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>
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
Error:Execution failed for task ':app:transformDexWithInstantRunSlicesApkForDebug'. Failed to read zip file
Switch off the Instant Run in Preferences helped me
Related Topics
How to Control the Width and Height of the Default Alert Dialog in Android
How to Dismiss the Dialog with Click on Outside of the Dialog
Set Transparent Background of an Imageview on Android
How to Customize a Spinner in Android
Outlined Edit Text from Material Design
How to Disable Recyclerview Scrolling
Android Quick Actions UI Pattern
How to Send a File in Android from a Mobile Device to Server Using Http
Resources$Notfoundexception: Resource Is Not a Drawable (Color or Path)
Android: Detect When Scrollview Stops Scrolling
Manifest Merger Failed with Multiple Errors in Android Studio
What's the Best Way to Iterate an Android Cursor
Recyclerview Expand/Collapse Items
How to Specify Different Layouts for Portrait and Landscape Orientations
How to Encrypt and Decrypt File in Android
Is There a Broadcast Action for Volume Changes
Android "Elevation" Not Showing a Shadow
Android: Java.Lang.Securityexception: Permission Denial: Start Intent