How to rebuild the entire Android folder?

后端 未结 8 2130
长发绾君心
长发绾君心 2021-01-31 17:44

I have messed the files up in the Android folder and would like to rebuild the Android project inside of the Android folder. How do I do this?

Is it safe to delete the

相关标签:
8条回答
  • 2021-01-31 18:05

    The solution if ur version of react-native >= 0.61.0 :

    1. sudo rm -rf android/ ios/

    2. yarn add react-native-eject

    3. npx react-native eject

    enjoy !

    0 讨论(0)
  • 2021-01-31 18:05

    Below command will create the android and ios folders.

    react-native eject
    
    0 讨论(0)
  • 2021-01-31 18:06

    Here my solution: (I'm doing this for android)

    First command:(Navigation to the Android folder of your react-native project)

    cd Android
    

    Second command:

    ./gradlew clean
    

    Third commmand:

    ./gradlew cleanBuildCache
    

    I'm not fan of deleting android folder. (I think this not a best approaches)

    To generate apk file for production: (First one from /Android)(second one from root project)

    ./gradlew bundleRelease
    react-native run-android --variant=release
    

    Happy coding!!!

    0 讨论(0)
  • 2021-01-31 18:10

    Funny solution here Create a new react native app and copy the new android folder over and then run $react-native run-android

    0 讨论(0)
  • 2021-01-31 18:11

    Running following commands should do the trick:

    sudo rm -rf android/ ios/ #Delete Android and ios folders first...
    react-native eject
    react-native upgrade //rebuilds android/ios folders
    react-native link
    react-native run-android
    react-native run-ios
    
    0 讨论(0)
  • 2021-01-31 18:11

    Yes, it is safe to delete the Android and IOS folder and you can make it again by following steps:

    1.First Method: react-native eject <=0.59.0

    React-native had this command in the previous version. Running this command will check if the ios and android directories exist and then rebuild whichever one is missing.

    sudo rm -rf android/ ios/

    react-native eject // Will create new Android and IOS folder.

    react-native link

    react-native run-android

    2.Second Method: react-native upgrade --legacy true>=0.60.0

    Now you should use the react-native upgrade --legacy true command to back up your android folders or ios as the case may be as this command will replace your files.

    0 讨论(0)
提交回复
热议问题