[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null
Opened this issue Β· 23 comments
What happened?
App is not starting up, on every start its showing the issue - [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.. I have done everything, gradlew clean & gradlew build, --reset-cache thing, deleting nodemodulles and reinstalling the npm dependecies., Delete .gradle folder.
Package.json is as :
`.{ "name": "goplugsmart", "version": "0.0.1", "private": true, "script": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@aws-amplify/analytics": "^7.0.86", "@aws-amplify/api": "^4.0.2", "@aws-amplify/auth": "^4.6.14", "@aws-amplify/core": "^6.1.0", "@aws-amplify/react-native": "^1.1.0", "@aws-amplify/storage": "^4.5.14", "@react-native-async-storage/async-storage": "^2.2.0", "@react-native-community/datetimepicker": "6.7.4", "@react-native-community/netinfo": "7.1.3", "@react-navigation/native": "^6.1.6", "@react-navigation/native-stack": "^6.9.12", "aws-amplify": "^4.3.42", "axios": "^1.6.2", "react": "^18.2.0", "react-native": "^0.72.17", "react-native-geolocation-service": "^5.3.1", "react-native-get-random-values": "^1.10.0", "react-native-maps": "1.11.3", "react-native-modal": "^13.0.1", "react-native-modal-datetime-picker": "^18.0.0", "react-native-safe-area-context": "^4.7.4", "react-native-screens": "^3.29.0", "react-native-svg": "^13.9.0", "react-native-vector-icons": "^10.0.3", "uuid": "^9.0.1" }, "devDependencies": { "@babel/core": "^7.23.0", "@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/plugin-proposal-private-methods": "^7.18.6", "@babel/plugin-transform-flow-strip-types": "^7.23.0", "@babel/plugin-transform-runtime": "^7.23.0", "@babel/runtime": "^7.23.0", "@react-native-community/cli": "^11.3.6", "@react-native-community/cli-platform-android": "^11.3.6", "@react-native/metro-config": "0.72.11", "@types/jest": "^29.5.1", "@types/react": "^18.2.21", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "eslint": "^8.49.0", "jest": "^29.6.3", "metro-react-native-babel-preset": "0.76.8", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "prettier": "2.8.8", "react-test-renderer": "18.2.0", "typescript": "5.2.2" }, "engines": { "node": ">=16" }, "jest": { "preset": "react-native" } }
Version
2.2.0
What platforms are you seeing this issue on?
- Android
- iOS
- macOS
- Windows
- web
System Information
npx react-native info
info Fetching system and libraries information...
System:
OS: Windows 11 10.0.22631
CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
Memory: 2.59 GB / 15.73 GB
Binaries:
Node:
version: 22.17.1
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.22
path: ~\AppData\Roaming\npm\yarn.CMD
npm:
version: 10.9.2
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: AI-251.25410.109.2511.13752376
Visual Studio: Not Found
Languages:
Java:
version: 17.0.12
path: /c/Program Files/Common Files/Oracle/Java/javapath/javac
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 11.4.1
wanted: ^11.3.6
react:
installed: 18.2.0
wanted: ^18.2.0
react-native:
installed: 0.72.17
wanted: ^0.72.17
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: false
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Steps to Reproduce
Clean Build and start the app.
anyone looking at this ??
Package.json -
{
"name": "goplugsmart",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@aws-amplify/analytics": "^7.0.86",
"@aws-amplify/api": "^4.0.2",
"@aws-amplify/auth": "^4.6.14",
"@aws-amplify/core": "^6.1.0",
"@aws-amplify/react-native": "^1.1.0",
"@aws-amplify/storage": "^4.5.14",
"@react-native-async-storage/async-storage": "^2.2.0",
"@react-native-community/datetimepicker": "6.7.4",
"@react-native-community/netinfo": "7.1.3",
"@react-navigation/native": "^6.1.6",
"@react-navigation/native-stack": "^6.9.12",
"aws-amplify": "^4.3.42",
"axios": "^1.6.2",
"react": "^18.2.0",
"react-native": "^0.72.17",
"react-native-geolocation-service": "^5.3.1",
"react-native-get-random-values": "^1.10.0",
"react-native-maps": "1.11.3",
"react-native-modal": "^13.0.1",
"react-native-modal-datetime-picker": "^18.0.0",
"react-native-safe-area-context": "^4.7.4",
"react-native-screens": "^3.29.0",
"react-native-svg": "^13.9.0",
"react-native-vector-icons": "^10.0.3",
"uuid": "^9.0.1"
},
"devDependencies": {
"@babel/core": "^7.23.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-transform-flow-strip-types": "^7.23.0",
"@babel/plugin-transform-runtime": "^7.23.0",
"@babel/runtime": "^7.23.0",
"@react-native-community/cli": "^11.3.6",
"@react-native-community/cli-platform-android": "^11.3.6",
"@react-native/metro-config": "0.72.11",
"@types/jest": "^29.5.1",
"@types/react": "^18.2.21",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"eslint": "^8.49.0",
"jest": "^29.6.3",
"metro-react-native-babel-preset": "0.76.8",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0",
"prettier": "2.8.8",
"react-test-renderer": "18.2.0",
"typescript": "5.2.2"
},
"engines": {
"node": ">=16"
},
"jest": {
"preset": "react-native"
}
}
App - Build.gradle -
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "kotlin-kapt"
def enableProguardInReleaseBuilds = false
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
android {
namespace "com.goplugsmart"
compileSdkVersion 33
project.ext.vectoricons = [
iconFontNames: ['MaterialIcons.ttf', 'FontAwesome.ttf']
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
defaultConfig {
applicationId "com.goplugsmart"
minSdkVersion 24
targetSdkVersion 33
versionCode 1
versionName "1.0"
manifestPlaceholders = [
GOOGLE_MAPS_API_KEY: localProperties.getProperty('GOOGLE_MAPS_API_KEY', '')
]
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
buildConfigField "boolean", "IS_HERMES_ENABLED", isHermesEnabled().toString()
}
buildFeatures {
buildConfig true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
// Add release signingConfigs for production if required
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
packagingOptions {
pickFirst '**/libc++_shared.so'
pickFirst '**/libreactnativejni.so'
pickFirst '**/libreactnativeutilsjni.so'
pickFirst '**/libreact_featureflagsjni.so'
}
ndkVersion "21.4.7075529"
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:hermes-android")
// Add specific version for react-native
// implementation("com.facebook.react:react-native:0.72.6") // Dont use this
//For React Native 0.71+, the correct artifact for Android is react-android, NOT react-native.
//Any reference to com.facebook.react:react-native:0.72.6 in your Gradle files or dependencies will fail!
implementation 'com.facebook.react:react-android'// This is correct for RN 0.71+
// Add these if you're using the new architecture
if (isNewArchitectureEnabled()) {
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:hermes-android")
}
// Force all React Native modules to use the same version
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:0.72.6"
force "com.facebook.react:react-android:0.72.6"
force "com.facebook.react:hermes-android:0.72.6"
force "com.facebook.react:hermes-engine:0.72.6"
}
}
implementation "androidx.annotation:annotation:1.2.0"
implementation "androidx.appcompat:appcompat:1.4.1"
implementation "androidx.core:core-ktx:1.7.0"
implementation "com.google.android.gms:play-services-maps:18.1.0"
implementation "com.google.android.gms:play-services-location:21.0.1"
implementation "com.google.maps.android:android-maps-utils:2.2.3"
implementation "com.google.android.libraries.places:places:2.5.0"
implementation 'com.facebook.soloader:soloader:0.10.4+'
implementation 'androidx.multidex:multidex:2.0.1'
}
//apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
//applyNativeModulesAppBuildGradle(project)
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = '11'
}
}
def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}
def isHermesEnabled() {
def hermesEnabled = false
if (project.hasProperty('hermesEnabled')) {
hermesEnabled = project.properties['hermesEnabled'] == 'true'
}
return hermesEnabled
}
Android Build.gradle -
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
}
}
plugins {
id("com.android.application") version "8.3.1" apply false
id("com.android.library") version "8.3.1" apply false
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
}
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
// Remove this override in 0.65+, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
}
Settings.gradle -
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// React Native (local maven)
maven { url("$rootDir/../node_modules/react-native/android") }
maven { url("$rootDir/../node_modules/jsc-android/dist") }
// If using hermes, keep this
maven { url("$rootDir/../node_modules/hermes-engine/android/") }
}
}
rootProject.name = "goplugsmart"
include(":app")
MainApplication.kt -
package com.goplugsmart
import android.app.Application
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.soloader.SoLoader
class MainApplication : Application(), ReactApplication {
private val mReactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getUseDeveloperSupport(): Boolean {
return BuildConfig.DEBUG
}
// π RN 0.72+ autolinking handles packages, so return emptyList()
override fun getPackages(): List<ReactPackage> {
return emptyList()
}
override fun getJSMainModuleName(): String {
return "index"
}
override val isNewArchEnabled: Boolean
get() = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean
get() = BuildConfig.IS_HERMES_ENABLED
}
override fun getReactNativeHost(): ReactNativeHost {
return mReactNativeHost
}
override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
load()
}
}
}
I just ran into this issue as well.
Everything worked for me yesterday, but today i was getting this error. I was switching branches between that (which had a few different packages, i just added AsyncStorage to this branch).
I tried gradle clean, reinstalling node modules and clearing some other caches, but nothing worked.
I then just deleted the entire repository and made a fresh pull and now it works again.
where are you using async store ?
i am using this for my expo react native project. after i upgrade from expo 53 -> 54
react-native from 0.79 -> 0.81
Having the same issue after upgrading expo 53 -> 54 and react-native 0.79 -> 0.81
Having the same issue, but I started my project with expo 54
I am facing exact same issue.
Mine is cli
"react-native": "0.80.2". It was initially 0.81 and I had downgraded it to 0.80.2
Any updates or solution please?
I have same issue upgrading react native from 0.78.2 yo 0.81.0. I have this in my package.
% npm ls @react-native-async-storage/async-storage
multiriesgoapp@0.0.1 /Users/iarteta/Desktop/multiriesgoapp
βββ @react-native-async-storage/async-storage@2.2.0
βββ¬ @react-native-firebase/messaging@23.4.1
βββ¬ @react-native-firebase/app@23.4.1
βββ¬ firebase@12.4.0
βββ¬ @firebase/auth-compat@0.6.0
β βββ¬ @firebase/auth@1.11.0
β βββ @react-native-async-storage/async-storage@1.24.0
βββ¬ @firebase/auth@1.11.0
βββ @react-native-async-storage/async-storage@1.24.0
But I have the same in my older app and it works. Maybe itΒ΄s a bug with firebase? Anyone has same issue with firebase in project?
I have tried to downgrade the async storage to "@react-native-async-storage/async-storage": "^1.19.1"
This is working in my simulator.
Do you have firebase in your project? it doesnΒ΄t work to me
In my case, I just ran the build again and it worked again. I believe there's a bug in the build. You can try deleting the modules folder and reinstalling it, then running the build again.
eas build --platform android --profile development
I tried this a lot of times and never works. I deleted node_modules and app build and doesnΒ΄t works. My issue is only in iPhone with every iOS version.
Hey! I was getting the same error a moment ago, I resolved it. Hopefully this work for you guys too in your app:
Cleaning dev build and dependecies:
- expo clean
- pnpm/npm exec expo clean
- rm -rf .expo && rm -rf build
- rm -rf android/build && rm -rf node_modules/.cache
Re-installing & running android:
- npm/pnpm install
- npm/pnpm run clean:android
Doing this, fixed it for me. Best of luck!
It doesnΒ΄t works for me because i donΒ΄t use expo, I use react Native CLI and my problem is only on iOS. Thanks anyway :)
@ivanarteta can you reproduce it in new project?
Quick scaffold
npx @react-native-community/cli@latest init AwesomeProject
yarn add @react-native-async-storage/async-storage
bundle install
bundle exec pod install --project-directory=ios
yarn ios
@krizzu I tried and it works. I think my problems is Firebase. I use Firebase to send push notifications to users and the dependencies install another version of async-storage. I have this in my package:
project@0.0.1 /Users/iarteta/Desktop/project
βββ @react-native-async-storage/async-storage@2.2.0
βββ¬ @react-native-firebase/messaging@23.4.1
βββ¬ @react-native-firebase/app@23.4.1
βββ¬ firebase@12.4.0
βββ¬ @firebase/auth-compat@0.6.0
β βββ¬ @firebase/auth@1.11.0
β βββ @react-native-async-storage/async-storage@1.24.0
βββ¬ @firebase/auth@1.11.0
βββ @react-native-async-storage/async-storage@1.24.0
This version of Firebase is the latest version. Do you know another alternative to send push notifications in my App?
Thanks for all.
@ivanarteta Have u tried using resolution to use single version of Async Storage?
Try adding this to your package.json:
"resolutions": {
"@react-native-async-storage/async-storage": "2.2.0"
}
@krizzu IΒ΄ve tried and it's the same. I've seen that Firebase have some dependencies that always install that version even if I set the resolutions.
Someone has this problem using firebase in project?