修改包名的步骤
- 选中 ‘Compact Middle Packages’,右击想要改的名字,‘Refactor->Rename’ 即可
- 修改 build.gradle(Module:app) 中的 applicationId(如果只需要修改apk的包名,只进行这一项就可以了)
遇到的问题
修改完applicationId 控制台出现如下问题
Some file crunching failed, see logs for details
点击如上Toggle View 按钮可以查看具体的问题出在哪里。
我出现的问题是在xml文件中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
xmlns:app=“http://schemas.android.com/apk/res-auto”
'res-auto’写的是以前的包名,这个位置在编译的时候会和applicationId进行对比,所以会报错,修改成res-auto就可以了