1

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: No dex files created at C:\Users\DELL\AndroidStudioProjects\PK19\app\build\intermediates\transforms\dex\debug\folders\1000\10\instant-run_3e64ab9e373807c9050a33a8846eab1e5e4e2138

This is how my gradle looks. I use android studio 2.1.2

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.example.dell.pk19"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    dexOptions {
        incremental = true;
        preDexLibraries = false
        javaMaxHeapSize "4g" // 2g should be also OK
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'

    compile 'com.android.support:multidex:1.0.0'
}

How to fix this error?

Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49

3 Answers3

1

In my case none of the solutions available worked except this, I disabled instant run.No need to make any changes in the gradle

File → Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.

0

This could happen because of the bad cache used by the instant run by Android Studio. Clean the project and rebuild it

Build->Clean Project

Samuel Robert
  • 10,106
  • 7
  • 39
  • 60
-1

Your application class should extend MultiDexApplication :

public class App extends MultiDexApplication {...}

Then in AndroidManifest you should refer to this class :

<application
    ...
    android:name=".App">
    ...
</application>
Mody
  • 204
  • 2
  • 7
  • public class App extends MultiDexApplication { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } } added this in my mainactivity n wrote android:name=".app" in my android manifest but it didnt help – Nikit Bhandari Oct 13 '16 at 07:43
  • Please, check [this link](http://blog.osom.info/2014/10/multi-dex-to-rescue-from-infamous-65536.html). Considerable part of explanation and resolving the problem is in the "afterEvaluate" block in .gradle. Hope, it'll help. – Mody Oct 13 '16 at 13:31
  • coppied the "afterEvaluate" block. still the same error – Nikit Bhandari Oct 13 '16 at 17:02