Async-storage: Unable to build assemble releas on android react native 0.60.5

Created on 23 Sep 2019  ·  16Comments  ·  Source: react-native-async-storage/async-storage

Current behavior

There is the following error when building ./gradlew assembleRelease

Expected behavior

it build without error

Repro steps

  1. ./gradlew assembleRelease

Environment

  • Async Storage version: "^1.6.1"
  • React-Native version: "0.60.5"
  • Platform tested: Android
  • Logs/Error that are relevant:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':@react-native-community_async-storage:verifyReleaseResources'.
> 1 exception was raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  D:\confidential-project\node_modules\@react-native-community\async-storage\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  D:\confidential-project\node_modules\@react-native-community\async-storage\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  D:\confidential-project\node_modules\@react-native-community\async-storage\android\build\intermediates\res\merged\release\values\values.xml:2737: error: resource android:attr/fontVariationSettings not found.
  D:\confidential-project\node_modules\@react-native-community\async-storage\android\build\intermediates\res\merged\release\values\values.xml:2738: error: resource android:attr/ttcIndex not found.
  error: failed linking references.

Most helpful comment

@SimonPotier This is the main problem - the Gradle does know where to find Android SDK.
Normally, this path is included in local.properties and looks something like this:

ndk.dir=/Users/<YourUserName>/Library/Android/sdk/ndk-bundle
sdk.dir=/Users/<YourUserName>/Library/Android/

Try finding your Android SDK path and adding it to the local.properties.

All 16 comments

What's your targetSdkVersion in app/build.gradle ?

Exact same error doing ./gradlew assembleRelease using Async Storage version: 1.6.2 and React-Native version: 0.60.5.

targetSdkVersion version:
Code 1
versionName "1.0"

@SimonPotier I'd need to know the targetSdkVersion from android block in app/build.gradle

@Krizzu Sorry, I believe this are what you need:

buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"

The above error is happening whenever i'm trying to ./gradlew assembleRelease or even to just launch the android version on my emulator with react-native run-android (using xCode simulator on macOs), react-native run-ios command is running fine.

Im using react-native version 0.60.5 and everything seems to be linked correctly when im following the steps on the Android section from this page: https://github.com/react-native-community/async-storage/blob/LEGACY/docs/Linking.md

@SimonPotier Have you tried cleaning the project (remove node_modules and in android directory, run ./gradlew clean)?

@Krizzu I'm not sure what you want me to remove (I think there is a typo in your last comment), but I tried to delete the node_modules folder, then yarn install a fresh one and then ./gradlew clean build inside the android directory resulted in the same error: A problem occurred configuring project ':@react-native-community_async-storage'.

Yeah, made a typo.
Do you have a repo that I could look into?

Unfortunatly our repo is private, I tried to create a Snack Expo but I figured out that they only support react-native until 0.59.10... I'll try to play around with the async-storage versions this week-end to see if there is any change. I'll also try to create a new project and export it.

@SimonPotier Heads up - this module won't work with Expo as you can't extend its native module list.

@Krizzu Hello, I just created a brand new test project and linked it to a public repository here https://github.com/SimonPotier/rn-async-storage-test

What I did in order was:

  • react-native init projectName
  • yarn add @react-native-community/async-storage
  • cd ios + pod install
  • react-native run-ios <- This build correctly and im able to use asyncStorage in App.
  • react-native run-android <- This throw the error.

Please feel free to experiment with the public repo.
Have a good day.

@SimonPotier Just cloned the repo, installed dependencies and ran react-native run-android successfully.

What error message you receive?

react-native run-android calls globally installed CLi. Can you check what version you use with react-native -v ?

Does the issue happens when you run CLI from your modules: yarn react-native run-android?

Miss click and closed the issue 🤦‍♂️

@Krizzu
react-native-cli: 2.0.1
react-native: 0.61.2 (on the new project created for test reproduction, but on my real project i'm on react-native: 0.60.5)

Tried yarn react-native run-android and the error message is the same that without the yarn, managed to have more details on this one:

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':@react-native-community_async-storage'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '<myfolderspath>/AsyncStorageTest/android/local.properties'.

Im not understanding this error neither do I have a local.properties file in my android folder. Do you have any idea on how to resolve this ?

@SimonPotier This is the main problem - the Gradle does know where to find Android SDK.
Normally, this path is included in local.properties and looks something like this:

ndk.dir=/Users/<YourUserName>/Library/Android/sdk/ndk-bundle
sdk.dir=/Users/<YourUserName>/Library/Android/

Try finding your Android SDK path and adding it to the local.properties.

same problem here, both commands: bundleRelease and assembleRelease
image

Infos:

System:
    OS: macOS Mojave 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 528.58 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 8.12.0 - /usr/local/bin/node
    Yarn: 1.17.3 - ~/.yarn/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 23.0.2, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.2, 28.0.3
      System Images: android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

async-storage v1.6.2

@rodrigowpl In that case, you have to enable dex build for you app

@Krizzu Thanks, the issue for me was that the Android SDK wasn't even installed on my machine, I installed it using Android Studio. The build works fine now, thanks again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muhammadn picture muhammadn  ·  58Comments

dominiczaq picture dominiczaq  ·  22Comments

Krizzu picture Krizzu  ·  36Comments

santhanakrishnanstark picture santhanakrishnanstark  ·  67Comments

sumanthyedoti picture sumanthyedoti  ·  25Comments