最近在使用React-Native进行开发,总结了一下修改Android项目名称的步骤(不是修改包名!),供自己参考:
(1)到android/app/src/main/res/values/strings.xml目录下,找到app_name,把它修改为我们想设置的名称:
<resources>
<string name="app_name">名称</string>
</resources>
通常这一步就可以了,但是如果出现了错误,如下:
FAILURE: Build Failed with an exception.
* What went wrong: Execution Failed for task ':app:mergeDebugResources'. > Error: Cannot create directory D:\work\lotteryMobileRN\LotteryRN\android\app\b uild\intermediates\incremental\mergeDebugResources\merged.dir\values * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD Failed Total time: 14.789 secs Could not install the app on the device,read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html
那么我们就要进行第二步了。
(2)进入android文件夹,执行一条命令,并且重新构建项目,相应步骤如下:
cd android
gradlew clean
cd ..
react-native run-android
原文链接:https://www.f2er.com/react/301972.html