I'm getting the below error when running an opensource Flutter app that I checked out from Github. It runs the first Activity of the screen and after about 1-second app crashes with the following error in Logcat. I'm not able to see any errors in Run console of Flutter.
Process: app.ceylon.selftrackingapp, PID: 32590
java.lang.RuntimeException: Unable to start activity ComponentInfo{app.ceylon.selftrackingapp/app.ceylon.selftrackingapp.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.BinaryMessenger.setMessageHandler(java.lang.String, io.flutter.plugin.common.BinaryMessenger$BinaryMessageHandler)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3448)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7811)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.BinaryMessenger.setMessageHandler(java.lang.String, io.flutter.plugin.common.BinaryMessenger$BinaryMessageHandler)' on a null object reference
at io.flutter.plugin.common.MethodChannel.setMethodCallHandler(MethodChannel.java:116)
at com.baseflow.geolocator.GeolocatorPlugin.registerWith(GeolocatorPlugin.java:49)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:20)
at app.ceylon.selftrackingapp.MainActivity.onCreate(MainActivity.kt:32)
at android.app.Activity.performCreate(Activity.java:7955)
at android.app.Activity.performCreate(Activity.java:7944)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7811)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
2020-03-21 10:09:53.328 15534-15539/? E/nightwatch-watcher: Failed to read from logcat: Success
I'm using an actual device Galaxy S9+ for testing and here is the Flutter version that I have installed in my computer.
Flutter 1.15.17 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 2294d75bfa (2 weeks ago) • 2020-03-07 00:28:38 +0900
Engine • revision 5aff311948
Tools • Dart 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)
I've also looked for the solution and I've found one here.
The core is: add " flutter_plugin_android_lifecycle: ^1.0.4" to pubspec.yaml
Related
I've developed a KivyMD app which runs fine on my Windows machine. However, my company has locked down all my USB ports, so I'm not able to "deploy" the app for testing with Buildozer. Instead, I'm using Android Studio to emulate Android. I'm able to install my APK file (produced with Buildozer) on the virtual device, but when I launch the app I only see a Kivy splash screen which says "Loading..." for a second and then it crashes.
Android Studio provides the following log, but as far as I can tell it offers no clue to what the problem is.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.facefinder, PID: 3493
java.lang.RuntimeException: Unable to resume activity {com.example.facefinder/com.example.facefinder.MainActivity}:
java.lang.NullPointerException: Attempt to get length of null array
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4205)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at com.example.facefinder.MainActivity.onResume(MainActivity.java:81)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1446)
at android.app.Activity.performResume(Activity.java:7939)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
What can I do to diagnose my problem? Thanks in advance for any guidance!
flutter app works just fine in android debug, ios debug and ios release. but with android release (flutter build apk) it just does not launch.
What I've tried:
lowering the gradle version from 4.1.3 to 3.6.2 as suggested in here.
running with no-shrink flag (flutter build apk --no-shrink).
setting shrinkResources and minifyEnabled to false in android/app/build.gradle
HERE IS A VIDEO THAT SHOWS THE ERROR CLEARLY
this is my flutter doctor -v output:
[√] Flutter (Channel stable, 2.0.5, on Microsoft Windows [Version 10.0.19041.928], locale
en-US)
• Flutter version 2.0.5 at C:\Users\adnan\flutter
• Framework revision adc687823a (3 days ago), 2021-04-16 09:40:20 -0700
• Engine revision b09f014e96
• Dart version 2.12.3
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\adnan\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.55.2)
• VS Code at C:\Users\adnan\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.21.0
[√] Connected device (3 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30)
(emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.128
• Edge (web) • edge • web-javascript • Microsoft Edge 89.0.774.57
• No issues found!
edit: here is the error log from the android studio Logcat:
2021-04-20 09:58:24.300 6866-6866/? E/FlutterLoader: Flutter initialization failed.
java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
at java.util.concurrent.FutureTask.report(FutureTask.java:123)
at java.util.concurrent.FutureTask.get(FutureTask.java:193)
at io.flutter.embedding.engine.g.c.c(Unknown Source:23)
at io.flutter.embedding.engine.a.<init>(Unknown Source:202)
at io.flutter.embedding.engine.a.<init>(Unknown Source:16)
at io.flutter.embedding.android.f.B(Unknown Source:106)
at io.flutter.embedding.android.f.k(Unknown Source:7)
at io.flutter.embedding.android.e.onCreate(Unknown Source:13)
at com.myExampleApp.MainActivity.onCreate(Unknown Source:0)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
at java.lang.System.loadLibrary(System.java:1664)
at io.flutter.embedding.engine.FlutterJNI.loadLibrary(Unknown Source:13)
at io.flutter.embedding.engine.g.c$a.a(Unknown Source:14)
at io.flutter.embedding.engine.g.c$a.call(Unknown Source:0)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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:923)
2021-04-20 09:58:24.300 6866-6866/? D/AndroidRuntime: Shutting down VM
--------- beginning of crash
2021-04-20 09:58:24.301 6866-6866/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myExampleApp, PID: 6866
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myExampleApp/com.myExampleApp.MainActivity}: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
at io.flutter.embedding.engine.g.c.c(Unknown Source:367)
at io.flutter.embedding.engine.a.<init>(Unknown Source:202)
at io.flutter.embedding.engine.a.<init>(Unknown Source:16)
at io.flutter.embedding.android.f.B(Unknown Source:106)
at io.flutter.embedding.android.f.k(Unknown Source:7)
at io.flutter.embedding.android.e.onCreate(Unknown Source:13)
at com.myExampleApp.MainActivity.onCreate(Unknown Source:0)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
at java.util.concurrent.FutureTask.report(FutureTask.java:123)
at java.util.concurrent.FutureTask.get(FutureTask.java:193)
at io.flutter.embedding.engine.g.c.c(Unknown Source:23)
at io.flutter.embedding.engine.a.<init>(Unknown Source:202)
at io.flutter.embedding.engine.a.<init>(Unknown Source:16)
at io.flutter.embedding.android.f.B(Unknown Source:106)
at io.flutter.embedding.android.f.k(Unknown Source:7)
at io.flutter.embedding.android.e.onCreate(Unknown Source:13)
at com.myExampleApp.MainActivity.onCreate(Unknown Source:0)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
at java.lang.System.loadLibrary(System.java:1664)
at io.flutter.embedding.engine.FlutterJNI.loadLibrary(Unknown Source:13)
at io.flutter.embedding.engine.g.c$a.a(Unknown Source:14)
at io.flutter.embedding.engine.g.c$a.call(Unknown Source:0)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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:923)
2021-04-20 09:58:24.308 519-5643/? W/ActivityTaskManager: Force finishing activity com.myExampleApp/.MainActivity
2021-04-20 09:58:24.309 306-306/? W/EmuHWC2: validate: layer 37 CompositionType 1, fallback
(maybe duplicate of this)
its a general flutter sdk and android architecture support issue as at now, waiting for a permanent fix....
but This abifilters solution solved the issue on emulator blue stacks emulating an LG phone for me..
Add the ndk code in the defaultConfig tag inside your build.gradle android file of your project
**
android {
//...
defaultConfig {
ndk {
// Filter for architectures supported by Flutter.
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
}
}
}
**
Dont know if has drawbacks on other phones, but i will be updating this thread as we rollout and see which phones our customers who get same issues again are getting it on
Edit, Also Add lines below to the end of settings.gradle: file to filter more.. This code will generate file libflutter.so on folders x86_64, arm64-v8a and armeabi-v7a. And for devices x86, then emulate arm which are the devices with the problems..
gradle.beforeProject({ project->
if (project.hasProperty("target-platform") &&
!project.getProperty("target-platform").split(",").contains("android-arm")) {
project.setProperty("target-platform", "android-arm,android-arm64")
}
})
I am making this post today because I have a problem with my ionic application.
So here it is, the app builds perfectly on an emulator with android studio. However, right after the splash screen it crashes instantly. I have no idea why this is happening. After running the app in debug mode, I get this error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.julesbsz.shortnews, PID: 862
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.julesbsz.shortnews/com.julesbsz.shortnews.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONArray.length()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONArray.length()' on a null object reference
at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.load(GoogleAuth.java:47)
at com.getcapacitor.PluginHandle.load(PluginHandle.java:72)
at com.getcapacitor.PluginHandle.<init>(PluginHandle.java:44)
at com.getcapacitor.Bridge.registerPlugin(Bridge.java:476)
at com.getcapacitor.Bridge.registerAllPlugins(Bridge.java:440)
at com.getcapacitor.Bridge.<init>(Bridge.java:170)
at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:83)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:62)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:48)
at com.julesbsz.shortnews.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'
I really don't see what the problem is. Also, if you need more information about something in particular, let me know. Thank you very much.
If you read the stacktrace you can see that the crash originates from
at com.julesbsz.shortnews.MainActivity.onCreate(MainActivity.java:17)
It then appears to fail at some authorization logic
at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.load(GoogleAuth.java:47)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONArray.length()' on a null object reference
You did not post your code so perhaps this is a good time to learn how to set breakpoints and debug?
https://developer.android.com/studio/debug#breakPoints
Creating an Ionic 5 app with Capacitor, I'm running into this problem where it seems that capacitor.config.json is not being loaded.
This problem came after I've installed #codetrix-studio/capacitor-google-auth, before the project was running on android fine.
{
"appId": "com.luyou.clauncher",
"appName": "c-launchpad",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"plugins": {
"SplashScreen": {
"launchShowDuration": 0
},
"GoogleAuth": {
"scopes": [
"profile",
"email"
],
"serverClientId": "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", // On my project I'm using the real server client id
"forceCodeForRefreshToken": true
}
}
}
On the android studio the build goes okay but when you try to open the app, it does crash with the following:
D/Capacitor: Starting BridgeActivity
E/Capacitor: Unable to load capacitor.config.json. Run npx cap copy first
java.io.FileNotFoundException: capacitor.config.json
at android.content.res.AssetManager.nativeOpenAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:874)
at android.content.res.AssetManager.open(AssetManager.java:851)
at com.getcapacitor.FileUtils.readFile(FileUtils.java:148)
at com.getcapacitor.CapConfig.loadConfig(CapConfig.java:121)
at com.getcapacitor.CapConfig.loadDefault(CapConfig.java:85)
at com.getcapacitor.Bridge.<init>(Bridge.java:152)
at com.getcapacitor.Bridge$Builder.create(Bridge.java:1160)
at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:73)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:54)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:37)
at com.luyou.clauncher.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
D/Capacitor: Registering plugin: WebView
D/Capacitor: Registering plugin: AdMob
D/Capacitor: Registering plugin: GoogleAuth
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.luyou.clauncher, PID: 11477
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.luyou.clauncher/com.luyou.clauncher.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONArray.length()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONArray.length()' on a null object reference
at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.load(GoogleAuth.java:47)
at com.getcapacitor.PluginHandle.load(PluginHandle.java:95)
at com.getcapacitor.PluginHandle.<init>(PluginHandle.java:59)
at com.getcapacitor.Bridge.registerPlugin(Bridge.java:464)
at com.getcapacitor.Bridge.registerAllPlugins(Bridge.java:419)
at com.getcapacitor.Bridge.<init>(Bridge.java:164)
at com.getcapacitor.Bridge$Builder.create(Bridge.java:1160)
at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:73)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:54)
at com.getcapacitor.BridgeActivity.init(BridgeActivity.java:37)
at com.luyou.clauncher.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process: Sending signal. PID: 11477 SIG: 9
capacitor.config.json is already on the root path of the project and doing npx cap copy or npx cap sync doesn't solve this problem, but actually is copying the www files. For some reason, the capacitor config simply is just not being copied.
Seems like Capacitor alpha versions are broken, so gonig back to Capacitor 2.4.7 fixes the problem. The capacitor.config.json is loading correctly and the native plugins are loading fine.
awesome, thanks #Adrian Legaspi.
Downgrading to capacitor 2.4.7 solved it for me.
This is what my package.json looks like:
"dependencies": {
...
"#capacitor/android": "^2.4.2",
"#capacitor/core": "2.4.7",
..
},
"devDependencies": {
...
"#capacitor/cli": "2.4.2",
...
}
The splash activity of my app works well on all devices except on an Android 10 device that I have just recently updated.
Here is my code:
public class SplashScreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(FirebaseAuth.getInstance().getUid() != null)
startActivity(new Intent(this, HomeActivity.class));
else
startActivity(new Intent(this, LoginActivity.class));
finish();
}
}
I have also tried navigating directly to HomeActiviy or LoginActivity but still crashes when I try to run on an Android 10 device
Error occurs when calling super.onCreate(savedInstanceState)
2020-01-17 13:58:25.527 23561-23561/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: rickroydaban.projects.android.memorise, PID: 23561
java.lang.RuntimeException: Unable to start activity ComponentInfo{rickroydaban.projects.android.memorise/rickroydaban.android.memorise.ui.SplashScreen}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.lifecycle.ReportFragment.setProcessListener(androidx.lifecycle.ReportFragment$ActivityInitializationListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3448)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7811)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.lifecycle.ReportFragment.setProcessListener(androidx.lifecycle.ReportFragment$ActivityInitializationListener)' on a null object reference
at androidx.lifecycle.ProcessLifecycleOwner$3.onActivityCreated(ProcessLifecycleOwner.java:162)
at android.app.Application.dispatchActivityCreated(Application.java:392)
at android.app.Activity.dispatchActivityCreated(Activity.java:1232)
at android.app.Activity.onCreate(Activity.java:1513)
at androidx.core.app.ComponentActivity.onCreate(ComponentActivity.java:81)
at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:149)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:313)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:106)
at rickroydaban.android.memorise.ui.SplashScreen.onCreate(SplashScreen.java:18)
at android.app.Activity.performCreate(Activity.java:7955)
at android.app.Activity.performCreate(Activity.java:7944)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7811)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
Has anyone able to fix this issue?
As per this issue, this will occur when using lifecycle-runtime:2.2.0 (usually through a transitive dependency on Fragment or AppCompat) and lifecycle-process:2.1.0 (usually through a transitive dependency on lifecycle-extensions).
There are a number of work arounds available in the bug:
You do any one of the following:
Add an explicit dependency on lifecycle-process:2.2.0-alpha05 to pull in the new version that is compatible with lifecycle-runtime:2.2.0-alpha05
Upgrade your lifecycle:extensions dependency to 2.2.0-alpha05 so that lifecycle-process is upgraded
Remove the lifecycle:extensions dependency entirely and use only the lifecycle libraries you need (for example, use lifecycle-viewmodel-ktx if you want ViewModels) so that you don't pull in lifecycle-process at all
Or, since the compatibility issue has been fixed in a later release, upgrade to a later version of Fragments (version 1.2.0-beta01 or higher) or Lifecycle 2.2.0-beta01 or higher if you directly depend on Lifecycle.