Reputation: 405
I integrated Google Maps API into my app and now it takes much more time for first start (even if I don't launch maps) and moreover I can't Build APK
with maps. I can simply run it on device but I can't build it in Android Studio.
Dependencies:
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.google.android.gms:play-services:9.8.0'
Here are errors:
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 2
So, two questions: how to decrease time for first launch and how to build app?
Upvotes: 0
Views: 150
Reputation: 5705
Don't include complete play services libs in gradle file, they consume about 34 k methods from 64k method limit provided for an apk. So there are two solutions.
com.google.android.gms:play-services-maps:10.0.1
Enable multidex support for your app. To do this do the following steps
android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true// add this line
}
}
And add this as a dependency
compile 'com.android.support:multidex:1.0.1'
Upvotes: 0
Reputation: 1271
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
Use this in your app build.gradle file it will work.
Upvotes: 1