Android studio 3.0编译时错误BUILD FAILED

问题描述 投票:5回答:2

移动android studio 3.0之后,我正面临着这个问题。

每当我尝试运行几次后,就会发生此错误。

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

解决方案是重建或清理然后运行应用程序。因此,我无法使用即时运行功能。

I have already tried this solution和它的作品。

但为什么我经常在一小时内面对这个问题4-5次呢?

P.S我没有管理员权限。正如提到的HERE as accepted answer

我的其他项目工作正常,没有任何问题。你可能会发现这个问题是重复的,但以前的解决方案根本不对我有帮助。

的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'
}
android-gradle build.gradle android-studio-3.0
2个回答
6
投票

我也遇到了同样的问题并解决了它。

尝试将Realm插件更新到4.2.0。

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


0
投票

尝试这个缺少java文件作为1.jar,2.jar....28.jar,29.jar ...尽快

在gradle.properties中添加以下内容:

android.enableD8.desugaring = true 
© www.soinside.com 2019 - 2024. All rights reserved.