java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:Android资源链接失败

时间:2018-12-02 23:34:10

标签: android react-native lottie aapt2

我制作了一个演示应用程序,并使用Lottie添加了一些动画,它在调试中工作正常,但在发布模式下失败。 这是我得到的错误

Execution failed for task ':lottie-react- 
native:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.andr

这是我的build.gradle

buildscript {
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}


allprojects {
repositories {
    google()
    mavenLocal()
    jcenter()
    maven {
        url 'https://maven.google.com'
    }
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

ext.versions = [:]
versions.compileSdk = 28
versions.minSdk = 19
versions.targetSdk = 26
versions.support = "28.0.0"
versions.constraint_layout = "1.1.3"
versions.glide = "4.8.0"
versions.work = "1.0.0-alpha10"

应用级gradle

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
    applicationId "com.pois"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
subprojects {
    project.configurations.all {
        afterEvaluate {project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion 26
                    buildToolsVersion '26.0.1'
                }
            }
        }
    }
}

signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}
}




dependencies {
compile project(':lottie-react-native')
compile project(':react-native-code-push')
compile project(':react-native-vector-icons')
compile project(':react-native-view-overflow')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:28.0.0'
compile "com.android.support:support-v4:28.0.+"
compile 'com.facebook.react:react-native:+'
// From node_modules
implementation "android.arch.work:work-runtime:$versions.work"
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex:rxandroid:1.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.6@aar') {
    transitive = true;
}
}

仅当我将Lottie添加到项目后,此错误才出现。当我使用react-native run-android运行它时,它可以正常工作,但是当我生成一个签名的apk时,它不起作用。

1 个答案:

答案 0 :(得分:0)

我真傻。我只需要在各自的gradle文件中升级Lottie库和codePush的compileSdkVersion,好了就可以了。