2

Trying to add an ad to our existing Android app, and when compiled I got this:

Cannot fit requested classes in a single dex file. Try supplying a main-dex list.

Looking around, the suggestion is to reduce the play-services size and this is what I have:

implementation 'com.google.android.gms:play-services-ads:12.0.1' // newly added
implementation 'com.google.android.gms:play-services:12.0.1'

I use Android Wear in the code, so when I reduce to:

implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.android.gms:play-services-wearable:12.0.1'

Now I got:

resource style/Theme.AppCompat (...) not found. 

I try adding

compile "com.android.support:appcompat-v7:21.0.+"

and I got more problems of conflict. What is my best solution? My current fix is to change AppCompat back to Activity. Would appreciate other answers!

Lim Thye Chean
  • 8,704
  • 9
  • 49
  • 88

1 Answers1

8

You may refer with this thread. Try adding this library in the app gradle: implementation 'com.android.support:multidex:1.0.3'. Then add multiDexEnabled true in the defaultConfig of the app gradle. Also from this documentation, when your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture.

abielita
  • 13,147
  • 2
  • 17
  • 59