Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android app crashes without logs, adb logcat shows [Didn't find class "com.reactnativecommunity.asyncstorage.AsyncStoragePackage"] #848

Closed
1 of 5 tasks
raphaelmsr opened this issue Oct 5, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@raphaelmsr
Copy link

What happened?

On a fresh install, removed node_modules and played multiple times between yarn & npm; every build for Android crashes (runs fine on iOS)
Using Expo SDK 46 and the version 1.17.10 of the package (every previous version has the same bug)
I had to manually link the package as to what's written in the Manual Linking page in the API.
This should be completely automatic and somehow only this package has this issue.

Version

1.17.10

What platforms are you seeing this issue on?

  • Android
  • iOS
  • macOS
  • Windows
  • web

System Information

info Fetching system and libraries information...
System:
    OS: macOS 12.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 1.56 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.1.2 - /usr/local/bin/npm
    Watchman: 2022.08.08.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 14.0/14A309 - /usr/bin/xcodebuild
  Languages:
    Java: 15.0.2 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0 
    react-native: 0.69.6 => 0.69.6 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to Reproduce

Install "@react-native-async-storage/async-storage": "^1.17.10", call the package in App.js, run npx expo run:android

@raphaelmsr raphaelmsr added the bug Something isn't working label Oct 5, 2022
@krizzu
Copy link
Member

krizzu commented Oct 6, 2022

You should not have to use manual linking, as you cannot link any native code using expo.

It'd be also good to know what error you see, so we could help out. I see you posted that in issue's title.

I'd ask on Expo forum for help, seems like something that should be working out of the box

@raphaelmsr
Copy link
Author

raphaelmsr commented Oct 6, 2022

Expo does allow for native modules since Expo 44 I guess

The error is exactly whats written in the title, sorry about that
The error is Didn't find class "com.reactnativecommunity.asyncstorage.AsyncStoragePackage"

It looks like React Native 0.69 breaks lots of packages’ autolinking.

getsentry/sentry-react-native#2267

andpor/react-native-sqlite-storage#522

Dont know if related; but I have used AsyncStorage in the past, in Expo; and never had to manually link anything (EDIT : e.g. with other RN versions)

EDIT2 : Also, works on iOS out-of-the-box; just Android gives me a hard time when building

@krizzu
Copy link
Member

krizzu commented Oct 6, 2022

I just ran a quick test on RN 0.69.0 and I could install AsyncStorage and run the app successfully.
I'm not Expo user, so I can't really help in that manner. Have you tried setting up a new Expo project and seeing if the problem exists?

@raphaelmsr
Copy link
Author

raphaelmsr commented Oct 6, 2022

Here is a reproductive example; and it does crash the same way.

  1. npx create-expo-app my-app-async && cd my-app-async
  2. expo install @react-native-async-storage/async-storage
  3. Changing App.js to
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Button } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';

export default function App() {

  const storeData = async (value) => {
    try {
      await AsyncStorage.setItem('@storage_Key', value)
    } catch (e) {
      // saving error
    }
  }
  
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <Button onPress={()=>storeData("Test")} >TEST</Button>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});


  1. export ANDROID_SDK_ROOT="~/Library/Android/sdk"; npx expo run:android

Crashes without logs in the Debugger, only in adb logcat

I am not sure whether it is actually an Expo bug, I believe it is related to RN 0.69

EDIT : did you manually link ?

EDIT2 : removed node_modules and deleted the package from package.json and reinstalled everything, builds on android just fine - super weird

@krizzu
Copy link
Member

krizzu commented Oct 6, 2022

Thanks for the repro steps. I manage to get up and running, without manual linking. So all is good on my side.

I see that you got it working too, so that's good! Feel free to close the issue.

@raphaelmsr
Copy link
Author

No thats not what I meant haha
I removed the package then everything worked fine; but I need it!
I just double-checked in case something was wrong with my environment or with the Expo template; I checked without packages if it would build and run and it did

@krizzu
Copy link
Member

krizzu commented Oct 7, 2022

I ran the expo app with your steps just fine, so probably it's your dev env?

@raphaelmsr
Copy link
Author

Wow really ? Somehow I had to downgrade Expo version to SDK 45 it still didn't work, downgraded again to SDK 44 and now it works like it should
Thanks a million for trying to repro the steps; I'm glad it works actually. It means your package is fine
Although I have no idea how to debug my environment ... Haha

Thanks again, shall I close ?

@krizzu
Copy link
Member

krizzu commented Oct 7, 2022

Maybe try to clone your project again and then install everything? You can also try to do yarn cache clean to be sure that yarn will fetch packages again.

Yes, feel free to close

@krizzu krizzu closed this as completed Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants