Issue
When building apk with ./gradlew assembleRelease
under Android for React Native 0.70.1/gradle 7.3.3/7.4.2/7.5.1/Android Studio 2021.3.1/macOS Monterey, it failed with error. The app runs fine (npx react-native run-android
) on Android simulator:
> Task :rn-alioss:verifyReleaseResources FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':rn-alioss:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
> Android resource linking failed
ERROR:/Users/macair/Documents/code/js/xyz_app6/node_modules/rn-alioss/android/build/intermediates/merged_res/release/values/values.xml:2723: AAPT: error: resource android:attr/lStar not found.
Here is the portion in values.xml mentioned in the error:
<declare-styleable name="ColorStateListItem">
<attr name="android:color"/>
<attr format="float" name="alpha"/>
<attr name="android:alpha"/>
<attr format="float" name="lStar"/>
<attr name="android:lStar"/>. //<<==line# 2723 mentioned in error above
</declare-styleable>
It is a common error related to gradle but solutions posted were not working in my case. What I did was to downgrade gradle from 7.5.1 to 7.4.2 with:
./gradlew wrapper --gradle-version 7.4.2 --distribution-type=all
Then downgrade to 7.3.3
and the error remains the same. Deleting android/.gradle
and ./gradlew clean
didn’t help. Adding org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m ,,,,
to /android/gradle.properties causing error of MaxPerSize unrecognized
.
Solution
This feature "android:lStar"
requires compileSdk 31.
So one possible solution is upgrade the compileSdkVersion to 31.
If you do not want this, maybe your project or some dependencies has androidx.core:core-ktx:+
, which dosno‘t limit the version or has 1.7
and above. So change it in your build.gradle :
configurations.all {
resolutionStrategy {
force 'androidx.core:core:1.6.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
Hope this can help you!
Answered By – 木大白易
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0