I'm getting overly frustrated with this issue. First of all, this did work fine with no issues, I have no idea why I'm now getting this error.
The application runs fine on my phone (v2.3.4) but not on one emulator (1.6 > 2.3)
The error I'm getting is 'NullPointerException' immediately after I load the application. Heres the DDMS
08-24 21:10:11.706: WARN/dalvikvm(423): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): FATAL EXCEPTION: main
08-24 21:10:11.726: ERROR/AndroidRuntime(423): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.app/com.myapp.app.SplashActivity}: java.lang.NullPointerException
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.os.Handler.dispatchMessage(Handler.java:99)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.os.Looper.loop(Looper.java:123)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.app.ActivityThread.main(ActivityThread.java:3647)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at java.lang.reflect.Method.invokeNative(Native Method)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at java.lang.reflect.Method.invoke(Method.java:507)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at dalvik.system.NativeStart.main(Native Method)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): Caused by: java.lang.NullPointerException
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at com.myapp.app.SplashActivity.onCreate(SplashActivity.java:43)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
08-24 21:10:11.726: ERROR/AndroidRuntime(423): ... 11 more
OK, so I look up what caused the problem (08-24 21:10:11.726: ERROR/AndroidRuntime(423): at com.myapp.app.SplashActivity.onCreate(SplashActivity.java:43))
Here is my onCreate:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
Button playBtn = (Button) findViewById(R.id.playBtn);
playBtn.setOnClickListener(this);
Button settingsBtn = (Button) findViewById(R.id.settingsBtn);
settingsBtn.setOnClickListener(this);
Button rulesBtn = (Button) findViewById(R.id.rulesBtn);
rulesBtn.setOnClickListener(this);
Button exitBtn = (Button) findViewById(R.id.exitBtn);
exitBtn.setOnClickListener(this);
}
Line 43 is the last one: exitBtn.setOnClickListener(this);
This is handled later on in the app using a switch statement for each button, the only code for the exit button is 'finish();' but it crashes 'onCreate' not onClick.
This is making no sense to me, this used to work fine and I haven't changed the code relating to this since it previously worked. Also, the exit button is set up exactly the same as all the other buttons (in src and layout files), so why would it crash when it gets to the exit button? As I said, this works OK on my cyn7 device but not on any of the emulators (it did)
This app has taken a massive amount of work to get it to this point, I was just doing final tests when this began.. so infuriating!
Can anyone please offer any suggestions to fix or even as to why this may happen?
EDIT: OK, this is really strange. I commented out the Exit button. Now my 'Play' button does nothing (even in DDMS it shows up nothing) the settings up OK and the Rules crashes, with the same error for the Rules activity on a setOnClickListener(this). Which makes no sense as the settings activity also has a 'setOnClickListener'. What is going on?!
Sounds like a corrupt worksapce. Android in Eclipse sometimes gets the autogenerated resource files out of sysnc with the actual layout. As Xion mentioned, a clean and rebuild will fix this via Project -> Clean... -> Clean all projects. Before doing this, ensure that Project -> Build Automatically is ticked.
Related
I don't know why the app crashes whenever it's supposed to go to the next Activity. I made a practice app that works as it should when using the same format. I uploaded the files to gist.github.
The error is
1216-1216/com.example.chiozokamalu.newfreshstart E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ArrayIndexOutOfBoundsException
at com.example.chiozokamalu.newfreshstart.MainActivity.onClick(MainActivity.java:164)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
On line 164 of MainActivity.java:
questionView.setText(questions[questionIndex]); // set the text to the next question
EDIT: After Varun helped me, I get a new error which is
1307-1307/com.example.chiozokamalu.newfreshstart E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.chiozokamalu.newfreshstart/com.example.chiozokamalu.newfreshstart.Results1}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.chiozokamalu.newfreshstart.Results1.onCreate(Results1.java:58)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
The questions array at line no. 164 is going out of bound that means questionIndex is greater than the total length of the questions array. So you should add a check on the length before extracting value from the array.
You have added the check but after that you incremented the value so either you modify the if condition to if (questionIndex < questions.length -1)
or modify the questionIndex variable before the if condition
You are getting problem because you haven't initiated resultView9 that is why it is null and giving nullpointer, just initiatlise it as you done with other and everything is fine. You have initialised the resultView8 twice just add resultview9 over there
Alright, I've been going thru posts left and right trying to figure out this error.. I've managed to fix a few errors, but this is just driving me nuts.. it has almost no information.. or atleast none that makes any sense to me.
D/dalvikvm(431): Trying to load lib /data/data/com.hyperlinkup.manglerbt/lib/libventrilo_interface.so 0x405156c8
D/dalvikvm(431): Added shared lib /data/data/com.hyperlinkup.manglerbt/lib/libventrilo_interface.so 0x405156c8
D/dalvikvm(431): No JNI_OnLoad found in /data/data/com.hyperlinkup.manglerbt/lib/libventrilo_interface.so 0x405156c8, skipping init
D/dalvikvm(431): GC_EXTERNAL_ALLOC freed 61K, 53% free 2565K/5379K, external 1027K/1038K, paused 89ms
W/dalvikvm(431): No implementation found for native Lcom/hyperlinkup/manglerbt/VentriloInterface;.debuglevel (I)I
D/AndroidRuntime(431): Shutting down VM
W/dalvikvm(431): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(431): FATAL EXCEPTION: main
E/AndroidRuntime(431): java.lang.UnsatisfiedLinkError: debuglevel
E/AndroidRuntime(431): at com.hyperlinkup.manglerbt.VentriloInterface.debuglevel(Native Method)
E/AndroidRuntime(431): at com.hyperlinkup.manglerbt.ServerList.onCreate(ServerList.java:96)
E/AndroidRuntime(431): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(431): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
E/AndroidRuntime(431): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime(431): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime(431): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime(431): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(431): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(431): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime(431): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(431): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(431): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(431): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(431): at dalvik.system.NativeStart.main(Native Method)
I/Process(431): Sending signal. PID: 431 SIG: 9
I'm trying to rework the Mangler app to use Bluetooth recording (via startBluetoothSco), but I want to make sure the original is working before incorporating the bluetooth functionality.. Any help I can get on this matter would be greatly appreciated.
edit: thinking maybe my issue is with jni_wrappers.c.. first 3 #include's are unresolved.. original build was on linux system it would appear, so it's looking for jni.h, stdint.h and ventrilo3.h
Answer is in the Logcat Stacktrace itself
No implementation found for native Lcom/hyperlinkup/manglerbt/VentriloInterface;.debuglevel (I)I D/AndroidRuntime(431): Shutting down VM
There is a Native method called debuglevel in VentriloInterface. You have not implemented that method. So, the VM throws java.lang.UnsatisfiedLinkError.
I am getting this error in my one activity and it is making no sense because I can go to the Calendar activity from another activity so I know i declared it correctly in the manifest
<activity android:name=".Calendar" android:label="Calendar"/>
Intent is in a Dialog selection
Intent ok = new Intent(Events.this,Calendar.class);
ok.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(ok); //ActivityNotFoundException
finish();
I can from activity A to the Calendar activity just fine then the Calendar activity has access to my Events activity but I cant go from my Events to the Calendar activity??
Ideas as to why this is?
EDIT: Update with error
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): FATAL EXCEPTION: main
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.app.notifyme/java.util.Calendar}; have you declared this activity in your AndroidManifest.xml?
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Activity.startActivityForResult(Activity.java:2827)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.Activity.startActivity(Activity.java:2933)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.app.notifyme.Events$12.onClick(Events.java:318)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:873)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.ListView.performItemClick(ListView.java:3513)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1849)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Handler.handleCallback(Handler.java:587)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Handler.dispatchMessage(Handler.java:92)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.os.Looper.loop(Looper.java:123)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at android.app.ActivityThread.main(ActivityThread.java:3839)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at java.lang.reflect.Method.invokeNative(Native Method)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at java.lang.reflect.Method.invoke(Method.java:507)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-24 12:53:46.951: ERROR/AndroidRuntime(3045): at dalvik.system.NativeStart.main(Native Method)
Import the correct package. I guess you are importing something like java.util.Calendar in your Events class.
If, for some reason, you need both Calendar classes (the one you wrote and the java.util one), you must put the complete path... for instance:
Intent ok = new Intent(Events.this, your.pkg.example.Calendar.class);
When you call finish() the system actually removes the activity from the stack.
This disallows you from going back to that activity.
I suggest you carefully read the Activity Lifecycle Documentation.
It should help you figure out your problem. :)
EDIT:
You should also not need that flag. Just start the activity, the system will take care of the rest.
You also do not have access to one activity from another activity. Each activity is a standalone unit that should not attempt to access other activities.
If you need to pass data between activities, use a static class/variable in a seperate class, or pass it using Intent.putExtra().
I'm getting that exception when I pick a wallpaper. I'm actually not sure what function is the culprit. Here's the error log:
I/ActivityManager( 1360): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
W/dalvikvm(29175): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
E/AndroidRuntime(29175): FATAL EXCEPTION: main
E/AndroidRuntime(29175): java.lang.IllegalStateException: AssetManager has been finalized!
E/AndroidRuntime(29175): at android.content.res.AssetManager.isUpToDate(Native Method)
E/AndroidRuntime(29175): at android.app.ActivityThread.getPackageInfo(ActivityThread.java:2350)
E/AndroidRuntime(29175): at android.app.ActivityThread.getPackageInfoNoCheck(ActivityThread.java:2337)
E/AndroidRuntime(29175): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2935)
E/AndroidRuntime(29175): at android.app.ActivityThread.access$3300(ActivityThread.java:125)
E/AndroidRuntime(29175): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2087)
E/AndroidRuntime(29175): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29175): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(29175): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(29175): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(29175): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(29175): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
E/AndroidRuntime(29175): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
E/AndroidRuntime(29175): at dalvik.system.NativeStart.main(Native Method)
I/ActivityManager( 1360): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 331 ms (total 331 ms)
W/InputManagerService( 1360): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#44bf5a08
I/ActivityManager( 1360): Process com.bukabros.videolivewallpaper (pid 29175) has died.
W/ActivityManager( 1360): Scheduling restart of crashed service com.bukabros.videolivewallpaper/.VideoLiveWallpaper in 5000ms
I/ActivityManager( 1360): Start proc com.bukabros.videolivewallpaper for service com.bukabros.videolivewallpaper/.VideoLiveWallpaper: pid=29207 uid=10090 gids={}
The only thing I can think of is that onCreate doesn't get called in the right order when the wallpaper gets picked cuz that's where I instantiate the asset manager.
And yes, I'm using the NDK but the asset manager doesn't get used there.
Ah nevermind. The culprit was that the handle to the assetmanager was a static variable. (That was just a quick hack for something else). Making that a normal variable solved the problem.
I have problem running my app on Android 2.3 (Gingerbread). The app has a splash screen and timer, and then it runs
the main class. It works fine on Android 2.2 (Froyo), Android 2.1 (Eclair), etc. It just crashes on Android 2.3.
Do I need to create another thread than the main activity thread?
Here is the error below:
java.lang.RuntimeException: Unable to start activity
java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
I found it. It turned out my background image was too big. That’s why my app crashed on create, because it took longer time to load which triggered the UI thread runtimeerror.