Android Error:Execution failed for task ':app:transformClassesWithDexForDebug'
You are compiling the whole Google play services library:
compile 'com.google.android.gms:play-services:8.3.0'
which can cross the 64K reference limit'
during compiling..
See this
if u just use some services from the library you can Selectively compiling APIs into your executable
Like:
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
I would also suggest to use latest version of play services compile 'com.google.android.gms:play-services:10.2.1'
2nd Way
If you really want to use the whole library : Enable Multidex
in your application.
in your Gradle:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
in Application class:
public class MyApplication extends SomeOtherApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Define the application class in manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
I get: Error:Execution failed for task ':app:transformClassesWithDexForDebug'. when making Google maps App
clean and see still error is there if yes,
1.go to your build.gradle
file.
add multiDexEnabled true
defaultConfig {
multiDexEnabled true
}
2.in your dependencies add compile 'com.android.support:multidex:1.0.1'
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
3.inside your application tag in menifest add android:name="android.support.multidex.MultiDexApplication"
<application
android:name="android.support.multidex.MultiDexApplication"
....
4.use this override method on your launching activity
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Execution failed for task ':app:transformClassesWithDexForDebug' in react native
My guess is you are over the 64k reference limit and need to enable multidexing. The second article you linked referenced how to solve this, but many react-native projects are initialized with minSdkVersion of 16, so there is an extra step to enabled multidex. You have two options.
Option 1:
Upgrade your minSdkVersion to 21 in your AndroidManifest.xml file (android/app/src/main/AndroidManifest.xml) and also your build.gradle file (android/app/build.gradle), then in your build.gradle file add multiDexEnabled to true in this line
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
Option 2:
If you need to stay at minSdkVersion 16, set multiDexEnabled to true in your build.gradle file, then add this line under "dependencies" in the same file
dependencies {
compile 'com.android.support:multidex:1.0.1'
...(your other dependencies here)
}
Then depending on whether you override the Application class, perform one of the following:
If you do not override the Application class, edit your manifest file to set android:name in the tag as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
If you do override the Application class in android/app/src/main/java/MainApplication.java, change it to extend MultiDexApplication (if possible) as follows:
public class MyApplication extends MultiDexApplication { ... }
Here is android's documentation on what this error means and why it occurs, as well as how to fix it https://developer.android.com/studio/build/multidex.html
Related Topics
Ontouchevent Not Working on Child Views
Parcelable Encountered Ioexception Writing Serializable Object Getactivity()
Java.Lang.Unsatisfiedlinkerror: Dalvik.System.Pathclassloader
Android Studio Doesn't Recognize My Device
What Should Be the Package Name of Android App
Launching Activity from Widget
Dynamically Add Textviews to a Linearlayout
Change Checkbox Value Without Triggering Oncheckchanged
How to Update Notification with Remoteviews
How to Implement Uncaughtexception Android
Processing More Than One Button Click at Android Widget
Android: How to Integrate a Decoder to Multimedia Framework
Menu Items Are Not Showing on Action Bar
Android Broadcastreceiver Within Activity
How to Listen for Preference Changes Within a Preferencefragment