Failed to register native method ProxyJavaScriptExecutor.initialize ... & no static or non-static method ProxyJavaScriptExecutor.initialize ...
when i run reactnative with multidex(dex-3) in note3 (5.0 OS) in my project ,i saw the error at runtime below:
from the logs ,it seem to aim to the native method
com/facebook/react/bridge/ProxyJavaScriptExecutor
private native void initialize(JavaJSExecutor var1);
Logs begin :
01-29 18:46:09.204 21856-22634/com.a E/art: Failed to register native method com.facebook.react.bridge.ProxyJavaScriptExecutor.initialize(Lcom/facebook/react/bridge/ProxyJavaScriptExecutor$JavaJSExecutor;)V in /data/app/com.a-2/base.apk 01-29 18:46:09.214 21856-22634/a W/ExceptionHandler: Exception occurs in worker thread , but it will not crash.
java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at
java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NoSuchMethodError: no static or non-static method "Lcom/facebook/react/bridge/ProxyJavaScriptExecutor;.initialize(Lcom/facebook/react/bridge/ProxyJavaScriptExecutor$JavaJSExecutor;)V" at java.lang.Runtime.nativeLoad(Native Method) at java.lang.Runtime.doLoad(Runtime.java:428) at java.lang.Runtime.load(Runtime.java:329) at java.lang.System.load(System.java:982) at com.facebook.soloader.DirectorySoSource.loadLibrary(Unknown Source) at com.facebook.soloader.SoLoader.loadLibraryBySoName(Unknown Source) at com.facebook.soloader.SoLoader.loadLibrary(Unknown Source) at com.facebook.react.bridge.JSCJavaScriptExecutor.(Unknown Source) at com.facebook.react.bridge.JSCJavaScriptExecutor$Factory.create(Unknown Source) at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(Unknown Source) at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(Unknown Source) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)
01-29 18:46:09.284 21856-21856/com.a W/unknown:React: Unable to dispatch keyboard events in JS as the react instance has not been attached
Logs end
thanks for @mkonicek @lexs @mhorowitz , do you see this error logs before ?
envs 1.use the multidex of android (dex NO.3) 2.mobile is 5.x android OS 3.in the app runtime ,when i use rootView.startReactApplication(); 4.from the log ,it is not also related to the progurad
is it possible that the .so was not loaded successfully( but i unzip the apk,i found all the .so in the libs folde ) ?
i use maven to build project,
the key log is :
java.lang.NoSuchMethodError: no static or non-static method "Lcom/facebook/react/bridge/ProxyJavaScriptExecutor;.initialize....
I'm not sure we support multidex actually. How did you enable it? Using the Gradle build file?http://stackoverflow.com/questions/26609734/how-to-enable-multidexing-with-the-new-android-multidex-support-library
@mkonicek @yipengmu I have the same exception but for a different method when I try to run react-native in an existing Android project that uses multidex.
Failed to register native method com.facebook.react.bridge.ReadableNativeMap.getType(Ljava/lang/String;)Lcom/facebook/react/bridge/ReadableType; in /data/app/<app_package>/base.apk:classes2.dex
@mkonicek The way it was enabled is the one described in the link you provided above. I am assuming that the error has something to do with the multiple dex files that get created now (2 in our case). The Java class loader can see and access see all dex files, but if you are trying to load a class from native code I think you have to make sure that everything you need is in the first file that the loader can see. I am still trying to figure out how to fix this and what are all the affected classes.
Thanks for the explanation @andreipt. I'm curious if you find out how to use multidex with Gradle, we only use multidex with Buck internally. Would be awesome to add it to the docs too.
@mkonicek So it seems that the problem was actually caused due to a misconfiguration in the proguard file. Since we are using multidex we are also runing proguard on all builds (even debug). I was missing:
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
and had to update the correct package for:
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
Hi there! This issue is being closed because it has been inactive for a while.
But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/failed-to-register-native-method-proxyjavascriptexecutorinitialize-no-static-or-non-static-method-proxyjavascriptexecutorinitialize-
ProductPains helps the community prioritize the most important issues thanks to its voting feature. It is easy to use - just login with GitHub. GitHub issues have voting too, nevertheless Product Pains has been very useful in highlighting the top bugs and feature requests: https://productpains.com/product/react-native?tab=top
Also, if this issue is a bug, please consider sending a pull request with a fix. We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.