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
Related
I have this one line under MainActivity.kt file, no syntax errors and gradle is completely building the app, but when I open it in Emulator (Android 11) it closes instantly with message "App stopped working"
on messing around this is the one line causing it
var Thelist = findViewById<ImageButton>(/*Correct ImageButton D*/)
The logs of Emulator show
Process: com.cobalt.MyApp, PID: 5052
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.cobalt.MyApp/com.cobalt.MyApp.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3365)
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 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:173)
at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:174)
at android.content.Context.obtainStyledAttributes(Context.java:744)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:852)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:819)
at androidx.appcompat.app.AppCompatDelegateImpl.findViewById(AppCompatDelegateImpl.java:640)
at androidx.appcompat.app.AppCompatActivity.findViewById(AppCompatActivity.java:261)
at com.cobalt.MyApp.MainActivity.<init>(MainActivity.kt:76)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
at android.app.Instrumentation.newActivity(Instrumentation.java:1253)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3353)
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)
The app refused to open itself despite compiling successfully
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!
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 1 year ago.
at first when I started the app the error sad "unable to delete directory" so i delete that file. The virtual devices started but the app keep stopping and I can't find why.
Process: com.example.library, PID: 10926
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.library/com.example.library.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' 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 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.library.MainActivity.onCreate(MainActivity.java:20)
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)
this is the error when i start the app
A Button in the MainActivity line 20 is not be inited.
you should init the button by :
Button btn = (Button)findViewById(R.id.btn);
Before use btn.serOnClickListener...
I have initialized Firebase on Application onCreate() :
FirebaseApp.initializeApp(getApplicationContext());
then try to binding isolate process on Activity
bindService(intent, mIsolatedServiceConnection, BIND_AUTO_CREATE);
Firebase has crashed with below exception, Could someone help me to fix this bug?
2020-05-25 11:47:13.700 27703-27703/com.test.process_v:tmp:com.test.process.IsolatedService W/ContextImpl: Failed to ensure /data/user/0/com.test.process_v/shared_prefs: mkdir failed: EACCES (Permission denied)
2020-05-25 11:47:13.700 27703-27703/com.test.process_v:tmp:com.test.process.IsolatedService W/SystemServiceRegistry: No service published for: user
2020-05-25 11:47:13.701 27703-27703/com.test.process_v:tmp:com.test.process.IsolatedService D/AndroidRuntime: Shutting down VM
--------- beginning of crash
2020-05-25 11:47:13.702 27703-27703/com.test.process_v:tmp:com.test.process.IsolatedService E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.darvin.security_v:tmp:com.test.process.IsolatedService, PID: 27703
java.lang.RuntimeException: Unable to create application com.test.process.App: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.os.UserManager.isUserUnlockingOrUnlocked(int)' on a null object reference
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6465)
at java.lang.reflect.Method.invoke(Native Method)
at com.swift.sandhook.SandHook.callOriginMethod(SandHook.java:185)
at com.swift.sandhook.xposedcompat.hookstub.HookStubManager.hookBridge(HookStubManager.java:375)
at SandHookerNew_5sm3dthec8858ee0to4kj3c1ge.hook(Unknown Source:51)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
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 'boolean android.os.UserManager.isUserUnlockingOrUnlocked(int)' on a null object reference
at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:457)
at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:443)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:178)
at com.google.firebase.FirebaseApp.<init>(com.google.firebase:firebase-common##16.0.2:528)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common##16.0.2:355)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common##16.0.2:324)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common##16.0.2:310)
at com.test.process.App.onCreate(App.java:32)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
at java.lang.reflect.Method.invoke(Native Method)
at com.swift.sandhook.SandHook.callOriginMethod(SandHook.java:185)
at com.swift.sandhook.xposedcompat.hookstub.HookStubManager.hookBridge(HookStubManager.java:375)
at SandHookerNew_5sm3dthec8858ee0to4kj3c1ge.hook(Unknown Source:51)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
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)
If Firebase has initialized on Activity then no crashed happen.
Check in your application onCreate() if process that runs it is isolated. If not - run initialization of Firebase.
override fun onCreate() {
super.onCreate()
if (!android.os.Process.isIsolated()) {
//init firebase
}
}
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