React Native: Failed to execute

2018-11-14  本文已影响0人  本间麻衣子

描述:
构建 release 版本失败,开发环境正常

版本信息:

react@16.6.1
react-native@0.57.5

错误信息:

error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
C:\Users\nodece\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\41458edcfa3aa3330042a7673ace2ab9\res\values-v26\values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.

C:\Users\nodece\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\41458edcfa3aa3330042a7673ace2ab9\res\values-v26\values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.

C:\Users\nodece\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\41458edcfa3aa3330042a7673ace2ab9\res\values-v26\values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.

C:\Users\nodece\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\41458edcfa3aa3330042a7673ace2ab9\res\values\values.xml:251:5-69: AAPT: error: resource android:attr/fontStyle not found.

C:\Users\nodece\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\41458edcfa3aa3330042a7673ace2ab9\res\values\values.xml:251:5-69: AAPT: error: resource android:attr/font not found.

C:\Users\nodece\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\41458edcfa3aa3330042a7673ace2ab9\res\values\values.xml:251:5-69: AAPT: error: resource android:attr/fontWeight not found.

error: failed linking references.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-wechat:verifyReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

解决方案:
修改 android/gradle.build

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

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

// 解决方案开始
subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion     //do this in android/app/build.gradle too
                buildToolsVersion rootProject.ext.buildToolsVersion     //do this in android/app/build.gradle too
            }
        }
    }
}
// 解决方案结束

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


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

上一篇下一篇

猜你喜欢

热点阅读