question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After including Async Storage, react native build fails

See original GitHub issue

Current behavior

In react Native Project, before Async Storage, the build compiles successfully. After including the Async Storage, the react native build fails.

Expected behavior

With Async Storage, the React Native build should compile successfully.

Repro steps

Create a React native project With some basic View Rendering compile it, it should compile successfully Now, import Async Storage in the code & now the build should fail

Environment

  • Async Storage version: 1.9.0
  • React-Native version: 0.62.2
  • Platform tested: Android
  • Logs/Error that are relevant:

#####################

Build Error Logs

##################### D:\reactnative\MyTestApp>npm run android-windows

MyTestApp@0.0.1 android-windows D:\reactnative\MyTestApp react-native bundle --platform android --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android

             Welcome to React Native!
            Learn once, write anywhere

info Writing bundle output to:, android/app/src/main/assets/index.android.bundle info Done writing bundle output info Copying 12 asset files info Done copying assets info Running jetifier to migrate libraries to AndroidX. You can disable it using “–no-jetifier” flag. Jetifier found 1166 file(s) to forward-jetify. Using 4 workers… info Starting JS server… info Installing the app…

Task :app:mergeDexDebug FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use ‘–warning-mode all’ to show the individual deprecation warnings. See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings 155 actionable tasks: 7 executed, 148 up-to-date

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:mergeDexDebug’.

Could not resolve all files for configuration ‘:app:debugRuntimeClasspath’. Failed to transform full.jar (project :react-native-community_async-storage) to match attributes {artifactType=android-dex, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.api.attributes.VariantAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=16, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. Execution failed for DexingWithClasspathTransform: D:\reactnative\MyTestApp\node_modules@react-native-community\async-storage\android\build\intermediates\full_jar\debug\createFullJarDebug\full.jar. java.io.IOException: Unable to delete directory ‘D:\reactnative\MyTestApp\node_modules@react-native-community\async-storage\android\build.transforms\545d63fb41417ef2ad382f109bad4810’ Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory. - D:\reactnative\MyTestApp\node_modules@react-native-community\async-storage\android\build.transforms\545d63fb41417ef2ad382f109bad4810\full

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 11s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:mergeDexDebug’.

Could not resolve all files for configuration ‘:app:debugRuntimeClasspath’. Failed to transform full.jar (project :react-native-community_async-storage) to match attributes {artifactType=android-dex, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.api.attributes.VariantAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=16, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. Execution failed for DexingWithClasspathTransform: D:\reactnative\MyTestApp\node_modules@react-native-community\async-storage\android\build\intermediates\full_jar\debug\createFullJarDebug\full.jar. java.io.IOException: Unable to delete directory ‘D:\reactnative\MyTestApp\node_modules@react-native-community\async-storage\android\build.transforms\545d63fb41417ef2ad382f109bad4810’ Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory. - D:\reactnative\MyTestApp\node_modules@react-native-community\async-storage\android\build.transforms\545d63fb41417ef2ad382f109bad4810\full

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 11s

at makeError (D:\reactnative\MyTestApp\node_modules\execa\index.js:174:9)
at D:\reactnative\MyTestApp\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (D:\reactnative\MyTestApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (D:\reactnative\MyTestApp\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! MyTestApp@0.0.1 android-windows: react-native bundle --platform android --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the MyTestApp@0.0.1 android-windows script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\User\AppData\Roaming\npm-cache_logs\2020-04-20T23_41_00_595Z-debug.log

#####################

Cleanup Error Logs

##################### D:\reactnative\MyTestApp\android>gradlew.bat clean Starting a Gradle Daemon (subsequent builds will be faster)

Task :react-native-community_async-storage:clean FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:react-native-community_async-storage:clean’.

java.io.IOException: Unable to delete file ‘D:\reactnative\MyTestApp\node_modules@react-native-community\async-storage\android\build’

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use ‘–warning-mode all’ to show the individual deprecation warnings. See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 27s 2 actionable tasks: 2 executed

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
krizzucommented, Apr 21, 2020

Hi,

Enable multi-dex support in your project for app (in android/app/build.gradle):

android {
    defaultConfig {
        ...
+        multiDexEnabled true
    }
    ...
}
3reactions
krizzucommented, Apr 21, 2020

@dmrajiv You don’t have to link it manually if you’re working with RN 0.60+. First code would work if you’d actually call the function you’ve defined.

componentDidMount(){
  getData = async () => {
    // your code here
  };
+  getData();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

FAILURE: Build failed with an exception. · Issue #862 - GitHub
What went wrong: Execution failed for task ':@react-native-community_async-storage:compileDebugJavaWithJavac'. Compilation failed; see the ...
Read more >
Async Storage error when run react-native run-android
Open the AVD Manager and try to start your phone emulator with Cold Boot, then close all applications. Clean and compile your application...
Read more >
Troubleshooting | Async Storage - GitHub Pages
This error means that AsyncStorage was unable to find its native module. This occurs because AsyncStorage was not linked into the final app...
Read more >
React Native Async Storage - npm
React Native Async Storage. An asynchronous, unencrypted, persistent, key-value storage system for React Native.
Read more >
AsyncStorage · React Native
It is recommended that you use an abstraction on top of AsyncStorage instead of AsyncStorage directly for anything more than light usage since...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found