CLJSRN Release Build Runtime Failure - android

I inherited this CLJS React Native codebase and I'm trying to upgrade the Android SDK to v26 with React 16.4 and RN 0.56. The debug build works great but the release build fails when starting up with the following call stack:
2018-11-21 10:31:30.731 16727-16790/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: XXX, PID: 16727
com.facebook.react.common.JavascriptException: Can't find variable: a, stack:
<unknown>#12:60553
<unknown>#12:60366
<unknown>#12:518500
c#2:822
i#2:394
t#2:324
global code#322:8
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(Native Method)
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(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Any ideas on how to get the non-minified version of the call stack? Is the minification done by the cljs to js compiler? Or the RN bundler/packager?
I'm currently using advanced optimizations on the cljs to js compiler. If I switch it to whitespace optimizations, then I get a build error
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
I can work around it by doing the bundling separately
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/build/intermediates/assets/release/index.android.bundle --assets-dest /usr/src/app/android/app/build/intermediates/res/merged/release
But I hit another failure
Unable to load script from assets 'index.android.bundle'.
Any ideas what else I can try?
Update 1: The "Unable to load script from assets 'index.android.bundle'." error message was caused by the index.android.bundle file being placed in the wrong folder. The following command worked:
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/src/main/assets/index.android.bundle --assets-dest /usr/src/app/android/app/src/main/res/
The unminified call stack looks like:
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Exception: Can't find variable: document (index.android.bundle:1632)
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Stack: index.android.bundle:1632:43
loadModuleImplementation#index.android.bundle:162:14
guardedLoadModule#index.android.bundle:83:47
metroRequire#index.android.bundle:72:79
global code#index.android.bundle:1639:8
2018-11-27 15:07:00.749 23765-23859/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: XXX, PID: 23765
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:525)
at com.facebook.react.bridge.CatalystInstanceImpl.access$1000(CatalystInstanceImpl.java:39)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:541)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:193) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
at java.lang.Thread.run(Thread.java:764) 
Caused by: com.facebook.jni.CppException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) 
at android.os.Looper.loop(Looper.java:193) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
at java.lang.Thread.run(Thread.java:764) 

APK worked OK after I restarted the RN upgrade process with react-native-git-upgrade. There was another issue after the upgrade with some unresolved symbol during runtime but that turned out to be an issue with the externs file because I had switched from the deprecated BackAndroid to BackHandler.

Related

Release app crash FATAL EXCEPTION: create_react_context (React Native)

I can build in debug mode, it works fine, but when I get release build, it gets build, but the application breaks, you can see the error output here.
FATAL EXCEPTION: create_react_context
java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
FATAL EXCEPTION: create_react_context
Process: com.example, PID: 27990
java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(Unknown Source:2)
at com.facebook.react.bridge.JSBundleLoader$1.loadScript(Unknown Source:10)
at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(Unknown Source:18)
at com.facebook.react.q.q(Unknown Source:180)
at com.facebook.react.q.b(Unknown Source:0)
at com.facebook.react.q$e.run(Unknown Source:68)
at java.lang.Thread.run(Thread.java:764)
"react-native": "0.62.2"
This is a 0.62.2 version issue that was solved here.
Long story short,
Edit ../../node_modules/react-native/react.gradle with this fix

React native App is getting crashed. Logcat logs are as described below-

2020-11-13 16:35:41.850 27509-27525/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.sehat, PID: 27509
java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'app.bundle' is packaged correctly for release.
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:235)
at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29)
at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:259)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1243)
at com.facebook.react.ReactInstanceManager.access$1000(ReactInstanceManager.java:132)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:996)
at java.lang.Thread.run(Thread.java:764)

running python in android app with chaquopy yields fatal error

I'm try to run python code in my android app using Chaquopy, I'm also using the moviepy library (I'm converting a mp4 file to a gif file). When I try to do the conversion I get the following error message:
2019-02-06 15:46:47.586 3924-3924/com.udacity.gradle.builditbigger E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.udacity.gradle.builditbigger, PID: 3924
com.chaquo.python.PyException: AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'
at <python>.moviepy.editor.<module>(<string>:1)
at <python>.moviepy.editor.<module>(editor.py:80)
at <python>.java.android.importer.load_module_impl(importer.py:435)
at <python>.java.android.importer.load_module(importer.py:353)
at <python>.importlib._bootstrap._load_backward_compatible(<frozen importlib._bootstrap>:626)
at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:656)
at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:955)
at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:971)
at <python>.java.chaquopy.import_override(import.pxi:18)
at <python>.gif_convert.<module>(gif_convert.py:1)
at <python>.java.android.importer.load_module_impl(importer.py:435)
at <python>.java.android.importer.load_module(importer.py:353)
at <python>.importlib._bootstrap._load_backward_compatible(<frozen importlib._bootstrap>:626)
at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:656)
at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:955)
at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:971)
at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:994)
at <python>.importlib.import_module(__init__.py:126)
at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModule(chaquopy_java.pyx:154)
at com.chaquo.python.Python.getModule(Native Method)
at com.udacity.gradle.builditbigger.newPost.visualMediaPost.VisualMediaPostFragment.moveFile(VisualMediaPostFragment.java:247)
at com.udacity.gradle.builditbigger.camera.LifeCycleCamera.getFilePath(LifeCycleCamera.java:1161)
at com.udacity.gradle.builditbigger.camera.LifeCycleCamera.stopRecordingVideo(LifeCycleCamera.java:1078)
at com.udacity.gradle.builditbigger.newPost.visualMediaPost.VisualMediaPostFragment.lambda$onCreateView$5(VisualMediaPostFragment.java:162)
at com.udacity.gradle.builditbigger.newPost.visualMediaPost.-$$Lambda$VisualMediaPostFragment$WS1G2y9p8sE-re_eOWFa7Rr0OCU.onClick(Unknown Source:4)
at android.view.View.performClick(View.java:6897)
at android.view.View$PerformClick.run(View.java:26089)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6940)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
I've found a fix for this problem (it involves changing the python code that would normally be generated by android studio, so any changes made to the python files will be overwritten during build time.
The python code is shown below
from moviepy.editor import VideoFileClip
def convert(path):
clip = VideoFileClip(path)
return clip.write_gif("output.gif", fps=24)
The java code used to start the pyhton code:
Python.start(new AndroidPlatform(getActivity()));
Python py = Python.getInstance();
PyObject gifConvert = py.getModule("gif_convert");
PyObject gif = gifConvert.callAttr("convert", file.getAbsolutePath());
Log.i("gif type", gif.toString());
Any help would be greatly appreciated.
Older versions of Chaquopy had a problem with pkgutil.iter_modules. This has been fixed in Chaquopy 6.2.1.

Nativescript Android build: Unable to instantiate activity ComponentInfo

I'm trying to create new Android app with Nativescript Angular, build passes ok, but when I try to run it on my device I get an error:
An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{<my-app-id>/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptActivity'
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptActivity'
at com.tns.Runtime.createJSInstanceNative(Native Method)
at com.tns.Runtime.createJSInstance(Runtime.java:643)
at com.tns.Runtime.initInstance(Runtime.java:618)
at com.tns.NativeScriptActivity.<init>(NativeScriptActivity.java:12)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
... 9 more
Reproduction steps:
cd elipay-builds
tns create MyApp --appid <my-app-id> --template ng
cd MyApp
npm install --save-dev nativescript-dev-webpack
npm install
./node_modules/.bin/update-ns-webpack --configs --deps
tns run android
tns build android --bundle
UPDATE 1: I managed to figure out that an issue is somehow connected to the applicationId.
UPDATE 2: If I update id property in my nativescript's package.json file:
{
...
"nativescript": {
"id": "<my-new-app-id>"
},
...
}
I need to assign new applicationId to my app each time I build it. And this is wrong, since stores will recognize my app as different one after the update.
I don't know what else I can try. Please help me.
Thanks :)

How to build and use PJSIP for different architectures than armeabi?

I succesfully compiled PJSIP library for Android. Sample project works without any problems when I build for default architecture armeabi. Now I tried to compile library for arch such as armeabi-v7a and arm64-v8a. Unfortunately when I add libraries to project in appropriate folders (jnLibs/armeabi-v7a and jniLibs/arm64-v8a) application is not starting...
To setup build for different archs I use this command:
NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags
I have this error on app launch:
07-04 12:28:46.079 15317-15317/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.futuremind.omili, PID: 15317
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "getifaddrs" referenced by "/data/app/com.futuremind.omili-1/lib/arm/libpjsua2.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:372)
at java.lang.System.loadLibrary(System.java:1076)
at com.futuremind.omili.MyApp.<clinit>(MyApp.java:293)
at com.futuremind.omili.MainActivity.onCreate(MainActivity.java:87)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Thanks for any help! :)
I was able to fix this error by updating the AndroidManifest.xml in "pjsip-apps/src/swig/java/android/app/src/main" to match my android target -- in my case to "23". Then "make clean" and another "make" in "pjsip-apps/src/swig", and rebuilding my app.

Categories

Resources