I can successfully build and run my Android app in my debug and release variants with no problem. Yet, when I try to run my new unit tests (I never had them before), I get t
the error occurs maybe because of too many functions in your projects and library.
You can:
- Enable multiple dex
as @Intellij Amiya's answer
- Check libraries: specifying only the specific Google Play services APIs your app uses, instead of all of them.
compile 'com.google.android.gms:play-services-ads:7.5.0'
Find and exclude duplicated dependencies: open your terminal and run:
gradle -q dependencies
It will show a list as below example:
+--- com.android.support:appcompat-v7:23.0.1
| \--- com.android.support:support-v4:23.0.1
| \--- com.android.support:support-annotations:23.0.1
+--- :dputility_library-1.1.2:
+--- com.google.android.gms:play-services-ads:7.5.0
| +--- com.google.android.gms:play-services-base:7.5.0
| | \--- com.android.support:support-v4:22.0.0 -> 23.0.1 (*)
| \--- com.google.android.gms:play-services-analytics:7.5.0
| \--- com.google.android.gms:play-services-base:7.5.0 (*)
+--- com.jakewharton:butterknife:7.0.1
+--- com.afollestad:material-dialogs:0.7.6.0
| +--- com.android.support:support-v4:22.2.0 -> 23.0.1 (*)
| +--- com.android.support:appcompat-v7:22.2.0 -> 23.0.1 (*)
| +--- com.android.support:recyclerview-v7:22.2.0
| | +--- com.android.support:support-annotations:22.2.0 -> 23.0.1
| | \--- com.android.support:support-v4:22.2.0 -> 23.0.1 (*)
| \--- com.android.support:support-annotations:22.2.0 -> 23.0.1
You can see some dependencies with (*), you can exclude it from your gradle dependences:
compile('com.google.android.gms:play-services-ads:7.5.0')
{
exclude module: 'support-v4'
exclude module: 'play-services-base'
}
Actually, for me, the excluding method works (multiple dex does not). Hope it helps.