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.

Android debug build crashes after installing async-storage.

See original GitHub issue

Current behavior

I want to implement caching for my android app for which I would need async-storage to be installed. As shown in docs I have installed the package and implemented an example code given in docs. When I run react-native run-android the app builds successfully but it crashes on App launch. Although, I have asked for external read-write permission in my manifest file.

Expected behavior

The App should not crash work as described in the documentation

Repro steps

Installed the package and below is the code

` import React, { Component } from ‘react’; import { Text, View, TouchableOpacity, } from ‘react-native’; import AsyncStorage from ‘@react-native-async-storage/async-storage’; export default class Company extends Component{ constructor(props) { super(props);

	this.cacheCompany = this.cacheCompany.bind(this);
	this.getCache = this.getCache.bind(this);
}

async cacheCompany(){
	  try {
	    await AsyncStorage.setItem('company_name', 'My Company')
	  } catch (e) {
	    console.log(e);
	  }
}

async getCache(){
	try {
	    const value = await AsyncStorage.getItem('company_name')
	    if(value !== null) {
	      console.log(value);
	      return value;
	    }
	  } catch(e) {
	    console.log(e);
	  }

	  return "nothing found";
}

render(){
	this.cacheCompany();

	return(
		<View>
			<Text>Test Caching</Text>
			<Text>{this.getCache();}</Text>
		</View>
	);
}

}`

Environment

  • Platforms tested:

    • Android
    • iOS
    • macOS
    • Windows
  • AsyncStorage version: 1.13.2

  • Environment: System: OS: Linux 4.15 Ubuntu 18.04.4 LTS (Bionic Beaver) CPU: (4) x64 Intel® Core™ i3-2348M CPU @ 2.30GHz Memory: 1.04 GB / 7.61 GB Shell: 4.4.20 - /bin/bash Binaries: Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node Yarn: 1.22.4 - /usr/bin/yarn npm: 6.14.4 - ~/.nvm/versions/node/v12.18.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: Android SDK: API Levels: 26, 27, 28 Build Tools: 28.0.3 Android NDK: Not Found IDEs: Android Studio: Not Found Languages: Java: 1.8.0_265 - /usr/bin/javac Python: 2.7.17 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.2 => 0.63.2 npmGlobalPackages: react-native: Not Found

  • Logs/Errors that may be relevant: Below logs are from adb logcat from my device. 01-18 10:58:52.120 2581 2581 D Launcher.ItemClickHandler: onClick, tag = WorkspaceItemInfo(@9491b60id=113 type=APP container=desktop screen=1 cell(0,2) span(1,1) minSpan(1,1) rank=0 user=UserHandle{0} installStateType=-1 installSource=null component=ComponentInfo{com.CacheApp/com.CacheApp.SplashActivity}, update=false, limit=false, runtime=110000000, status=0 intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.CacheApp/.SplashActivity bnds=[48,730][294,1027] }) 01-18 10:58:52.120 2581 2674 D Launcher.FloatingIconView: getIconResult: supportsAdaptiveIcons: false, info: WorkspaceItemInfo(@9491b60id=113 type=APP container=desktop screen=1 cell(0,2) span(1,1) minSpan(1,1) rank=0 user=UserHandle{0} installStateType=-1 installSource=null component=ComponentInfo{com.CacheApp/com.CacheApp.SplashActivity}, update=false, limit=false, runtime=110000000, status=0 intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.CacheApp/.SplashActivity bnds=[48,730][294,1027] }), isFancyIcon: false, isFolderIcon: false 01-18 10:58:52.123 1390 3517 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.CacheApp/.SplashActivity bnds=[48,730][294,1027] mCallingUid=10075} from uid 10075 and from pid 2581 01-18 10:58:52.128 796 2976 D DispPerfService: get hint proc=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}}#0, idx=0 none 01-18 10:58:52.130 1390 3517 D PowerHalWrapper: <amsBoostResume> last:com.oppo.launcher, next:com.CacheApp 01-18 10:58:52.132 2581 2581 D Launcher.LauncherStatistics: onEvent. event:open_app info:{has_badge=no, packageName=com.CacheApp} 01-18 10:58:52.144 1390 1479 D WindowManager: Add to mViews: DecorView@35314f7[CacheApp], this = android.view.WindowManagerGlobal@ac95e02,pkg= com.CacheApp 01-18 10:58:52.145 1390 1479 D ViewRootImpl[CacheApp]: hardware acceleration = false , fakeHwAccelerated = true, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false 01-18 10:58:52.146 1390 1479 D OppoDisplayPolicy: com.CacheApp, no change cutoutMode: 0 01-18 10:58:52.146 796 2976 D DispPerfService: get hint proc=dda45cd Splash Screen com.CacheApp#0, idx=0 none 01-18 10:58:52.153 1390 1479 D OppoDisplayPolicy: com.CacheApp, no change cutoutMode: 0 01-18 10:58:52.155 796 2976 D DispPerfService: get hint proc=Splash Screen com.CacheApp#0, idx=0 none 01-18 10:58:52.155 796 2976 I BufferQueueConsumer: Splash Screen com.CacheApp#0 setConsumerName: Splash Screen com.CacheApp#0 01-18 10:58:52.155 796 2976 I BufferQueueConsumer: Splash Screen com.CacheApp#0 setDefaultBufferSize: width=1080 height=2400 01-18 10:58:52.158 1390 1520 I ActivityManager: Start proc 3093:com.CacheApp/u0a262 for activity {com.CacheApp/com.CacheApp.SplashActivity} 01-18 10:58:52.158 796 835 I BufferQueueProducer: Splash Screen com.CacheApp#0 connect(P): api=2 producer=(1390:system_server) producerControlledByApp=false 01-18 10:58:52.164 3093 3093 I com.CacheApp: Late-enabling -Xcheck:jni 01-18 10:58:52.165 796 835 D DispPerfService: onframeavailable pid=1390, slot=0, seq=161448, ret=0, name=system_server:Splash Screen com.CacheApp#0 01-18 10:58:52.178 3093 3093 E com.CacheApp: Unknown bits set in runtime_flags: 0x8000 01-18 10:58:52.194 1390 2663 I ColorAppSwitchManagerService: appswitch hasProcess ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971} 01-18 10:58:52.195 1390 2663 I ColorAppSwitchManagerService: appswitch hasProcess ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971} 01-18 10:58:52.195 1390 2663 I ColorZoomWindowManagerService: topResumedActivityChanged start r = ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971} 01-18 10:58:52.195 1390 2663 W ColorAccessControlManagerService: notifyZoomWindowExit: stack=ActivityStack{fcdc059 stackId=3999 type=standard mode=fullscreen visible=true translucent=false, 1 tasks} windowMode=1 topActivity=ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971} toFullScreen = true 01-18 10:58:52.197 1390 2663 D ScreenModeManager: setScreenFlushModeLocked token:AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}} mActivityName:com.CacheApp/.SplashActivity mPackageName:com.CacheApp spec:ScreenModeSpec: POWERSAVE 2caller:com.android.server.wm.WindowManagerService.setScreenFlushMode:8884 com.android.server.wm.ActivityTaskManagerService.setResumedActivityUncheckLocked:5817 com.android.server.wm.ActivityStack.onActivityStateChanged:631 com.android.server.wm.TaskRecord.onActivityStateChanged:1972 com.android.server.wm.ActivityRecord.setState:1987 01-18 10:58:52.198 1390 2663 I ScreenModeManager: post to setScreenFlushModeLocked for AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}} to mode=1 package com.CacheApp activity com.CacheApp/.SplashActivity 01-18 10:58:52.200 1168 1193 I DCS-BackgroundAppData: sendAppBgEvent: has no pkgName=com.CacheApp 01-18 10:58:52.201 1390 2663 D PowerHalWrapper: amsBoostNotify pid:3093,activity:com.CacheApp.SplashActivity, package:com.CacheApp, mProcessCreatePacknull 01-18 10:58:52.204 754 778 I libPowerHal: [perfNotifyAppState] foreground:com.CacheApp, pid:3093, uid:10262 01-18 10:58:52.204 754 778 I powerd : [powerd_req] POWER_MSG_NOTIFY_STATE, pc:0, com.oppo.launcher => com.CacheApp 01-18 10:58:52.207 796 835 D DispPerfService: get hint proc=Surface(name=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}})/@0x33be0ce - animation-leash#0, idx=0 none 01-18 10:58:52.212 1390 1478 D OppoOomAjusterHelper: TOP_APP is ProcessRecord{c51abef 3093:com.CacheApp/u0a262} uid is 10262 01-18 10:58:52.214 3093 3093 I com.CacheApp: The ClassLoaderContext is a special shared library. 01-18 10:58:52.214 3147 26379 E oiface : packageSwitch pkg com.CacheApp, enter 01-18 10:58:52.214 3147 26379 E oiface : current package is com.CacheApp 01-18 10:58:52.218 3147 3176 D oiface : forground package is com.CacheApp 01-18 10:58:52.236 1390 2642 D ColorAppListInterceptManager: shouldFilterTask::packageName = com.CacheApp 01-18 10:58:52.351 3093 3093 E AndroidRuntime: Process: com.CacheApp, PID: 3093 01-18 10:58:52.351 3093 3093 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application com.CacheApp.MainApplication: java.lang.ClassNotFoundException: Didn’t find class “com.CacheApp.MainApplication” on path: DexPathList[[zip file “/data/app/com.CacheApp-twoIBwGo6XXriswu7lWPrQ==/base.apk”],nativeLibraryDirectories=[/data/app/com.CacheApp-twoIBwGo6XXriswu7lWPrQ==/lib/arm64, /data/app/com.CacheApp-twoIBwGo6XXriswu7lWPrQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]] 01-18 10:58:52.351 3093 3093 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.CacheApp.MainApplication” on path: DexPathList[[zip file “/data/app/com.CacheApp-twoIBwGo6XXriswu7lWPrQ==/base.apk”],nativeLibraryDirectories=[/data/app/com.CacheApp-twoIBwGo6XXriswu7lWPrQ==/lib/arm64, /data/app/com.CacheApp-twoIBwGo6XXriswu7lWPrQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]] 01-18 10:58:52.357 1390 2642 W ActivityTaskManager: Force finishing activity com.CacheApp/.SplashActivity 01-18 10:58:52.363 1390 2642 D PowerHalWrapper: <amsBoostResume> last:com.CacheApp, next:com.oppo.launcher 01-18 10:58:52.381 1390 4789 V ActivityManager: Death received in com.android.server.am.ActivityManagerService$AppDeathRecipient@2b30dd0 for thread android.os.BinderProxy@35271c9, mPid:3093,mApp:ProcessRecord{c51abef 3093:com.CacheApp/u0a262} 01-18 10:58:52.381 1390 4789 I ActivityManager: Process com.CacheApp (pid 3093) has died: fore TOP 01-18 10:58:52.383 1168 1256 I DCS-BackgroundAppData: sendAppBgEvent: has no pkgName=com.CacheApp 01-18 10:58:52.393 754 778 I powerd : [powerd_req] POWER_MSG_NOTIFY_STATE, pc:0, com.CacheApp => com.oppo.launcher 01-18 10:58:52.397 1390 4789 V ColorZoomWindowManagerService: onAnimationFinished: r=ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t-1 f} 01-18 10:58:52.397 1390 4789 V ColorZoomWindowManagerService: onAnimationFinished: r=ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t-1 f} 01-18 10:58:52.399 1390 4789 V ColorZoomWindowManagerService: onAnimationFinished: r=ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t-1 f} 01-18 10:58:52.403 1390 3116 D ColorEapUtils: collectFile: com.CacheApp, cc58c8b4dfc8484b, data_app_crash 01-18 10:58:52.406 1390 1390 I OppoPhoneWindowManager: KeyLockModeReceiver KeyLockMode: 0 ProcessName: com.CacheApp 01-18 10:58:52.407 1390 1479 D View : [Warning] assignParent to null: this = DecorView@35314f7[CacheApp] 01-18 10:58:52.408 796 796 E Layer : [Surface(name=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}})/@0x33be0ce - animation-leash#0] No local sync point found 01-18 10:58:52.408 796 796 E Layer : [Surface(name=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}})/@0x33be0ce - animation-leash#0] No local sync point found 01-18 10:58:52.408 796 796 D SurfaceFlinger: Client::detachLayer this 0x7284a8fd80, layer sequence 161447 dda45cd Splash Screen com.CacheApp#0 01-18 10:58:52.408 796 796 D SurfaceFlinger: Client::detachLayer this 0x7288dc9640, layer sequence 161446 AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}}#0 01-18 10:58:52.411 796 1375 I BufferQueueProducer: Splash Screen com.CacheApp#0 disconnect(P): api 2 01-18 10:58:52.418 796 796 I BufferQueue: Splash Screen com.CacheApp#0 ~BufferQueueCore 01-18 10:58:52.418 796 796 D SurfaceFlinger: Client::detachLayer this 0x7284a8fd80, layer sequence 161448 Splash Screen com.CacheApp#0 01-18 10:58:52.419 796 796 E Layer : [Surface(name=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}})/@0x33be0ce - animation-leash#0] No local sync point found 01-18 10:58:52.429 796 796 E Layer : [Surface(name=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}})/@0x33be0ce - animation-leash#0] No local sync point found 01-18 10:58:52.440 796 796 E Layer : [Surface(name=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}})/@0x33be0ce - animation-leash#0] No local sync point found 01-18 10:58:52.451 796 796 E Layer : [Surface(name=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}})/@0x33be0ce - animation-leash#0] No local sync point found 01-18 10:58:52.462 796 796 E Layer : [Surface(name=AppWindowToken{6873ca0 token=Token{41971a3 ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t3971}}})/@0x33be0ce - animation-leash#0] No local sync point found 01-18 10:58:52.858 1390 1478 W ActivityTaskManager: Activity top resumed state loss timeout for ActivityRecord{e9d1cd2 u0 com.CacheApp/.SplashActivity t-1 f} 01-18 10:58:56.139 1390 3116 D ColorEapUtils: zipFile: /data/oppo/coloros/eap/cc58c8b4dfc8484b to /data/oppo/coloros/eap/com.CacheApp_1.0_data_app_crash@cc58c8b4dfc8484b@RMX2151PU_11.A.75_0750_202012182056@2021-01-18-10-58-56.zip 01-18 10:59:10.286 32444 3182 D OppoLFEHelper: writing file /data/oppo/coloros/eap/com.CacheApp_1.0_data_app_crash@004e28dc68fc472a@RMX2151PU_11.A.75_0750_202012182056@2021-01-18-10-58-30.zip 01-18 10:59:10.418 32444 3182 V OppoLFEHelper: encode file: /data/oppo/coloros/eap/com.CacheApp_1.0_data_app_crash@004e28dc68fc472a@RMX2151PU_11.A.75_0750_202012182056@2021-01-18-10-58-30.zip, spend time 132, srcFileSize 1782297, enCodeFileSize 1782297 01-18 10:59:10.437 32444 3182 D OppoLFEHelper: writing file /data/oppo/coloros/eap/com.CacheApp_1.0_data_app_crash@b6ddbd99bdb54f13@RMX2151PU_11.A.75_0750_202012182056@2021-01-18-10-58-35.zip 01-18 10:59:10.519 32444 3182 V OppoLFEHelper: encode file: /data/oppo/coloros/eap/com.CacheApp_1.0_data_app_crash@b6ddbd99bdb54f13@RMX2151PU_11.A.75_0750_202012182056@2021-01-18-10-58-35.zip, spend time 81, srcFileSize 1797615, enCodeFileSize 1797615 01-18 10:59:10.538 32444 3182 D OppoLFEHelper: writing file /data/oppo/coloros/eap/com.CacheApp_1.0_data_app_crash@cc58c8b4dfc8484b@RMX2151PU_11.A.75_0750_202012182056@2021-01-18-10-58-56.zip 01-18 10:59:10.621 32444 3182 V OppoLFEHelper: encode file: /data/oppo/coloros/eap/com.CacheApp_1.0_data_app_crash@cc58c8b4dfc8484b@RMX2151PU_11.A.75_0750_202012182056@2021-01-18-10-58-56.zip, spend time 82, srcFileSize 1788028, enCodeFileSize 1788028

Kindly let me know how to fix this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
CharlesPoullaincommented, Jan 20, 2021

Hey @Neel97

I just fix the same issus with a simple ./android/gradlew clean

0reactions
Flip437commented, Jan 25, 2022

Hey @neel97

I just fix the same issus with a simple ./android/gradlew clean

This worked for me ! Thanks a lot !

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native: AsyncStorage crashes Android app
Show activity on this post. I'm writing an App for Android and iOS using react-native. The iOS version works perfectly but the Android...
Read more >
expo app crashes, no dialog, can't debug : r/reactnative
Hi - I'm working on my first Android app using Expo and React Native and recently it started randomly crashing. There's no "Such...
Read more >
Troubleshooting build errors and crashes
A reference for troubleshooting build errors and crashes when using EAS Build. ... build/app/node_modules/@react-native-async-storage/async-storage/android/ ...
Read more >
React Native development tips
Tip #1: speed up android dev builds using --active-arch-only · Tip #2: debug your app with Flipper · Tip #3: don't forget your...
Read more >
Production: Capture & Analyze Native Crash Reports - YouTube
... crashes with Instabug and utilize the reports.FULL COURSE & CODE: https://reactnativeschool.com/ debugging -in-development-and-production.
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