0

when i run ./gradlew assembleRelease on my react android project, i keep getting the following error:

    A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /root/.gradle/caches/transforms-2/files-2.1/6da249295a8c8ecbd4d1ab0ef0c0da5a/core-1.5.0-alpha04/res/values/values.xml:143:5-174:25: AAPT: error: resource android:attr/fontStyle not found.
         
     /root/.gradle/caches/transforms-2/files-2.1/6da249295a8c8ecbd4d1ab0ef0c0da5a/core-1.5.0-alpha04/res/values/values.xml:143:5-174:25: AAPT: error: resource android:attr/font not found.
         
     /root/.gradle/caches/transforms-2/files-2.1/6da249295a8c8ecbd4d1ab0ef0c0da5a/core-1.5.0-alpha04/res/values/values.xml:143:5-174:25: AAPT: error: resource android:attr/fontWeight not found.
         
     /root/.gradle/caches/transforms-2/files-2.1/6da249295a8c8ecbd4d1ab0ef0c0da5a/core-1.5.0-alpha04/res/values/values.xml:143:5-174:25: AAPT: error: resource android:attr/fontVariationSettings not found.
         
     /root/.gradle/caches/transforms-2/files-2.1/6da249295a8c8ecbd4d1ab0ef0c0da5a/core-1.5.0-alpha04/res/values/values.xml:143:5-174:25: AAPT: error: resource android:attr/ttcIndex not found.

It builds fine of i do a assembeDebug

Here is some of my gradle build settings

 buildToolsVersion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29
        ext.kotlin_version = '1.4.10'


multiDexEnabled true


release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }


apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
buildscript {
    ext.kotlin_version = '1.4.10'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
repositories {
    mavenCentral()
}
Jono
  • 17,341
  • 48
  • 135
  • 217
  • Try deleting gradle cache and rebuilding – Manohar Oct 28 '20 at 10:05
  • Where is the gradle cache? all i see is a gadle-wrapper.jar and .properties file insid ethe gralde folder in the project – Jono Oct 28 '20 at 10:27
  • In home/.gradle or windows/user/yourName/.gradle . There should be a caches folder inside it . it should be safe to delete . If you are worried the copy some where else and delete . .gradle folder will be hidden – Manohar Oct 28 '20 at 11:16
  • You can also try deleting .gradle folder "inside project" if above didn't work – Manohar Oct 28 '20 at 11:17
  • Deleted the cache file in the .gradle folder and re ran the above command and still recieved the same error – Jono Oct 28 '20 at 11:46

1 Answers1

0

run this command:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res --verbose

and then delete project_root/android/app/src/main/raw + drawable-.. folders.

After that build your release APK.

B. Mohammad
  • 2,152
  • 1
  • 13
  • 28
  • When i try runing that command i get `Command `bundle` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.` i am inside my react naive project and other react native commands work fine such as 'react-native start' – Jono Oct 28 '20 at 10:50
  • That progressed and enabled me to run the script, however i now get this error: Failed to construct transformer: Error: EACCES: permission denied, open '/tmp/haste-map-metro-4-0be85dad9d95e79ac5ef993923 – Jono Oct 28 '20 at 10:53
  • I tried runing sudo npx react-native ..... but it says ocmmand npx not found after place sudo before it – Jono Oct 28 '20 at 10:54
  • looks like user access problem, may be try `sudo chmod -R 777 {path}`. – B. Mohammad Oct 28 '20 at 11:03
  • Ok thanks. I now get this error : info Writing bundle output to:, android/app/src/main/assets/index.android.bundle error ENOENT: no such file or directory, open 'android/app/src/main/assets/index.android.bundle' – Jono Oct 28 '20 at 11:07
  • Can you check this: https://stackoverflow.com/questions/58767106/enoent-no-such-file-or-directory-open-android-app-src-main-assets-index-andro – B. Mohammad Oct 28 '20 at 11:09
  • I don't have another idea, maybe sync project in android studio and try again. – B. Mohammad Oct 28 '20 at 11:18
  • No joy, even restarted my whole machine :( i dont understand why this builds and works on debug mod ebut not on release. ie ven tried to disable any proguard obfuscating – Jono Oct 28 '20 at 11:52
  • OK i have made progrss. i had to execute that code one level down and it worked. You mention i should delete androud/app/src/main/raw+drawable folders but there is none, i have app/src/main/res/raw and draables but that contains assets used in the app? – Jono Oct 28 '20 at 12:32
  • To be honest, i do that without understanding the why, but if i dont i get duplicate assets error. – B. Mohammad Oct 28 '20 at 13:06
  • OK thanks. after i had deleted the drawabel and raw folders, i executed the assembleRelease again andi got the same android resorce linking failed errors as before :( – Jono Oct 28 '20 at 13:32
  • are you using some custom fonts? try react-native link if so. Also try to build the apk using android studio – B. Mohammad Oct 28 '20 at 13:46