react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Unexpected native type exception in android

Open hzzcc opened this issue 11 years ago • 31 comments

09-19 08:55:39.816 9079-10772/com.facebook.react.uiapp E/unknown:React﹕ Exception in native call from JS com.facebook.react.bridge.UnexpectedNativeTypeException: TypeError: expected dynamic type string', but had typeint64' at com.facebook.react.bridge.ReadableNativeMap.getString(Native Method) at com.facebook.react.uimanager.CatalystStylesDiffMap.getString(CatalystStylesDiffMap.java:72) at com.facebook.react.views.text.ReactTextShadowNode.updateProperties(ReactTextShadowNode.java:320) at com.facebook.react.views.textinput.ReactTextInputShadowNode.updateProperties(ReactTextInputShadowNode.java:102) at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:256) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:106) at com.facebook.react.bridge.NativeModuleRegistry$ModuleDefinition.call(NativeModuleRegistry.java:126) at com.facebook.react.bridge.NativeModuleRegistry.call(NativeModuleRegistry.java:64) at com.facebook.react.bridge.CatalystInstance$NativeModulesReactCallback.call(CatalystInstance.java:326) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:135) at com.facebook.react.bridge.queue.MessageQueueThread$1.run(MessageQueueThread.java:137) at java.lang.Thread.run(Thread.java:818)

hzzcc avatar Sep 19 '15 00:09 hzzcc

Thanks for reporting! This might be a recent bug related to color handling which just got fixed on master.

Can you please share your JS code? Can you repro it consistently?

mkonicek avatar Sep 19 '15 01:09 mkonicek

I just run the examples in react-native,and got the error. I hadn't wrote more than one code.

hzzcc avatar Sep 19 '15 01:09 hzzcc

I pull down the newest codes, but still have the problem when I run examples

hzzcc avatar Sep 19 '15 01:09 hzzcc

It's definitely caused by 9a2d05d9b2aea459ef3b3e92376cf15bca4d17fa, and it doesn't seem to be fixed in master yet. If I revert this commit, UIExplorer comes up fine. With the commit, you get this error.

malchev avatar Sep 19 '15 03:09 malchev

Thanks, @malchev

hzzcc avatar Sep 19 '15 04:09 hzzcc

Same problem. Here is the crash log in sample app com.facebook.react.movies

E: FATAL EXCEPTION: main
E: Process: com.facebook.react.movies, PID: 10425
E: com.facebook.react.bridge.UnexpectedNativeTypeException: TypeError: expected dynamic type `string', but had type `int64'
E:     at com.facebook.react.bridge.ReadableNativeMap.getString(Native Method)
E:     at com.facebook.react.uimanager.CatalystStylesDiffMap.getString(CatalystStylesDiffMap.java:72)
E:     at com.facebook.react.uimanager.BaseViewPropertyApplicator.applyCommonViewProperties(BaseViewPropertyApplicator.java:77)
E:     at com.facebook.react.uimanager.ViewGroupManager.updateView(ViewGroupManager.java:28)
E:     at com.facebook.react.views.view.ReactViewManager.updateView(ReactViewManager.java:87)
E:     at com.facebook.react.views.view.ReactViewManager.updateView(ReactViewManager.java:40)
E:     at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:182)
E:     at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:137)
E:     at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:574)
E:     at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:622)
E:     at com.facebook.react.uimanager.GuardedChoreographerFrameCallback.doFrame(GuardedChoreographerFrameCallback.java:32)
E:     at com.facebook.react.uimanager.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:114)
E:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:759)
E:     at android.view.Choreographer.doCallbacks(Choreographer.java:574)
E:     at android.view.Choreographer.doFrame(Choreographer.java:543)
E:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
E:     at android.os.Handler.handleCallback(Handler.java:733)
E:     at android.os.Handler.dispatchMessage(Handler.java:95)
E:     at android.os.Looper.loop(Looper.java:136)
E:     at android.app.ActivityThread.main(ActivityThread.java:5114)
E:     at java.lang.reflect.Method.invokeNative(Native Method)
E:     at java.lang.reflect.Method.invoke(Method.java:515)
E:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
E:     at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
E:     at dalvik.system.NativeStart.main(Native Method)

miao1007 avatar Sep 19 '15 09:09 miao1007

:+1:

Zenedith avatar Sep 19 '15 17:09 Zenedith

Same issue here - so far on UIExplorer and Movies.

zakelfassi avatar Sep 20 '15 14:09 zakelfassi

At least my problem is that UIExplorer's build.gradle depends on the prebuilt react native for Android. Once I realized that and switched over to sources, things started working again. Commit 9a2d05d9b2aea459ef3b3e92376cf15bca4d17fa changed Examples/UIExplorer, which caused the incompatibility with the prebuilt react native. I guess the build.gradle files in Exapmples should switch to compile from sources by default:

diff --git a/Examples/UIExplorer/android/app/build.gradle b/Examples/UIExplorer/android/app/build.gradle index 275ffb2..79fd9e8 100644 --- a/Examples/UIExplorer/android/app/build.gradle +++ b/Examples/UIExplorer/android/app/build.gradle @@ -27,9 +27,9 @@ dependencies { compile 'com.android.support:appcompat-v7:23.0.1'

 // Depend on pre-built React Native
  • compile 'com.facebook.react:react-native:0.11.+'
  • // compile 'com.facebook.react:react-native:0.11.+'

// Depend on React Native source. // This is useful for testing your changes when working on React Native.

  • // compile project(':ReactAndroid')
  • compile project(':ReactAndroid') }

malchev avatar Sep 21 '15 18:09 malchev

The examples don't build from source to keep the setup instructions less complicated (you need the NDK installed to build it).

ide avatar Sep 21 '15 18:09 ide

Hello

I just cloned the latest master (UTC/GMT is 20:00 on 23 September 2015) and I get the red screen of death saying:

TypeError: expected dynamic type 'string', but had type 'int64'

That is with the default project created with react-native init freedom and react-native run-android.

I also get this console output from react-native start

Unable to resolve module image!myIcon from Y:\fraedom\node_modules\react-native\Libraries\Image\Image.android.js
Unable to resolve module image!app_logo from Y:\fraedom\node_modules\react-native\Libraries\Components\ToolbarAndroid\ToolbarAndroid.android.js
Unable to resolve module image!icon_settings from Y:\fraedom\node_modules\react-native\Libraries\Components\ToolbarAndroid\ToolbarAndroid.android.js
Unable to resolve module image!some_icon from Y:\fraedom\node_modules\react-native\Libraries\Components\ToolbarAndroid\ToolbarAndroid.android.js
Unable to resolve module image!myButton from Y:\fraedom\node_modules\react-native\Libraries\Components\Touchable\TouchableHighlight.js
Unable to resolve module image!myButton from Y:\fraedom\node_modules\react-native\Libraries\Components\Touchable\TouchableOpacity.js

Any ideas how to fix that? @ide @malchev

Here is the complete output

Y:\fraedom>react-native start
 ┌────────────────────────────────────────────────────────────────────────────┐
 │  Running packager on port 8081.                                            │
 │                                                                            │
 │  Keep this packager running while developing on any JS projects. Feel      │
 │  free to close this tab and run your own packager instance if you          │
 │  prefer.                                                                   │
 │                                                                            │
 │  https://github.com/facebook/react-native                                  │
 │                                                                            │
 └────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
   Y:\fraedom

[8:55:21 AM] <START> Building Dependency Graph
[8:55:21 AM] <START> Crawling File System
[8:55:21 AM] <START> Loading bundles layout
[8:55:21 AM] <END>   Loading bundles layout (0ms)

React packager ready.

[8:55:31 AM] <END>   Crawling File System (9938ms)
[8:55:31 AM] <START> Building in-memory fs for JavaScript
[8:55:32 AM] <END>   Building in-memory fs for JavaScript (1265ms)
[8:55:32 AM] <START> Building in-memory fs for Assets
[8:55:33 AM] <END>   Building in-memory fs for Assets (1037ms)
[8:55:33 AM] <START> Building Haste Map
[8:55:34 AM] <START> Building (deprecated) Asset Map
[8:55:34 AM] <END>   Building (deprecated) Asset Map (166ms)
[8:55:34 AM] <END>   Building Haste Map (883ms)
[8:55:34 AM] <END>   Building Dependency Graph (13130ms)
[8:55:44 AM] <START> request:/index.android.bundle?platform=android
[8:55:44 AM] <START> find dependencies
Unable to resolve module image!myIcon from Y:\fraedom\node_modules\react-native\Libraries\Image\Image.android.js
Unable to resolve module image!app_logo from Y:\fraedom\node_modules\react-native\Libraries\Components\ToolbarAndroid\ToolbarAndroid.android.js
Unable to resolve module image!icon_settings from Y:\fraedom\node_modules\react-native\Libraries\Components\ToolbarAndroid\ToolbarAndroid.android.js
Unable to resolve module image!some_icon from Y:\fraedom\node_modules\react-native\Libraries\Components\ToolbarAndroid\ToolbarAndroid.android.js
Unable to resolve module image!myButton from Y:\fraedom\node_modules\react-native\Libraries\Components\Touchable\TouchableHighlight.js
Unable to resolve module image!myButton from Y:\fraedom\node_modules\react-native\Libraries\Components\Touchable\TouchableOpacity.js
[8:55:45 AM] <END>   find dependencies (145ms)
[8:55:45 AM] <START> transform
transforming [========================================] 100% 314/314
[8:55:45 AM] <END>   transform (89ms)
[8:55:45 AM] <END>   request:/index.android.bundle?platform=android (256ms)
::ffff:127.0.0.1 - - [Wed, 23 Sep 2015 20:55:46 GMT] "GET /flow/ HTTP/1.1" 404 - "-" "okhttp/2.4.0"

BerndWessels avatar Sep 23 '15 21:09 BerndWessels

cc @mkonicek ^ this issue may block 0.12

ide avatar Sep 23 '15 21:09 ide

Here is the red screen of death I got:

rn1

BerndWessels avatar Sep 23 '15 21:09 BerndWessels

Facing the same issue.

neeraj-singh avatar Sep 24 '15 12:09 neeraj-singh

Thanks for reporting! This is a KP which was fixed on master, see https://github.com/facebook/react-native/issues/2983

mkonicek avatar Sep 24 '15 14:09 mkonicek

@mkonicek Sorry, I belive it is still not fixed, see #2983 for details.

BerndWessels avatar Sep 24 '15 21:09 BerndWessels

Hi @malchev I still have this problem with the latest master.

Can you please tell me in more detail what your fix is?

I tried changing the 'guild.gradle' as you mentioned to:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    // compile 'com.facebook.react:react-native:0.11.+'
    compile project(':ReactAndroid')
}

But only get:

Y:\hope>react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat install
Debug)...

FAILURE: Build failed with an exception.

* Where:
Build file 'Y:\hope\android\app\build.gradle' line: 29

* What went wrong:
A problem occurred evaluating project ':app'.
> Project with path ':ReactAndroid' could not be found in project ':app'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 7.219 secs
Could not install the app on the device, see the error above.

Y:\hope>

BerndWessels avatar Sep 24 '15 21:09 BerndWessels

@BerndWessels obviously you need to add the ReactAndroid project/folder to your project folder. Put the folder from react-native/ReactAndroid to your project's folder, then add include ':ReactAndroid' to settings.gradle. You'll be good to go.

zakelfassi avatar Sep 24 '15 21:09 zakelfassi

@zakelfassi you can link it from node_modules also i guess. no need to copy.

In settings.gradle

include ':ReactAndroid', ':app'
project(': ReactAndroid').projectDir = new File(rootProject.projectDir, '../node_modules/react-native')

chirag04 avatar Sep 24 '15 22:09 chirag04

@zakelfassi OK, thank you, I try.

is this correct build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.hope"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    // compile 'com.facebook.react:react-native:0.11.+'
    compile project(':ReactAndroid')
}

And where does the ReactAndroid folder has to be copied to exactly?

BerndWessels avatar Sep 24 '15 22:09 BerndWessels