7

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?

Community
  • 1
  • 1
Moussa Khalil
  • 635
  • 5
  • 12
  • I'm not sure I understand how "Could not find class" means you are hitting the 65k limit. And you have minifyEnabled as false, so it shouldn't obfuscate those classes – OneCricketeer Jun 02 '16 at 13:21
  • Thank you for the comment. The reason I assume the issue is 65k limit, is because that is what I kept reaching while googling. It is also face a lot after people add gms. This link is an example of what led me to this conclusion. Things in common: D/dalvikvm, VFY: replacing opcode 0x71 at 0x0000 etc.. http://stackoverflow.com/questions/35794629/could-not-find-method-android-app-notificationbuilder-setlocalonly/35830652 – Moussa Khalil Jun 02 '16 at 13:24
  • 1
    Sure. You can read the second blue box on this page, as well, but you've properly handled that by only including ads. https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project – OneCricketeer Jun 02 '16 at 13:27
  • This is not a forum. Please don't edit your question to contain the answer. To mark a question as solved, simply accept an answer by clicking the grey checkmark under the voting arrows. – Nic Jun 29 '16 at 01:17
  • @QPaysTaxes I did that.. I added an answer and accepted it long ago – Moussa Khalil Jun 29 '16 at 10:43
  • Whoops, sorRyan. I was expecting the answer to be at the top, but I forgot that self-answers don't get pinned there. – Nic Jun 29 '16 at 16:16

3 Answers3

1

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.

Community
  • 1
  • 1
Vaiden
  • 15,728
  • 7
  • 61
  • 91
  • Updated question with project and app gradle. Also the portion of manifest that relates. I don't believe there is a pro guard directory as mentioned in the link you gave me. Isn't minifyEnabled false effectively shutting down proguard. I am still new to this stuff :). I even removed this line " proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'" but still no luck – Moussa Khalil Jun 02 '16 at 13:19
  • Many thanks Sir you pointed me to the correct direction. The classes were missing because of outdated APIs related to the android versions and not proguard eliminating them. PS: Adding GMS only exceeds 65k if you add all of it :) – Moussa Khalil Jun 02 '16 at 15:32
0

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"
Egor
  • 39,695
  • 10
  • 113
  • 130
0

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

Moussa Khalil
  • 635
  • 5
  • 12