1

in debug mode asyncstorage working perfectly fine but when build apk with this command

gradlew assembleRelease -x bundleReleaseJsAndAssets the apk build perfectly but i want to open it show me the error appstop in my phone

1

2

any help regarding this will be very appriciated

5
  • Can you try running the release apk after uninstalling the previously installed one? Commented Dec 9, 2022 at 14:52
  • yes I do but it still not working . but when I remove all the above code and simple run <navigation/> then the build apk work perfectly . Commented Dec 9, 2022 at 19:07
  • I'd recommend two things: 1. Instead of returning null, I'd say use a circular indicator 2. Try checking logcat logs Commented Dec 10, 2022 at 4:07
  • i try both but still dont work actually i want to run onboarding screen on first launch of the app thats why i use asyncstorage function here kindly tell me what can i do i stuck on this problem past two days Commented Dec 10, 2022 at 15:02
  • We can debug it together if you want Commented Dec 10, 2022 at 16:15

2 Answers 2

1
        Try this.
import AsyncStorage from '@react-native-async-storage/async-storage';

        export default function App() 
        {
         const [aldreadyLaunched, setaldreadyLaunched] = useState(true)
        useEffect(() => {
          AsyncStorage.getItem("alreadyLaunched").then((value) => {
            if (value == "false") {
              let parsedValue = JSON.parse(value)
              setaldreadyLaunched(parsedValue)
            }
        
          })  
        },[])
    return (<>
        display introductory screen when the already launched state is true and when the false display login or directly main screen
    </>)
        }
Sign up to request clarification or add additional context in comments.

Comments

1

Try this .....

 
 
 
 
  const [loading, setLoading] = useState(true);
  const [isFirstTimeLoad, setIsFirstTimeLoad] = useState(false);
 
 const checkForFirstTimeLoaded = async () => {
    const result = await AsyncStorage.getItem('isFirstTimeOpen');
    console.log('result:', result);
    if (result == null) {
      setIsFirstTimeLoad(true);
      setLoading(false);
    } else {
      setIsFirstTimeLoad(false);
      setLoading(false);
    }
  };
  
   if (loading)
    return (
      <View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
        <ActivityIndicator  size={'large'} color={'black'}/>
      </View>
    );
    
    
    if (isFirstTimeLoad)
    return (
      <NavigationContainer>
        <Stack.Navigator
          initialRouteName="OnboardingScreen"
          screenOptions={{
            headerShown: false,
            // header: () => <MainHeader />,
          }}>
          <Stack.Screen name="OnboardingScreen" component={OnBoardingScreen} />
          <Stack.Screen name="login" component={Login} />
          <Stack.Screen name="home" component={Home} />
          <Stack.Screen name="register" component={Register} />
          <Stack.Screen name="mobileverify" component={MobileVerify} />
          <Stack.Screen name="listscreen" component={ListData} />
        </Stack.Navigator>
      </NavigationContainer>
    );
    
    if (!isFirstTimeLoad) return <Login />;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.