I am working on a school project to create basic android apps. It runs very well before I added few classes (I copy-paste them from my previous classes, it has the same logic/structure but different XML)
When I tried to run my 'updated' app, logCat always show this error:
05-07 09:19:15.402: E/AndroidRuntime(1370): FATAL EXCEPTION: main
05-07 09:19:15.402: E/AndroidRuntime(1370): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.IllegalStateException: Unable to get package info for com.anatomi; is package not installed?
05-07 09:19:15.402: E/AndroidRuntime(1370): at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
and then, on the emulator, the "unfortunately, application has stopped" message appears.
However after I pressed OK, it's not even crashing and the app runs as normal.
Am I missing something? I'm pretty sure that the .java and .xml have the right structure, and the manifest too.
This happens sometimes when pushing a new version of your app to the device or emulator, when the old version is swapped with the new version. During that time, the package is not available, and this 'crash' occurs.
This is nothing to worry about, as this scenario will not occur in 'real life' (assuming Play Store updates are handled more gracefully, as I've never seen these crashes there).
Related
I've just built and deployed an app to Google Play. It worked well when I was running it through Android Studio but now it crashes when I download it from Google Play. Because this is my first time, I don't even know how to view the crash report/stacktrace of the app that was downloaded from Google Play. I appreciate any and all help.
UPDATE
So I got the stacktrace for the APK. It tells me that my TopImageFragment.java class cannot create my MemeViewModel.java class. I have no clue why its giving this error. Everything works fine as it is. It seems that proguard is indeed phasing out an important class:
2019-04-18 00:46:32.062 8099-8099/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ozbek.onur.memegenerator, PID: 8099
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ozbek.onur.memegenerator/com.ozbek.onur.memegenerator.MainActivity}: java.lang.RuntimeException: Cannot create an instance of class com.ozbek.onur.memegenerator.MemeViewModel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2853)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2928)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1609)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6703)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
Caused by: java.lang.RuntimeException: Cannot create an instance of class com.ozbek.onur.memegenerator.MemeViewModel
at android.arch.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:155)
at android.arch.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:210)
at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:134)
at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:102)
at com.ozbek.onur.memegenerator.TopImageFragment.onActivityCreated(TopImageFragment.java:89)
This kind of problem usually happens because your app deployed to Google Play was a release build and proguard minified your app and removed a class it shouldn't have. When you build in Android Studio it is a debug build that does not get minified. That's why you see the crash only from Google Play.
Before uploading to Google Play, test out your release APK file on a device and watch logcat for the error. That should tell you what class got removed by mistake and you can correct that by specifying custom proguard rules and trying again until the app stops crashing. Then when you upload to Google Play, you should be good.
You can also enable proguard in a debug build as well by changing your build.gradle file. Then when you run through Android Studio, you should see the same error as you see through Google Play.
One other alternative, you can disable proguard/minification in your release build. However this is not recommended because your app will be larger than it needs to be.
Check if you have any java files that don't have an access modifier. In my experience, just declaring a class without a public or private modifier, causes this problem.
My app suffered the same problem and it was a ProGuard kill.
Because ProGuard renames all classes unless otherwise instructed.
So, in your case, you have to add
#Keep
annotation before your class name MemeViewModel.
example,
#Keep
class MemeViewModel{
//
//
}
In my suggestion, keep your phone connected to your your PC/Laptop while you download and attempt to open it. Use Logcat on android studio, it mostly has all answers or at least errors that lead to the answers. try putting error logs here so we can have a proper look at it.
1) Try the same version of your application that you deployed on Google play store by pushing it through the android studio and see if the problem continues!
2) If same thing happens then put breakpoint on the entry point (onCreate method in most cases in MainActivity class) of your application and Go to Run->Debug "YourProject" option and do step by step debug for each command being executed and see which one is causing problem.
I imported a package of my own called server (the logic of my program) and was going to use libgdx for the graphics/cross platform. The desktop launcher works fine but when I run the android launcher I get this nasty error referring to my own library.
E/AndroidRuntime: FATAL EXCEPTION: GLThread 187
Process: com.mygdx.game, PID: 8093
java.lang.NoClassDefFoundError: server.Point
at server.Shape.<init>(Shape.java:9)
at server.T.<init>(T.java:7)
at server.Stack.<init>(Stack.java:28)
at server.Logic.<init>(Logic.java:14)
at com.mygdx.game.GameLoop.create(GameLoop.java:43)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:275)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1511)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
any help would be great
I solved it!
It was because I was using java.awt.point in the android build. So I basically wrote a new point class, replace it, and then cleaned my project. Everything works now
I want to make some Android applications running in the same process, so I give those apps's AndroidManifest the same sharedUserId:
< manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
android:sharedUserId="aaa.bbb" >
and assign each apps's application the same process:
< application
...
android:process="com.mytest" >
It works in android 4.4.4 , all the Applications run in the same Process.
But crash happened in android 6.0.1.
When I run the second app, it crashes due to:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class "com.example.myapplication.MainActivity" on path:
DexPathList[[zip file "/data/app/com.example.myapplication-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-1/lib/arm, /vendor/lib, /system/lib]]
after the system kill the Process, the second app can run and crashes if I run the first application.
It seem that applications can not run in the same process in the same time and I do not know why.
Each APK has its own ClassLoader. An article talking about this.
So it's normal you can't access a class of another APK.
It seems that a security bug was fix between Kitkat and Marshmallow.
Why you need this system ?
If it's to share data between application, you could use ContentProvider
If it's to launch Activity or Service, you could use Intent with action.
I fixed it !
disable the options in Android studio ant it works !
all I am doing:
Eclipse --> new Project --> Android Application --> Activity type: blank
no changes in the code, just the simple Hello world.
It does start, I see the Hello World on the virtual device, but then immediately shuts down.
The logcat is as follows:
08-31 06:01:14.976: W/dalvikvm(1114): threadid=1: thread exiting with uncaught exception(group=0xb2aeeba8)
08-31 06:01:14.996: E/AndroidRuntime(1114): FATAL EXCEPTION: main
08-31 06:01:14.996: E/AndroidRuntime(1114): Process: com.example.tester, PID: 1114
08-31 06:01:14.996: E/AndroidRuntime(1114): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
08-31 06:01:14.996: E/AndroidRuntime(1114): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
Any Ideas?
Edit:
Ok, apparently I for some reason have a dependency mixup:
Found 2 versions of android-support-v4.jar in the dependency list,
[2014-08-31 12:22:46 - tester] but not all the versions are identical (check is based on SHA-1 only at this
Can I simply delete one of them?
The error is essentially telling you that it can't find the Android Support Library, which it is using as a dependency.
Without knowing what build process you're using (e.g gradle) it's difficult to tell you how to fix it, but basically you'll need to either add it as a dependency, or remove the code that requires it.
For more information on the Android Support Library, try this:
https://developer.android.com/tools/support-library/index.html
If do not work the try this :
Step #1: Undo all that. If you are messing with the build path, on R16 or higher version of the ADT plugin for Eclipse, you're doing it wrong.
Step #2: Pick one of those two versions of the JAR, or pick the one from the "extras" area of your SDK installation.
Step #3: Put the right JAR in App Library.
Step #4: Delete the one from App Free, since it will pick up that JAR from App Library.
I am trying to run the Animation3DTest , one of libgdx's test examples
On the desktop (lwjgl) I can run this test flawlessly, I can see a guy and a sword and I can move him around without any errors.
However, on Android, after starting this test, I got a force stop, and here is what showed on the Logcat
09-24 10:46:49.526 24530-24577/com.badlogic.gdx.tests.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 1445
com.badlogic.gdx.utils.GdxRuntimeException: File not found: com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl (Classpath)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:133)
at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:563)
at com.badlogic.gdx.backends.android.AndroidFileHandle.length(AndroidFileHandle.java:162)
at com.badlogic.gdx.files.FileHandle.readString(FileHandle.java:192)
at com.badlogic.gdx.files.FileHandle.readString(FileHandle.java:186)
at com.badlogic.gdx.graphics.g3d.shaders.DefaultShader.getDefaultVertexShader(DefaultShader.java:249)
at com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider.<init>(DefaultShaderProvider.java:44)
at com.badlogic.gdx.graphics.g3d.ModelBatch.<init>(ModelBatch.java:101)
at com.badlogic.gdx.tests.g3d.BaseG3dTest.create(BaseG3dTest.java:38)
at com.badlogic.gdx.tests.g3d.BaseG3dHudTest.create(BaseG3dHudTest.java:50)
at com.badlogic.gdx.tests.g3d.Animation3DTest.create(Animation3DTest.java:45)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:322)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1514)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1242)
Get the latest nightly build. Here's the bug report.