任务':react-native-get-sms-android:verifyReleaseResources'的React Native Build错误执行失败

时间:2018-11-19 08:39:45

标签: android reactjs react-native gradle

安装“ react-native-get-sms-android”后,我在构建本机反应时遇到问题,您可以在此处https://www.npmjs.com/package/react-native-get-sms-android处查找,我不知道为什么,我尝试查找类似的错误,但是全部失败。

这是完整的错误:

> Task :app:processReleaseGoogleServices
Parsing json file: D:\Project\React Native\myProject\android\app\google-services.json

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\frank\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\226ef6010c3c969192062affc53f6ce6\res\values-v26\values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.

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

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

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

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

C:\Users\frank\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\226ef6010c3c969192062affc53f6ce6\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-get-sms-android:verifyReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 54s
203 actionable tasks: 4 executed, 199 up-to-date

请任何人帮助我解决此问题。

谢谢。

2 个答案:

答案 0 :(得分:3)

您需要更新android build tools version。 以下对我有用。 在android/build.gradle中,将ext更改如下:

ext {
    buildToolsVersion = "28.0.0"
    minSdkVersion = ... // your min SDK
    compileSdkVersion = 28
    targetSdkVersion = ...// your target SDK
    supportLibVersion = "28.0.0"
}

并将其放在文件末尾:

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "28.0.0"
            }
        }
    }
    afterEvaluate {
        project -> if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
                buildToolsVersion '28.0.0'
            }
        }
    }
}

android/app/build.gradle中,将此:"com.android.support:appcompat-v7:27.1.1"更改为:"com.android.support:appcompat-v7:28.0.0"

答案 1 :(得分:0)

错误原因:

您已将 react-native-get-sms-android 安装为依赖项,并且发生此错误的原因是android/app/build.gradlenode_modules/react-native-get-sms-android/android/build.gradle的配置不匹配

解决方案

  1. 导航到node_modules/react-native-get-sms-android/android/build.gradle
  2. 编辑compileSdkVersion buildToolsVersion minSdkVersion targetSdkVersion并使其与android/app/build.gradle相同
  3. 再次同步项目。
  4. 从终端运行./gradlew assembleRelease