更新到gradle 3.0.1后无法链接文件资源

时间:2017-12-07 12:48:37

标签: android gradle

尝试运行项目后,我收到以下错误。

Error:failed linking file resources.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

在关注what was suggested here(禁用aapt2)之后,我遇到了许多新错误。

Error:com.android.ide.common.process.ProcessException: Error while 
executing process DIR/build-tools/27.0.2/aapt with arguments {package -
f --no-crunch -I DIR/platforms/android-27/android.jar -M 
DIR/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S 
DIR/app/build/intermediates/res/merged/debug -m -J 
DIR/app/build/generated/source/r/debug -F 
DIR/app/build/intermediates/res/debug/resources-debug.ap_ --custom-
package com.appname -0 apk --output-text-symbols 
DIR/app/build/intermediates/symbols/debug --no-version-vectors}

Error:org.gradle.process.internal.ExecException: Process 'command 
'DIR/build-tools/27.0.2/aapt'' 
finished with non-zero exit value 1

Gradle文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.0'
    }
}
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
buildscript {
    repositories {
        repositories {
            maven { url 'https://maven.google.com' }
        }
        repositories {
            maven { url 'https://maven.fabric.io/public' }
        }
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.25.1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.2'
    defaultConfig {
        applicationId "com.trynagrub.trynagrub"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile files('libs/signalr-client-sdk.jar')
    compile files('libs/signalr-client-sdk-android.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true;
    }
//    compile 'org.zakariya.stickyheaders:stickyheaders:0.7.6'
//    compile 'com.github.stfalcon:chatkit:0.2.2'
//    compile 'com.hbb20:ccp:2.0.3'
    compile 'net.danlew:android.joda:2.9.9'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.xw.repo:bubbleseekbar:3.6'
    compile 'com.github.pavlospt:circleview:1.3'
    compile 'com.facebook.android:facebook-android-sdk:4.29.0'
    compile 'com.amitshekhar.android:android-networking:1.0.0'
    compile 'com.android.support:support-compat:27.0.1'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-gcm:11.6.2'
    compile 'com.snatik:storage:2.1.0'
    compile 'com.github.tamir7.contacts:contacts:1.1.7'
    compile 'com.google.android.gms:play-services-maps:11.6.2'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

我不知道为什么会一直发生。但是因为这个原因,应用程序中的所有R引用都无法解决。在更新之前我遇到了混合版本的android支持库的问题,所以我禁用了使用不同版本的支持库的库,这可能是导致这种情况的吗?

请帮忙。

2 个答案:

答案 0 :(得分:1)

尝试将compile部分中的所有dependencies字词更改为implementation

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation files('libs/signalr-client-sdk.jar')
implementation files('libs/signalr-client-sdk-android.jar')
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
    transitive = true;
}
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
    transitive = true;
}
implementation 'net.danlew:android.joda:2.9.9'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.xw.repo:bubbleseekbar:3.6'
implementation 'com.github.pavlospt:circleview:1.3'
implementation 'com.facebook.android:facebook-android-sdk:4.29.0'
implementation 'com.amitshekhar.android:android-networking:1.0.0'
implementation 'com.android.support:support-compat:27.0.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-gcm:11.6.2'
implementation 'com.snatik:storage:2.1.0'
implementation 'com.github.tamir7.contacts:contacts:1.1.7'
implementation 'com.google.android.gms:play-services-maps:11.6.2'
testCompile 'junit:junit:4.12'
}

答案 1 :(得分:0)

  

试试这个,转到你的

gradle.properties
  

使用以下代码

 android.enableAapt2=false

enter image description here enter image description here