Moussa Khalil
Moussa Khalil

Reputation: 635

Android: Just can't fix the 65k issue

I've been at this for two days now. I tried all solutions related to multi-dexing and so but to no avail. I removed everything so that I can do a fresh start.

App gradle:

apply plugin: 'com.android.application'
android {
          compileSdkVersion 21
          buildToolsVersion "21.1.2"
          defaultConfig {
          applicationId "com.bilboldev.joestrategy"
          minSdkVersion 15
          targetSdkVersion 21
          versionCode 1
          versionName "1.0"
          multiDexEnabled true
      }
buildTypes {
    release {
        minifyEnabled false

        proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
      }
   }
}

dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services-ads:9.0.0'
}

apply plugin: 'com.google.gms.google-services'

Project gradle:

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.1.0'
    classpath 'com.google.gms:google-services:3.0.0'

}
}



allprojects {
repositories {
    jcenter()
}
}

Inside manifiest:

 <meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
 <application
    android:name="android.support.multidex.MultiDexApplication" ...

The most common solution I read was don't include all google services, just the things you need. And thus i only compile the ads one. But it still doesn't work.

Some of the classes not being found:

E/dalvikvm﹕ Could not find class 'android.os.UserManager', referenced from method com.google.android.gms.common.zze.zzan

E/dalvikvm﹕ Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.internal.zzpv.zzg

E/dalvikvm﹕ Could not find class 'com.google.android.gms.internal.zzamq', referenced from method com.google.android.gms.internal.zzdi.zze

etc...

I tried all the approaches I found, one of which is this. I also used the dexcount plugin mentioned in the end to count the methods in my app. I don't know how to attach a file to a question so you can download the debug.txt from here.

Note: I believe that this is a 65k limit issue because on a 4.4 android mobile, the ads display and the errors do not show in logcat. but on two 4.2 android mobiles, the ads don't show and the errors how. HOWEVER, if you look at the debug.txt:

methods fields package/class name

15236 5010 android

14282 9575 com

Rest are less than 3k combined

I just don't see 65k... unless android and what's under it (android.something) stack

What am I missing here?

Upvotes: 7

Views: 309

Answers (3)

Moussa Khalil
Moussa Khalil

Reputation: 635

It would seem that the reason these classes were not showing was because they were not compatible with the google game services on some of my mobiles. At first I thought I was up to date because I could no longer update google play services. But I was wrong since the 'up to date' is based on the max version your mobile can handle (best explanation I can come up with)

Solution was to update the sdk APIs related to the versions in question (Android 4.1.2 Google APIs and so).

The reason the dexing solutions did not work is because this, while having symptoms similar to 65k method limit, it was related to outdated APIs.

If you encounter a situation that does require Dexing but still face missing classes, this is probably your problem :)

android W/GooglePlayServicesUtil Google Play services out of date. if you see that in your logcat even if your mobile gms is 'up to date', then you have this problem

Edit: Stackoverflow won't let me accept my own answer but this is it. I will update in two days unless a mod can set it to accepted

Upvotes: 0

Egor
Egor

Reputation: 40218

ads depends on other dependencies and won't function on its own. To start with, try including this one:

compile "com.google.android.gms:play-services-base:9.0.0"

Upvotes: 0

Vaiden
Vaiden

Reputation: 16132

Adding GMS you should have easily reached the 64K limit.

So let's look at the situation here:

  • You're below 64K methods when you probably should have been above.
  • You're missing classes.

Not having your full set of Gradle file, I would guess that the issue is related to Proguard cutting out stuff you want to keep. I suggest first turning off Proguard obfuscation entirely and testing whether this fixed the issue.

Upvotes: 1

Related Questions