安装“ 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
请任何人帮助我解决此问题。
谢谢。
答案 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.gradle
和node_modules/react-native-get-sms-android/android/build.gradle
的配置不匹配
解决方案
node_modules/react-native-get-sms-android/android/build.gradle
compileSdkVersion
buildToolsVersion
minSdkVersion
targetSdkVersion
并使其与android/app/build.gradle
相同./gradlew assembleRelease
。