1

I added OneSignal to App and it works fine, but when I added:

com.google.android.gms:play-services-ads:17.1.1

build fails: Cannot fit requested classes in a single dex file (# methods: 70355 > 65536)

I searched then found this https://stackoverflow.com/a/51088321 which indicates the reason. When I delete play-services-ads this problem gone. I didn't get which group or module should I exclude to solve this, I tried this but not solved the problem:

    implementation ('com.google.android.gms:play-services-ads:17.1.1'){
    transitive = true
    exclude group: "play-services-ads-identifier"
    exclude group: "play-services-basement"
    exclude group: "play-services-measurement-sdk-api"
    exclude module: "play-services-measurement-base"
}

gradlew :app:dependencies related output:

|    +--- com.google.android.gms:play-services-ads-base:[17.1.1] -> 17.1.1
|    +--- com.google.android.gms:play-services-ads-identifier:16.0.0 (*)
|    +--- com.google.android.gms:play-services-ads-lite:[17.1.1] -> 17.1.1
|    |    +--- com.google.android.gms:play-services-ads-base:[17.1.1] -> 17.1.1
|    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    \--- com.google.android.gms:play-services-measurement-sdk-api:16.0.3
|    |         +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |         \--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
|    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-gass:[17.1.1] -> 17.1.1
|    |    +--- com.google.android.gms:play-services-ads-base:[17.1.1] -> 17.1.1
|    |    \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)

I useed 17.1.1 because minAPI is 15.

I don't want use multidex support, because this is a not a solution.

ZaFaR97
  • 71
  • 1
  • 6
  • excluding a group or module should only be used when two or more dependencies have conflicting sub modules. If you are not planning to use multidex, try [proguarding](https://developer.android.com/studio/build/shrink-code#shrink-code) the app to remove redundant code. – Ranzz Sep 02 '20 at 18:46
  • @Ranzz Iam using it now, the problem appears after adding `play-services-ads` only, it wasn't before, and when I delete `OneSignal` & add `play-services-ads`, app works fine! This means that there are a conflict somwhere – ZaFaR97 Sep 03 '20 at 03:42

0 Answers0