skip to Main Content

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

2

Answers


  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
        </>)
            }
    
    Login or Signup to reply.
  2. 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 />;
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search