gpt4 book ai didi

react-native - Android资源链接失败-AAPT : error: resource android:attr/dialogCornerRadius not found

转载 作者:行者123 更新时间:2023-12-03 02:41:05 30 4
gpt4 key购买 nike

尝试将Android版本捆绑为react-native项目时出现错误。请注意,该项目应转换为AndroidX。

错误讯息

尝试为Android构建发行版本时,出现以下错误:

    * 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: error: resource android:attr/dialogCornerRadius not found
https://fincoapps.com/error-resource-androidattr-dialogcornerradius-not-found/

但是,这些看起来像您期望的那样已设置。一个问题表明子项目编辑存在于root build.gradle文件中,但是始终会出现相同的错误消息。

编辑

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

react native 信息
npmPackages:
react: ^16.7.0 => 16.13.1
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
react-native-cli: 2.0.1

最佳答案

解决方案1:

  • 检查现在所有响应 native 项目都支持androidX。
  • gradlew app:dependencies

    在输出中搜索androidX。获取所有具有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'
    }
    }

    这些是在我的 native 项目中引起问题的库。
    Google保留 https://developers.google.com/android/guides/releases#may_07_2019的所有版本。您也可以选择任何其他版本。这个解决方案解决了我的问题。让我知道是否有帮助。

    解决方案2
    rm -rf android/.gradle
    rm -rf .gradle
    rm -rf ~/.gradle
    ./gradlew clean

    关于react-native - Android资源链接失败-AAPT : error: resource android:attr/dialogCornerRadius not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62350094/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com