I am creating an app tht uses Google Maps API v2. It works fine, except for a little annoying this, when I use the setMyLocationEnabled(true); method, I get a ClassNotFoundException. I can just click "Resume" and the app continues. When running without debugger, there is nothing you can see happening.
This is what LogCat is saying:
09-23 22:39:31.645: I/dalvikvm(2067): Failed resolving Lcom/google/android/gms/location/internal/ParcelableGeofence; interface 4023 'Lglm;'
09-23 22:39:31.645: W/dalvikvm(2067): Link of class 'Lcom/google/android/gms/location/internal/ParcelableGeofence;' failed
09-23 22:39:32.473: W/dalvikvm(2067): VFY: unable to resolve static field 4203 (CREATOR) in Lcom/google/android/gms/location/internal/ParcelableGeofence;
It looks like a missing class in the library, and if I jump into the library project, I indeed do not see that class.
Is there anything I can add / fix to make this exception go away?
I have seen that logcat error before and I noticed it is due to mismatch in my API key between debug and release mode. If you are using separate key store for debug, please make sure you have included both debug and release SHA1+package.name combos in the Google Dev Console.
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 have used pretty much the boilerplate from firebase and google sign on documentation. I get the dialog for choosing the account to log in from, and then it fails. I have updated my google play services. And also regenerated my sha1 keys. One thing that I have noticed is that android studio keeps giving me back the old key when executing the signingreport task, tho I have generated keys twice after that, and also updated on the firebase console.
Gist of the main activity on github
E/dalvikvm: Could not find class 'android.support.v4.app.ActivityCompat$SharedElementCallback23Impl', referenced from method android.support.v4.app.ActivityCompat.setEnterSharedElementCallback
E/dalvikvm: Could not find class 'android.support.v4.app.ActivityCompat$SharedElementCallback21Impl', referenced from method android.support.v4.app.ActivityCompat.setEnterSharedElementCallback
E/dalvikvm: Could not find class 'android.support.v4.app.ActivityCompat$SharedElementCallback23Impl', referenced from method android.support.v4.app.ActivityCompat.setExitSharedElementCallback
E/dalvikvm: Could not find class 'android.support.v4.app.ActivityCompat$SharedElementCallback21Impl', referenced from method android.support.v4.app.ActivityCompat.setExitSharedElementCallback
So, because android studio was showing me the wrong, originally generated key when running the signingreport task from gradle, I tried generating new keys but that wasn't working.
And then I found this which explained how to find the debug keystore in android studio and set it up. My android studio was taking its keys from the .android directory in my home directory while I was generating keys in a different directory. After configuring the keys through this, I also got an error saying the key strength was very less, but that was easy to solve(just add the -keyalg RSA argument while generating keys.
And then when I launched the app it said that due to CA certificates being no longer valid I should uninstall and install again. And voila, it worked.
I have uploaded the Android app into playstore. While downloading it for the first time it gets crashed but after that it works fine. Its showing the error as Unable to instantiate receiver com.google.android.apps.analytics.AnalyticsReceiver Caused by java.lang.ClassNotFoundException: Didn't find class "com.google.android.apps.analytics.AnalyticsReceiver" .
How to resolve this issue?
I believe that issue related to your manifest file and refer to INSTALL_REFERRER.
Make sure if AnalyticsReceiver class included to your app
My suggestion, if you not use that receiver you can remove it, otherwise will keep throw crash error
Note:
As far as I know com.google.android.apps.analytics.AnalyticsReceiver from Google Analytics SDK v3
While if you using Google Analytics SDK v4 you should use com.google.android.gms.analytics.CampaignTrackingReceiver
Please read this post too
I am trying to create an android application that is location aware using google play services as it seems that is the new recommended fashion for doing this. I have used the tutorial I found on the android developers site to setup my project. It seems correct and builds fine, however, when the activity just BEFORE the activity that has the google play services dependencies starts I see the following in log cat.
06-18 01:31:04.126: I/dalvikvm(30480): Failed resolving Lcom/example/activities/NewActivity; interface 1045 'Lcom/google/android/gms/common/GooglePlayServicesClient$ConnectionCallbacks;'
06-18 01:31:04.126: W/dalvikvm(30480): Link of class 'Lcom/example/activities/NewActivity;' failed
06-18 01:31:04.126: W/dalvikvm(30480): Unable to resolve superclass of Lcom/example/activities/NewActivity_; (930)
06-18 01:31:04.126: W/dalvikvm(30480): Link of class 'Lcom/example/activities/NewActivity_;' failed
06-18 01:31:04.126: E/dalvikvm(30480): Could not find class 'com.example.activities.NewActivity_', referenced from method com.example.activities.HomeActivity.clickCurrentDonation
06-18 01:31:04.126: W/dalvikvm(30480): VFY: unable to resolve const-class 936 (Lcom/example/activities/NewActivity_;) in Lcom/example/activities/HomeActivity;
Here NewActivity is the activity using google play services that is unable to load and HomeActivity is the activity that calls NewActivity. These errors appear on load of the HomeActivity even before I try to start NewActivity.
I have confirmed that this works normally if I do not include the google play services code.
The only thing I am doing that seems to be different than the norm or than the tutorial is that I am using the android-annotations project which is why you'll see references above to the NewActivity_ which is a generated class this uses based on the code I write in the base class.
Has anyone else encountered this or have any idea how to resolve?
Thanks for any help!
Just re install the Google Play services from SDK Manager and try to link again and clean- build the project.
If still It does not work, download another SDK folder and install Google Play Services and import the Google Play Services project in your workspace and link to your current project.
I don't knw..Its quite strange But It worked for me.
I'm using the Java Google APIs for an Android application. I followed the usage pattern described here for Authenication and API use: http://goo.gl/rPZ9Z
The problem I'm having is that the call to GoogleTransport.create() throws a NoClassDefFoundException. I looked at the log and the HttpHeaders class is not linking properly. I attached the Google API JAR file using the normal method in eclipse and all other classes I'm using are working correctly. Problem is that this one class in particular is not linked correctly. Here are some logs of the app running but not calling the class:
01-27 14:04:34.390: WARN/dalvikvm(422): Link of class 'Lcom/google/api/client/http/HttpHeaders;' failed
01-27 14:04:34.400: WARN/dalvikvm(422): Unable to resolve superclass of Lcom/google/api/client/googleapis/GoogleHeaders; (43)
Log of direct call to GoogleTransport.create():
01-27 16:13:11.882: ERROR/AndroidRuntime(16086): java.lang.NoClassDefFoundError: com.google.api.client.http.HttpHeaders
01-27 16:13:11.882: ERROR/AndroidRuntime(16086): at com.google.api.client.http.HttpTransport.(HttpTransport.java:145)
01-27 16:13:11.882: ERROR/AndroidRuntime(16086): at com.google.api.client.googleapis.GoogleTransport.create(GoogleTransport.java:58)
Thanks in advance!
Sounds like your project references are messed up. Try checking the library dependencies.