Android资源链接失败-AAPT:错误:未找到资源android:attr / dialogCornerRadius

问题描述 投票:1回答:1

[尝试将本地版本的Android版本捆绑在一起时收到错误。请注意,该项目应转换为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.

Root 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"
      }
    }
  }
}

App 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 foundhttps://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

本机信息

npmPackages:
  react: ^16.7.0 => 16.13.1 
  react-native: 0.59.9 => 0.59.9 
npmGlobalPackages:
  react-native-cli: 2.0.1
react-native gradle build.gradle react-native-android aapt
1个回答
0
投票

解决方案1:

  1. 现在检查什么反应本机项目都支持androidX。
gradlew app:dependencies

在输出中搜索androidX。获取所有具有androidx的库。

  1. 在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/releases#may_07_2019。您也可以选择任何其他版本。这个解决方案解决了我的问题。让我知道是否有帮助。

解决方案2

rm -rf android/.gradle
rm -rf .gradle
rm -rf ~/.gradle
./gradlew clean
© www.soinside.com 2019 - 2024. All rights reserved.