Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android resource linking failed - AAPT: error: resource android:attr/dialogCornerRadius not found

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.

Error Messages

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.

Root Build.gradle file

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 file

dependencies

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'
}

Research

I have seen some other issues of this being reported such as:
React-native(android) AAPT: error: resource android:attr/dialogCornerRadius not found
https://fincoapps.com/error-resource-androidattr-dialogcornerradius-not-found/.

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.

Edit

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 info

npmPackages:
  react: ^16.7.0 => 16.13.1 
  react-native: 0.59.9 => 0.59.9 
npmGlobalPackages:
  react-native-cli: 2.0.1
like image 851
StuartM Avatar asked Jun 12 '20 18:06

StuartM


Video Answer


1 Answers

Solution 1:

  1. Check what all react native projects are supporting androidX now.
gradlew app:dependencies

Search for androidX in the output. Get all the libraries having androidx.

  1. Make a change in build.gradle inside android/app
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'
    }
}

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.

Solution 2

rm -rf android/.gradle
rm -rf .gradle
rm -rf ~/.gradle
./gradlew clean
like image 89
Muhammad Numan Avatar answered Oct 22 '22 19:10

Muhammad Numan