Android Initial error in Emulator on Application Start - android

I am faced with this weird error. Whenever I start my application on my emulator, I get a message in the Emulator saying that Unfortunately,Search has stopped.
My LogCat also shows some error but after a few seconds, the application runs properly without any hassles.
But, every time I upload and install the application on the emulator I get this error.
I realise that it does not cause any trouble to the application as after the initial error, everything runs fine but still I would very much like to know the cause of such an error.
Here is what my LogCat displays.
07-08 13:47:38.262: E/AndroidRuntime(1931): FATAL EXCEPTION: main
07-08 13:47:38.262: E/AndroidRuntime(1931): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.os.Looper.loop(Looper.java:137)
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-08 13:47:38.262: E/AndroidRuntime(1931): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 13:47:38.262: E/AndroidRuntime(1931): at java.lang.reflect.Method.invoke(Method.java:511)
07-08 13:47:38.262: E/AndroidRuntime(1931): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-08 13:47:38.262: E/AndroidRuntime(1931): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-08 13:47:38.262: E/AndroidRuntime(1931): at dalvik.system.NativeStart.main(Native Method)
07-08 13:47:38.262: E/AndroidRuntime(1931): Caused by: java.lang.NullPointerException
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
07-08 13:47:38.262: E/AndroidRuntime(1931): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
07-08 13:47:38.262: E/AndroidRuntime(1931): ... 11 more
Any idea what might be the cause ?

Make sure you correctly declared the android:name attribute of your application tag in the AndroidManifest.xml file.
See this answer here for an explanation on the Unable to instantiate application android.app.Application logcat error.

Make an entry in androidManifest.xml with the application name
<application
android:name=<name of the class that extends Application>
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >

Related

Control how android kills my app

I have an android application with a lot of activities and services. If I open another application while my application is running and android needs resources kills my application and I receive NullPointerException error messages like this:
07-08 18:14:48.567: E/AndroidRuntime(16300): FATAL EXCEPTION: main
07-08 18:14:48.567: E/AndroidRuntime(16300): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{icg.android.start/icg.android.web.CustomWebActivity}: java.lang.NullPointerException
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.os.Looper.loop(Looper.java:137)
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-08 18:14:48.567: E/AndroidRuntime(16300): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 18:14:48.567: E/AndroidRuntime(16300): at java.lang.reflect.Method.invoke(Method.java:511)
07-08 18:14:48.567: E/AndroidRuntime(16300): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-08 18:14:48.567: E/AndroidRuntime(16300): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-08 18:14:48.567: E/AndroidRuntime(16300): at dalvik.system.NativeStart.main(Native Method)
07-08 18:14:48.567: E/AndroidRuntime(16300): Caused by: java.lang.NullPointerException
07-08 18:14:48.567: E/AndroidRuntime(16300): at icg.guice.Dependencies.injectDependencies(Dependencies.java:238)
07-08 18:14:48.567: E/AndroidRuntime(16300): at icg.guice.GuiceActivity.<init>(GuiceActivity.java:9)
07-08 18:14:48.567: E/AndroidRuntime(16300): at icg.android.web.CustomWebActivity.<init>(CustomWebActivity.java:16)
07-08 18:14:48.567: E/AndroidRuntime(16300): at java.lang.Class.newInstanceImpl(Native Method)
07-08 18:14:48.567: E/AndroidRuntime(16300): at java.lang.Class.newInstance(Class.java:1319)
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
07-08 18:14:48.567: E/AndroidRuntime(16300): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
I tried to detect if android kills my activities but searching I found that there is no way to do that.
At least, is possible avoid to show the error message on the device screen? I prefer that the application crashes silently.
Thanks
There is no way to stop Android from killing your services/process if it is in need of more resources. In that case you need to use the onPause() and onDestroy() methods to shut down any services that you may not need and to release as many resources back to Android as possible.
Then you have to utilize onResume() to ensure that the proper activities/services are present when the application is in focus. This might help eliminate the NullPointerException and crashing.

Android L: LinkageError crashes application

As part of testing an existing Android app against the L preview, the app is crashing with the following exception:
07-08 10:05:39.024: E/AndroidRuntime(2126): FATAL EXCEPTION: main
07-08 10:05:39.024: E/AndroidRuntime(2126): Process: com.example, PID: 2126
07-08 10:05:39.024: E/AndroidRuntime(2126): java.lang.LinkageError: com.example.BaseActivity
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.defineClassNative(Native Method)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.defineClass(DexFile.java:222)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
The app works fine in API levels 14-19, but crashes on start up with this cryptic error on the L preview. The compile/targetSdk version is still set to API 19.
The problem was a conflicting method in BaseActivity. I had created a helper method called getDrawable(int drawableId) that had the same signature as a method added to the Activity class in Android L.
This conflict caused the LinkageError. To fix the issue, I simply renamed my helper method so it wouldn't conflict with the new built-in method.
07-08 10:05:39.024: E/AndroidRuntime(2126): FATAL EXCEPTION: main
07-08 10:05:39.024: E/AndroidRuntime(2126): Process: com.example, PID: 2126
07-08 10:05:39.024: E/AndroidRuntime(2126): java.lang.LinkageError: com.example.BaseActivity
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.defineClassNative(Native Method)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.defineClass(DexFile.java:222)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)

Vuforia with JPCT-AE error

I had download project from https://github.com/fishkingsin/QCAR-JPCT-AE
Set all environment variable and build method that describe to build vuforia android project.
Read all blogs from vuforia sites:
https://developer.vuforia.com/resources/dev-guide/step-2-installing-vuforia-sdk
Following error display in Log cat:
Logcat Error:
07-08 15:00:05.415: E/AndroidRuntime(3943): FATAL EXCEPTION: main
07-08 15:00:05.415: E/AndroidRuntime(3943): java.lang.UnsatisfiedLinkError: Native method not found: com.guruonline.vuforia.jpct.ImageTargets.getOpenGlEsVersionNative:()I
07-08 15:00:05.415: E/AndroidRuntime(3943): at com.guruonline.vuforia.jpct.ImageTargets.getOpenGlEsVersionNative(Native Method)
07-08 15:00:05.415: E/AndroidRuntime(3943): at com.guruonline.vuforia.jpct.ImageTargets.getInitializationFlags(ImageTargets.java:384)
07-08 15:00:05.415: E/AndroidRuntime(3943): at com.guruonline.vuforia.jpct.ImageTargets.onCreate(ImageTargets.java:355)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.app.Activity.performCreate(Activity.java:5133)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.os.Looper.loop(Looper.java:137)
07-08 15:00:05.415: E/AndroidRuntime(3943): at android.app.ActivityThread.main(ActivityThread.java:5103)
07-08 15:00:05.415: E/AndroidRuntime(3943): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 15:00:05.415: E/AndroidRuntime(3943): at java.lang.reflect.Method.invoke(Method.java:525)
07-08 15:00:05.415: E/AndroidRuntime(3943): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
07-08 15:00:05.415: E/AndroidRuntime(3943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-08 15:00:05.415: E/AndroidRuntime(3943): at dalvik.system.NativeStart.main(Native Method)
Command window error:
[armeabi] Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
[armeabi] Gdbsetup : libs/armeabi/gdb.setup
[armeabi-v7a] Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
[armeabi-v7a] Gdbsetup : libs/armeabi-v7a/gdb.setup
[armeabi] Compile++ arm : ImageTargets <= ImageTargets.cpp
jni/ImageTargets.cpp:33:34: fatal error: QCAR/TrackableResult.h: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi/objs-debug/ImageTargets/ImageTargets.o] Error 1
Please help me.....
Download latest vuforia.jar and build project.

NoClassDefFoundError in Cocos2D sample

I am getting the same problem this question, but the solution didn't work for me. I've included my JAR in build path. What wrong am I doing?
I am using the same example.
Here's the crash log:
07-08 04:04:33.440: E/AndroidRuntime(751): FATAL EXCEPTION: main
07-08 04:04:33.440: E/AndroidRuntime(751): java.lang.NoClassDefFoundError: org.cocos2d.opengl.CCGLSurfaceView
07-08 04:04:33.440: E/AndroidRuntime(751): at a.b.Cocos2DGameActivity.onCreate(Cocos2DGameActivity.java:22)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.Activity.performCreate(Activity.java:4465)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.os.Looper.loop(Looper.java:137)
07-08 04:04:33.440: E/AndroidRuntime(751): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-08 04:04:33.440: E/AndroidRuntime(751): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 04:04:33.440: E/AndroidRuntime(751): at java.lang.reflect.Method.invoke(Method.java:511)
07-08 04:04:33.440: E/AndroidRuntime(751): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-08 04:04:33.440: E/AndroidRuntime(751): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-08 04:04:33.440: E/AndroidRuntime(751): at dalvik.system.NativeStart.main(Native Method)
I recomend you to change libraries to cocos2d-x, because cocos2d for android won't be updated anymore.
Cocos2d-x works in C++, and uses JNI (Java native interface) to work. Here is all the info you will need to start using it.
I guess the problem was in the JAR file. Fortunately the project is open source, so I added the source file and it stopped giving me error. There's a source code available on that tutorial which also uses the source files, instead of the JAR.
I get the same problem. And I copy the source code to src instead of including the jar.
And you must change the project's jre version to 1.6

Android google map error

In my project eclispe does not debug any error ! but when run it's force to stop
this is my logcat any idea !!!
07-08 11:20:41.494: WARN/dalvikvm(735): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): FATAL EXCEPTION: main
07-08 11:20:41.534: ERROR/AndroidRuntime(735): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.remwebdevelopment.maptest/com.remwebdevelopment.maptest.MapTest}: java.lang.ClassNotFoundException: com.remwebdevelopment.maptest.MapTest in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.remwebdevelopment.maptest-2.apk]
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1544)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.os.Looper.loop(Looper.java:123)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.app.ActivityThread.main(ActivityThread.java:3647)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at java.lang.reflect.Method.invoke(Method.java:507)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at dalvik.system.NativeStart.main(Native Method)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): Caused by: java.lang.ClassNotFoundException: com.remwebdevelopment.maptest.MapTest in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.remwebdevelopment.maptest-2.apk]
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1536)
07-08 11:20:41.534: ERROR/AndroidRuntime(735): ... 11 more
You have either changed your AndroidManifest.xml to update the application package name without changing the <activity> definition for com.remwebdevelopment.maptest.MapTest or you did not define an <activity> entry for com.remwebdevelopment.maptest.MapTest in your AndroidManifest.xml file.
I had the same problem. My solution (similar to other people's answers) was to use the Manifest editor in eclipse. I just removed the "uses library" entry in the application tab and added it again. It put the node at the bottom of the tree (just before the application tag is closed) and it works now. It used to exist half way up the tree of nodes.
UPDATE
I also found later that I needed to update my project according to this post by running the command android update project -p .
Had this sort of problem today after upgrading to latest ADT/SDK. Also for me the exception was
Unable to instantiate activity
Took me quite a while. Checked that i used google-apis (for maps), uses-library, cleaned the project etc.
Deleting the .project and adding a fresh one (create new android project) finally solved it.

Categories

Resources