加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

React-Native修改应用名称(Android)

发布时间:2020-12-15 06:35:04 所属栏目:百科 来源:网络整理
导读:最近在使用React-Native进行开发,总结了一下修改Android项目名称的步骤(不是修改包名!),供自己参考: (1)到android/app/src/main/res/values/strings.xml目录下,找到app_name,把它修改为我们想设置的名称: resources string name = "app_name" 名

最近在使用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:worklotteryMobileRNLotteryRNandroidappb uildintermediatesincrementalmergeDebugResourcesmerged.dirvalues * 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

这个时候发现我们的Android应用的名称已经修改了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读