Android资源链接失败-AAPT:错误:未找到资源android:attr/dialogCornerRadius [英] Android resource linking failed - AAPT: error: resource android:attr/dialogCornerRadius not found
问题描述
当我尝试将Android版本捆绑为react-native项目时,我收到错误消息.该项目应作为注释转换为AndroidX.
I am receiving errors when trying to bundle an android release for a react-native project. This project should be converted to AndroidX as a note.
当尝试为Android构建发行版本时,出现以下错误:
When trying to build a release build for Android I receive the following errors:
* What went wrong:
Execution failed for task ':react-native-vector-icons:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> 1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/.../.gradle/caches/transforms-2/files-2.1/5c74eb36d229b35abeeb690f5d3b91a3/appcompat-1.0.0/res/values-v28/values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
/Users/.../.gradle/caches/transforms-2/files-2.1/5c74eb36d229b35abeeb690f5d3b91a3/appcompat-1.0.0/res/values-v28/values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
/Users/.../.gradle/caches/transforms-2/files-2.1/f54ae08833e39bf2b75fd420ffea65b9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/.../.gradle/caches/transforms-2/files-2.1/f54ae08833e39bf2b75fd420ffea65b9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
根Build.gradle文件
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0-alpha1"
reactNativeVersion = "0.59.9"
}
repositories {
jcenter()
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath('com.android.tools.build:gradle:3.6.3')
classpath 'com.google.gms:google-services:4.2.0'
// Add the Crashlytics Gradle plugin.
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
}
}
allprojects {
repositories {
google()
mavenLocal()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// React native video - exoplayer missing from google repos, temp fix
maven {
url "https://google.bintray.com/exoplayer/"
}
jcenter()
}
}
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0-alpha1"
reactNativeVersion = "0.59.9"
}
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion compileSdkVersion
buildToolsVersion "$buildToolsVersion"
}
}
}
}
应用程序build.gradle文件
依赖项
dependencies {
implementation project(':react-native-safe-area-context')
implementation 'com.android.support:support-annotations:28.0.3'
implementation "androidx.annotation:annotation:1.1.0"
implementation project(':react-native-video')
implementation(project(":react-native-google-signin"))
implementation project(':react-native-splash-screen')
implementation project(':react-native-iap')
implementation project(':react-native-version-check')
implementation project(':react-native-vector-icons')
implementation project(':react-native-linear-gradient')
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation project(':react-native-fbsdk')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-vector-icons')
implementation project(':react-native-fbsdk')
implementation project(':react-native-vector-icons')
// react-native-google-signin
// react-native-fbsdk
implementation 'com.facebook.android:facebook-android-sdk:4.33.0'
implementation project(':react-native-fbsdk')
// RNFirebase required dependencies
implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.android.gms:play-services-base:17.0.0"
// RNFirebase optional dependencies
implementation "com.google.firebase:firebase-auth:17.0.0"
implementation "com.google.firebase:firebase-database:16.0.5"
implementation "com.google.firebase:firebase-firestore:17.1.4"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation ("com.facebook.react:react-native:0.59.9") {force = true} // From node_modules
implementation 'com.google.firebase:firebase-crashlytics:17.0.1'
}
研究
我还看到了其他一些有关此问题的报道,例如:
React-native(android)AAPT:错误:资源android:attr/dialogCornerRadius找不到
https://fincoapps.com/error-resource-androidattr-dialogcornerradius-not-找到/.
但是,这些看起来已经按照您的期望进行了设置.一个问题表明子项目编辑存在于root build.gradle文件中,但是始终会出现相同的错误消息.
However, these look to be setup as you'd expect. One issue suggests the subprojects edit that exists in the root build.gradle file, but the same error messages always occur.
gradle-wrapper.properties
gradle-wrapper.properties
#Thu May 07 14:26:41 BST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
android.enableJetifier=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
android.useAndroidX=true
本机信息
npmPackages:
react: ^16.7.0 => 16.13.1
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
react-native-cli: 2.0.1
推荐答案
解决方案1:
- 检查所有响应本机项目现在都支持androidX.
gradlew app:dependencies
在输出中搜索androidX.获取所有具有androidx的库.
Search for androidX in the output. Get all the libraries having androidx.
- 在android/app内部的
build.gradle
中进行更改
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:16.1.0'
force 'com.google.android.gms:play-services-basement:16.2.0'
force 'com.google.android.gms:play-services-auth:16.0.1'
force 'com.google.firebase:firebase-messaging:18.0.0'
force 'com.google.firebase:firebase-common:17.0.0'
force 'com.google.firebase:firebase-iid:18.0.0'
force 'com.google.android.gms:play-services-stats:16.0.1'
force 'com.google.android.gms:play-services-base:16.0.1'
}
}
这些是在我的本机反应项目中引起问题的库.Google在此处维护所有版本 https://developers.google.com/android/guides/版本#may_07_2019 .您也可以选择任何其他版本.在我的情况下,此解决方案解决了问题.让我知道是否有帮助.
These were the libraries that caused problem in my react native project. Google maintains all the releases here https://developers.google.com/android/guides/releases#may_07_2019 . You can choose any other version also. This solution solved issue in my case. Let me know if this helps.
rm -rf android/.gradle
rm -rf .gradle
rm -rf ~/.gradle
./gradlew clean
这篇关于Android资源链接失败-AAPT:错误:未找到资源android:attr/dialogCornerRadius的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!