Getting Error: Could Not Find Class 'Android.App.Appopsmanager', Referenced from Method Com.Google.Android.Gms.Common.Googleplayservicesutil.Zza

Getting error: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza

After spending couple of days to solve this strange problem, Finally found the cause of the crash. Although the error persists, program runs without any problem now.

The reason why the program runs fine with API level 22 and not not with below 21 is the method limit in android which is 65K. Above 21 natively supports loading multiple dex files from application APK files where below 21 does not. Documents states it here

The solution for this problem is solved at this stackoverflow post

or

if you use google play services, instead of compiling the whole APIs, selectively compile may help. You can find more details here.

Could not find class referenced from Google Play Services Util

Refering to Koh

"UserManager requires API level 17 while AppOpsManager requires API level 19. [...] Otherwise, this could be a multidex issue such as here."

Android studio many error: Could not find class 'android.XXX'

While reading through many similar problems, I found out it might be fixed by enabling Multidex, credits to this answer from Bharath Kumar. He also posted some useful links I reccomend to read. At least it worked for me (to be precise: I'm left with only 1 of those errors now, while it were hundreds before)!

In short: enabling multidex can be done by simply adding multiDexEnabled true in your gradle defaultConfig and adding this dependency compile 'com.android.support:multidex:1.0.1'.
Finally, install Multidex by adding this piece of code to your Application class:

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

Of course another option is to prevent the 64K method limit, so you don't need MultiDex anymore. You can do this by decreasing the number of (unused) dependencies in your Gradle file, or use more specific dependencies (a nice example for google play-services is provided by wittyurchin in this answer).

However, if you DO need Multidex, then you might encounter some problems, like the ones I found:

1) Instant run is disabled while building to target API devices (you'll see the error message popping up when running your app from Android Studio).

2) If you're using Robolectric for unittesting, you'll probably won't be able to run the tests anymore. You can fix this problem by extending the MultiDex.install(this); code from earlier. Instead of explaining everything myself, it'll be easier to check the issue, and answer of sschuberth over here.

...

ps. it seems I don't necessarily need compile 'com.android.support:multidex:1.0.1' to have MultiDex working, however, I've seen many reccomendations that say it IS required. If anyone got more advice on this, be my guest!

Google Maps error in Android Studio

Without the full stack trace I can't be sure, but I suppose you are trying to use big notification on a device that does not support them. Which API level are you using?
Minsdk
TargetSDk
and deviceSDk

I think you are developing for targetsdk >= 16 and your device is older (maybe a gingerbread?



Related Topics



Leave a reply



Submit