integrating react native into existing android app - android

So I have a pretty robust android application and I want to add some code from a react-native only application in one activity. I've gone through the docs on the site and it turned out to be a lot more complicated to integrate a react-native app into an existing android native app. Among the may errors, this is the one I'm current stuck on, does anyone know where this comes from?
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoClassDefFoundError: com.facebook.react.CoreModulesPackage$1
at com.facebook.react.CoreModulesPackage.getNativeModules(CoreModulesPackage.java:96)
at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:71)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:97)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:950)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:880)
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:104)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:218)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:197)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
It's currently fetching the bundle and it gets to 100 percent but then the activity crashes with the error output above about CoreModulesPackages.
It's been pretty frustrating trying to get this thing up and running, there seems to be a bunch of errors from many sides, I had to import react native manually through an aar since the version on maven is archaic(0.20), download okhttp web socket support, FLog and .so loader stuff. Among also having to exclude architecture specific code. If anyone knows of an easier way to integrate a RN app into an existing codebase, I'd really appreciate it.
I'm coming from the native side trying to understand this thing. I set up npm, bundle up the js before staring the server and then run my app. After which i forward to the proper 8081 port. If I'm doing the sequence of steps wrong then someone please correct me. It's been 3 days. Halp.

I encountered this same error in my react native app on Android 5.x devices -- no issues on 6 or 7.
The issue ceased to occur after I removed Fabric.io Crashlytics as a dependency from my app.

I got same error.
Probles has been solved by properly configuration of multidex for old android
In my case I forgot to inherit my application class from MultiDexApplication

Related

E/com.facebook.appevents.RestrictiveDataManager: updateRulesFromSetting failed

When I launch my app from Android Studio, with Facebook SDK installed on my device, Xiaomi Mi A2, it triggers the same error trhee times. It does not stop the app, but I don't know if I am missing something or simply, it is not important, but in the end, it is an error and I want to clarify it.
I am using Android Studio 3.4.1, Android 9 on the Xiaomi A2 and the new clause in build.gradle file is implementation 'com.facebook.android:facebook-android-sdk:5.1.0'. Error has not appeared before upgrading Facebook SDK.
This is what appears in Logcat:
2019-06-24 18:24:31.202 25105-25136/com.myapp
E/com.facebook.appevents.RestrictiveDataManager:
updateRulesFromSetting failed
org.json.JSONException: End of input at character 0 of
at org.json.JSONTokener.syntaxError(JSONTokener.java:449)
at org.json.JSONTokener.nextValue(JSONTokener.java:97)
at org.json.JSONArray.(JSONArray.java:92)
at org.json.JSONArray.(JSONArray.java:108)
at com.facebook.appevents.RestrictiveDataManager.updateFromSetting(RestrictiveDataManager.java:32)
at com.facebook.internal.FetchedAppSettingsManager.parseAppSettingsFromJSON(FetchedAppSettingsManager.java:323)
at com.facebook.internal.FetchedAppSettingsManager.access$000(FetchedAppSettingsManager.java:63)
at com.facebook.internal.FetchedAppSettingsManager$1.run(FetchedAppSettingsManager.java:181)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
EDIT
The issue has been fixed in version 5.1.1.
Revert to 5.0.3 to get rid of this.
5.1.0 is actually crashing in production at this method (there's a bug report here). GitHub commits of this file show its rather flawed, the method is called from multiple threads concluding to a concurrency crash because it's using a static ArrayList.
Lately the core FB SDK is kinda bloated with useless stuff and low-quality code. The codeless stuff "feature" that simply can't even be turned off is especially a horror to look at. If you don't strictly need the FB SDK in your app, I'd avoid it until they get their shit figured out.

App crashes with the error INVALID_STATE_ERR

I am using react native. I am getting the crashes on crashlytics with the error INVALID_STATE_ERR.I am using FireBase Crashlytics. I am also using MQTT client for making web socket connection.
I am not able to figure out the reason of crashing the app. Is it due to the MQTT WebSockets or due to the error occurring on javascript thread? I am also not getting any relevant message from the stack trace either.
I am pasting my Stack Trace below.
Fatal Exception: com.facebook.react.common.JavascriptException: INVALID_STATE_ERR, stack:
value#79:1340
_socket_send#557:21101
_on_socket_open#557:16408
<unknown>#557:628
value#63:1501
<unknown>#79:4566
value#32:1363
value#18:3559
<unknown>#18:1044
value#18:2986
value#18:1016
at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
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:29)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:818)
Can I get more insight to fix this issue?
According to this Wix GitHub issue, it is caused by:
Too many views on older phones. RNN added a few nested views, but it appears I may have too many anyways.
That issue links to a pull request on React Native's GitHub repo, which should now be merged in. It mentions the issue is on pre-API 21, so I suggest you try your code on later APIs and see if it persists.
Either way, reducing the number of views (or requests, in this case?) seems a good first step.

Android crash : /data/user/0/[my app]/cache/WebView is not a directory

Hi I'm in a bit of bind here.
My app doesn't use webview anywhere, and my most frequent crash in Crashlytics is this error : /data/user/0/[myApp]/cache/WebView is not a directory.
The stack trace is minified despite me not using Proguard to minify/obfuscate so it's probably a lib I'm using.
Caused by java.lang.IllegalArgumentException: /data/user/0/[myApp]/cache/WebView is not a directory.
at bHS.<init>(SourceFile:58)
at akR.a(SourceFile:7)
at aoN.call(SourceFile:7)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at aoR.run(SourceFile:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
I'm thinking adMob since it's the only thing that could use a webView or maybe crashlytics itself ?
Has anyone encounter this problem or any lead on how to fix it ?
I tried creating this folder on app startup but it's deleted.
In my case it was that i did not add permissions for internet usage in the manifest:
<uses-permission android:name="android.permission.INTERNET" />
According to this post on the "android-webview-dev" Google Group by a chromium dev:
That looks like a real bug, and it would never show up in our crash reporting because that's crashing in crash handling code.
So it looks like the crash is within Chromium's crash reporting code which... doesn't help you much.
Can you reproduce it at all, or have any users told you how it happened? Additionally, is there any additional information available on Crashlytics (e.g. it only happens on certain Android versions / certain devices)?

Dexguard crashing after library added with native code

After adding a library to project that contains native code (embedded as .so), my app build started to crash when running the dexguard<Flavor><BuildType> task.
The error says:
Caused by: java.io.IOException: Can't read [/home/user/project/app/build/intermediates/transforms/mergeJniLibs/flavor/buildType/folders/2000/1f/main(;;;;;;lib/*/*.so,lib/*/gdb*)] (Can't write resource [lib/x86/filecointainedonlibrary.so] (New string section exceeds the length of the original: 243 > 242))
That might happen when DexGuard obfuscates your native methods.
The latest version 7.1.29 should fix this issue, please give it a try.
Edit: The troubleshooting section of the DexGuard manual describes work-arounds when this happens. They basically keep names of native methods.

Netty 5 Secure WebSockets running on Android causes NoClassDefFoundError for io/netty/channel/DefaultChannelId

I am using Netty 5 alpha release on android to write a secure web socket client.
But at the run time I am getting NoClassDefFoundError for io/netty/channel/DefaultChannelId.
The class is already exists in the Jar file. Can anybody tell me why this issue is happening.
Caused by: java.lang.NoClassDefFoundError: io/netty/channel/DefaultChannelId

Categories

Resources