您的位置:首页 > Web前端 > React

[置顶] React-Native修改应用名称(Android)

2018-02-03 10:46 387 查看
最近在使用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[/code] 
那么我们就要进行第二步了。

(2)进入android文件夹,执行一条命令,并且重新构建项目,相应步骤如下:

cd android
gradlew clean
cd ..
react-native run-android


这个时候发现我们的Android应用的名称已经修改了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: