React Native App Crashes on Launch in Android (API 19) - android

Description
I have created a project with react-native-cli
When I launch the app using the command "react-native run-android" on Devices and Emulators with Android API level 21+ App is launching.
But for devices less than API 21, the app crashing on launch.
I have specified in android Gradle minSdk version to 16.
I viewed the stack trace using "adb logcat" the crash was due to OkHttp3 that is used internally in Facebook Flipper, which is expecting API 21+.
I haven't used any OkHttp3 Dependency explicitly in my app
React Native version:
6.14.4
Steps To Reproduce
Create a project using react-native CLI not Expo CLI
Navigate to the project folder
Connect a device or an emulator with API less than 21
run command "react-native run-android" to run the app on the connected device
Expected Results
The app should launch without any crash.
Android Logs
E/AndroidRuntime( 3745): java.lang.RuntimeException: Unable to create application com.infifive.MainApplication: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
E/AndroidRuntime( 3745): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4347)
E/AndroidRuntime( 3745): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
E/AndroidRuntime( 3745): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
E/AndroidRuntime( 3745): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 3745): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 3745): at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 3745): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3745): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 3745): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 3745): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 3745): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3745): Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
E/AndroidRuntime( 3745): at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:90)
E/AndroidRuntime( 3745): at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:238)
E/AndroidRuntime( 3745): at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:281)
E/AndroidRuntime( 3745): at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:87)
E/AndroidRuntime( 3745): at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:39)
E/AndroidRuntime( 3745): at com.infifive.MainApplication.onCreate(MainApplication.java:47)
E/AndroidRuntime( 3745): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
E/AndroidRuntime( 3745): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
E/AndroidRuntime( 3745): ... 10 more
E/AndroidRuntime( 3745): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 3745): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 3745): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
E/AndroidRuntime( 3745): at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:80)
E/AndroidRuntime( 3745): ... 17 more
E/AndroidRuntime( 3745): Caused by: java.lang.ExceptionInInitializerError
E/AndroidRuntime( 3745): at okhttp3.OkHttpClient.newSslSocketFactory(OkHttpClient.java:263)
E/AndroidRuntime( 3745): at okhttp3.OkHttpClient.<init>(OkHttpClient.java:229)
E/AndroidRuntime( 3745): at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1015)
E/AndroidRuntime( 3745): at com.facebook.react.devsupport.DevServerHelper.<init>(DevServerHelper.java:132)
E/AndroidRuntime( 3745): at com.facebook.react.devsupport.DevSupportManagerImpl.<init>(DevSupportManagerImpl.java:183)
E/AndroidRuntime( 3745): ... 20 more
E/AndroidRuntime( 3745): Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 19
E/AndroidRuntime( 3745): at okhttp3.internal.platform.AndroidPlatform.buildIfSupported(AndroidPlatform.java:238)
E/AndroidRuntime( 3745): at okhttp3.internal.platform.Platform.findPlatform(Platform.java:202)
E/AndroidRuntime( 3745): at okhttp3.internal.platform.Platform.<clinit>(Platform.java:79)`

The only way I found to fix it is by commenting out all the code associated with flipper
GH thread here

This happens because of an internal check in the library called "okhttp" where the newer versions are supporting only API 21 and above. If possible, reduce the okhttp version, or anything related to it such as Glide or Retrofit etc. That will solve your problem.

Related

Android javafxports NullPointerException

I'm getting a force close crash on a small Android app I made for school using Javafxports.
Here is the code and APKs
And the logcat returns this exception:
E/AndroidRuntime( 4474): FATAL EXCEPTION: JavaFX Application Thread
E/AndroidRuntime( 4474): Process: com.julioqc.superflush, PID: 4474
E/AndroidRuntime( 4474): java.lang.NullPointerException
E/AndroidRuntime( 4474): at com.sun.glass.ui.monocle.MonocleWindowManager$1.run(MonocleWindowManager.java:179)
E/AndroidRuntime( 4474): at com.sun.javafx.application.PlatformImpl.lambda$null$155(PlatformImpl.java:295)
E/AndroidRuntime( 4474): at com.sun.javafx.application.PlatformImpl$$Lambda$19.run(Unknown Source)
E/AndroidRuntime( 4474): at java.security.AccessController.doPrivileged(AccessController.java:52)
E/AndroidRuntime( 4474): at com.sun.javafx.application.PlatformImpl.lambda$runLater$156(PlatformImpl.java:294)
E/AndroidRuntime( 4474): at com.sun.javafx.application.PlatformImpl$$Lambda$6.run(Unknown Source)
E/AndroidRuntime( 4474): at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
E/AndroidRuntime( 4474): at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
E/AndroidRuntime( 4474): at java.lang.Thread.run(Thread.java:841)
I/cm.log.servpro( 1334): [Privacy]/ com.google.android.googlequicksearchbox is not in contact list
W/ActivityManager( 726): Force finishing activity com.julioqc.superflush/javafxports.android.FXActivity
What is causing this error in my code??
EDIT: found out the issue is caused by some unsupported JavaFX 8 dialogs. Trying alternative.

Crash at startup on port to Cordova Crosswalk (Android)

I'm porting an existing android cordova app to cordova crosswalk.
Using cordova 4, crosswalk-cordova-10.39.235.9-x86 and Android SDK 19
The app crashes at startup with the following logs in logcat:
D/AndroidRuntime( 7208): Shutting down VM
W/dalvikvm( 7208): threadid=1: thread exiting with uncaught exception (group=0x41caeda0)
E/AndroidRuntime( 7208): FATAL EXCEPTION: main
E/AndroidRuntime( 7208): Process: myapp.cqa, PID: 7208
E/AndroidRuntime( 7208): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 7208): at org.apache.cordova.CordovaActivity.makeWebView(CordovaActivity.java:295)
E/AndroidRuntime( 7208): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:348)
E/AndroidRuntime( 7208): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:323)
E/AndroidRuntime( 7208): at myapp.cqa.CordovaApp.onCreate(CordovaApp.java:31)
E/AndroidRuntime( 7208): at android.app.Activity.performCreate(Activity.java:5451)
E/AndroidRuntime( 7208): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
E/AndroidRuntime( 7208): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
E/AndroidRuntime( 7208): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2452)
E/AndroidRuntime( 7208): at android.app.ActivityThread.access$900(ActivityThread.java:172)
E/AndroidRuntime( 7208): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1302)
E/AndroidRuntime( 7208): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 7208): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 7208): at android.app.ActivityThread.main(ActivityThread.java:5586)
E/AndroidRuntime( 7208): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7208): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 7208): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
E/AndroidRuntime( 7208): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
E/AndroidRuntime( 7208): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 7208): Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
E/AndroidRuntime( 7208): at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:233)
E/AndroidRuntime( 7208): at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
E/AndroidRuntime( 7208): at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)
E/AndroidRuntime( 7208): at org.xwalk.core.ReflectionHelper.loadClass(ReflectionHelper.java:199)
E/AndroidRuntime( 7208): at org.xwalk.core.XWalkPreferences.setValue(XWalkPreferences.java:112)
E/AndroidRuntime( 7208): at org.apache.cordova.CordovaWebView.<clinit>(CordovaWebView.java:890)
E/AndroidRuntime( 7208): ... 18 more
E/AndroidRuntime( 7208): Caused by: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
E/AndroidRuntime( 7208): ... 23 more
Any idea why it crashes ?
OK, after a night of sleeping, I realized I was using x86 crosswalk instead of the ARM one. Sorry for the dumb issue post...

Android AVD is crashing with NullPointerException on startup

I'm trying to set up an Android Virtual Device (AVD) on my Debian Wheezy machine. I run this command, and the AVD Manager opened like it should:
/.../android-sdk/tools/android avd
Then, I tried to add an AVD for an existing device, but it just didn't start up, without any error message. So I created my own device and an AVD for it, and it starts up, but just shows the Android splash screen without any changes for hours. I read through the LogCat (adb logcat) and found this error message being repeated about every minute:
E/AndroidRuntime( 1672): *** FATAL EXCEPTION IN SYSTEM PROCESS: WindowManager
E/AndroidRuntime( 1672): java.lang.NullPointerException
E/AndroidRuntime( 1672): at com.android.server.display.LocalDisplayAdapter$LocalDisplayDevice.getDisplayDeviceInfoLocked(LocalDisplayAdapter.java:147)
E/AndroidRuntime( 1672): at com.android.server.display.DisplayManagerService.handleDisplayDeviceAddedLocked(DisplayManagerService.java:852)
E/AndroidRuntime( 1672): at com.android.server.display.DisplayManagerService.handleDisplayDeviceAdded(DisplayManagerService.java:841)
E/AndroidRuntime( 1672): at com.android.server.display.DisplayManagerService.access$1100(DisplayManagerService.java:96)
E/AndroidRuntime( 1672): at com.android.server.display.DisplayManagerService$DisplayAdapterListener.onDisplayDeviceEvent(DisplayManagerService.java:1281)
E/AndroidRuntime( 1672): at com.android.server.display.DisplayAdapter$1.run(DisplayAdapter.java:108)
E/AndroidRuntime( 1672): at android.os.Handler.handleCallback(Handler.java:733)
E/AndroidRuntime( 1672): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 1672): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 1672): at android.os.HandlerThread.run(HandlerThread.java:61)
E/AndroidRuntime( 1672): Error reporting crash
E/AndroidRuntime( 1672): java.lang.NullPointerException
E/AndroidRuntime( 1672): at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:84)
E/AndroidRuntime( 1672): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
E/AndroidRuntime( 1672): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
I also tried to delete the $HOME/.android/avd folder and recreating the AVD, but it didn't help.
How can I fix this error? Note that I only have installed the SDK, not Eclipse.

app still running after disable

I’ve installed an app I’ve written as a system app that after receiving ACTION_BOOT_COMPLETED it runs a service.
The app works just fine, however, I would like to disable it (and not remove it completely).
So I wrote on the command line “adb shell pm disable [The package name]” and after reboot, even though I do not see my app on the menu anymore, I still get a message “Unfortunately [myApp] has stopped”.
Logcat:
FATAL EXCEPTION: main
E/AndroidRuntime( 1356): java.lang.RuntimeException: Unable to instantiate service [package name] : java.lang.ClassNotFoundException: Didn't find class "[packagename.classThatStartsTheService]" on path: /system/app/app.apk
E/AndroidRuntime( 1356): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2516)
E/AndroidRuntime( 1356): at android.app.ActivityThread.access$1600(ActivityThread.java:144)
E/AndroidRuntime( 1356): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)
E/AndroidRuntime( 1356): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1356): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 1356): at android.app.ActivityThread.main(ActivityThread.java:5074)
E/AndroidRuntime( 1356): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1356): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 1356): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 1356): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 1356): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1356): Caused by: java.lang.ClassNotFoundException: Didn't find class "[packagename.class that starts the service]" on path: /system/app/app.apk
E/AndroidRuntime( 1356): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
E/AndroidRuntime( 1356): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime( 1356): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 1356): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2513)
E/AndroidRuntime( 1356): ... 10 more
Does that mean the boot_completed is still recognized by my app but because it is disabled it cannot run? Or is it something else?
Thanks in advance!
So, apparently I had another app that had the option to activate my app (only when choosing so and not by default), so after reboot, it couldn’t find it’s apk as it was disabled. So I disabled the second app as well.

Google Drive SDK application to upload file

I am trying to use the Google Drive SDK to upload files, but I am getting a pop up saying unfortunately your application has stopped. This is due to a NoClassDefFoundError. I also made sure to include the play services jar and check it in the order and export tab as well.
This is the excpetion:
E/AndroidRuntime( 4906): java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
E/AndroidRuntime( 4906): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.
newChooseAccountIntent(GoogleAccountCredential.java:253)
E/AndroidRuntime( 4906): at com.example.informationretreival.MainActivity.onCreate(MainActivity.java:42)
E/AndroidRuntime( 4906): at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime( 4906): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/AndroidRuntime( 4906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2147)
E/AndroidRuntime( 4906): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
E/AndroidRuntime( 4906): at android.app.ActivityThread.access$600(ActivityThread.java:144)
E/AndroidRuntime( 4906): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
E/AndroidRuntime( 4906): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4906): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 4906): at android.app.ActivityThread.main(ActivityThread.java:5074)
E/AndroidRuntime( 4906): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4906): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 4906): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 4906): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 4906): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 771): Force finishing activity com.example.informationretreival/.MainActivity
I am following the quickstart on the developer website I have literally just copied the code. I would expect the quickstart example to work. Someone please point me in the right direction.
In your Android application configuration page, select Google APIs (Google Inc.) (API 17) for Compile with. Also, it would work more stable on real phone than virtual device since virtual device doesn't have play store.

Categories

Resources