Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio 3.0 compile time error BUILD FAILED

I'm facing this issue after moving on android studio 3.0.

Whenever I try to run after couple of time then this error occurs.

Information:Gradle tasks [:app:assembleDevDebug]
Error:java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Error:com.android.build.api.transform.TransformException: java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Error:java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Information:BUILD FAILED in 2s
Information:3 errors
Information:0 warnings

Solution is to rebuild or clean then run app. Because of this i am not able to use instant run feature.

I have already tried this solution and it works works.

But why am I facing this issue frequently like 4-5 times in an hour?

P.S I do not have admin access. as mentioned HERE as accepted answer

The rest of my projects are working fine without any issue. You may find this question as duplicate but the previous solutions are not really helpful to me at all.

Build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
apply plugin: 'realm-android'

repositories {
    maven {
        url "https://XXX.XXX.com/XXX.XXX.com"
    }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    flavorDimensions "default"
    project.archivesBaseName = "XXX";
    signingConfigs {
        release {
            storeFile file (System.getenv('XXX'))
            storePassword System.getenv("XXX")
            keyAlias System.getenv("XXX")
            keyPassword System.getenv("XXX")
        }
    }
    playAccountConfigs {
        defaultAccountConfig {
            serviceAccountEmail = '[email protected]'
            pk12File = file('XXX-XXX.p12')
        }
    }
    defaultConfig {
        applicationId "com.XXX.app"
        minSdkVersion 16
        targetSdkVersion 26
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        signingConfig signingConfigs.release
        playAccountConfig = playAccountConfigs.defaultAccountConfig

     ndk {
          abiFilters 'armeabi-v7a'
        }
    }
    lintOptions {
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    dexOptions {
        javaMaxHeapSize "4g"
        jumboMode true
    }
    productFlavors {

        pro {
            buildConfigField "XXX", "XXX", System.getenv("XXX")
            buildConfigField "XXX", "XXX", System.getenv("XXX")      
            buildConfigField "XXX", "XXX", System.getenv("XXX")
            buildConfigField "XXX", "XXX", System.getenv("XXX")
        }
        qa {
            buildConfigField "XXX", "XXX", System.getenv("XXX")
            buildConfigField "XXX", "XXX", System.getenv("XXX")
            manifestPlaceholders = [facebookId: "XXX"]
        }
    }
    buildTypes {        
        release {
            minifyEnabled false            
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            applicationVariants.all { variant ->
                variant.outputs.all {
                    outputFileName = "XXX-${variant.baseName}-${variant.versionName}.apk"
                }
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'META-INF/XXX'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs'
    })
    testImplementation 'junit:junit:4.12'
    implementation project(path: ':instacount')
    implementation project(path: ':cordova')
    implementation 'com.android.support:multidex:1.0.2'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:palette-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.google.android.gms:play-services-maps:11.0.4'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation 'net.danlew:android.joda:2.8.2'
    implementation 'com.auth0.android:auth0:1.8.0'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    implementation 'com.amazonaws:aws-android-sdk-s3:2.4.4'
    implementation 'testfairy:testfairy-android-sdk:1.+@aar'
    implementation 'com.afollestad.material-dialogs:commons:0.9.0.1'
    implementation 'com.jenzz.appstate:appstate:3.0.1'
    implementation 'id.zelory:compressor:2.1.0'
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    implementation 'com.commonsware.cwac:cam2:0.7.6'
    implementation 'org.parceler:parceler-api:1.1.9'
    annotationProcessor 'org.parceler:parceler:1.1.9'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
    implementation 'com.caverock:androidsvg:1.2.1'
}

play {
    track = 'beta'
}
like image 922
Aks4125 Avatar asked Nov 20 '17 08:11

Aks4125


People also ask

How do I fix errors in Android Studio?

layout error is being caused by a mismatch between Android Studio's cache and your project's current layout. If you suspect this may be the case, then select File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio's toolbar. Issues with the names of your resources can also prevent the R.

Why is Android studio not opening?

If Studio doesn't start after an upgrade, the problem may be due to an invalid Android Studio configuration imported from a previous version of Android Studio or an incompatible plugin.

Where is the Android SDK in Android Studio?

by default, the "Android Studio IDE" will be installed in " C:\Program Files\Android\Android Studio ", and the "Android SDK" in " c:\Users\username\AppData\Local\Android\Sdk ".


Video Answer


1 Answers

I also encountered the same problem and solved it.

Try to update Realm plugin to 4.2.0.

See File handles are not released in RealmTransformer · Issue #5521 · realm/realm-java

like image 90
takke Avatar answered Sep 21 '22 23:09

takke