Rename パッケージ名変更
【パッケージ名変更方法】
AndroidManifest.xmlのパッケージ名を変更します。 今回はソースレベルで変更しました。
manifestのpackageと、activityのandroid:name部分も変更する必要があります。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<manifest xmlns:android= "<a href=" http: //schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>" package = "com.psakura.hello" //変更部分 android:versionCode= "1" android:versionName= "1.0.0" android:installLocation= "auto" > // 省略 <activity android:name= "com.psakura.hello.HELLO" //変更部分 android:label= "@string/app_name" android:theme= "@style/app_theme" android:screenOrientation= "portrait" android:configChanges= "keyboardHidden|orientation" > |
AndroidManifest.xmlを変更し保存するとメッセージが出てきます。
—
The package definition in the manifest changed.
Do you want to update your Launch Configuration(s)?
—
「Yes」サー!
するとsrcの旧パッケージ名にxマークが出ます。
srcの旧パッケージ名を右クリック→Refactor→Rename→新しいパッケージ名を入力します。
「Yes」サー!
—
Found problems Packege’旧パッケージ名’ already exists in this project in filder’gen’
—
というメッセージが出てきます。
「Continue」するサー!
するとgenの旧パッケージ名も自動的に変わっていました。
最後にproject名を右クリック→Refactor→Rename→project名を入力しました。
【アプリ名変更方法】
次にアプリ名の変更です。
これは簡単で res→values→string.xmlの「app_name」を変更します。
例えば、英語と日本語などの複数の言語に対応させている場合は、
res→values-ja→string.xmlの「app_name」と他言語の変更も忘れてないよういしないといけません。