Android開発と本番の共存
最近アプリをリリースして、Gradleでリリース環境と本番環境を分ける作業をしたのでメモ
1.パッケージ名を変える
buildTypes { debug { debuggable true applicationIdSuffix = 'debug' // パッケージ名に .debug をつける } release { minifyEnabled true proguardFile getDefaultProguardFile('proguard-android-optimize.txt') proguardFile file('proguard-project.txt') } }
applicationIdSuffix = 'debug'
applicationIdSuffix を指定すると、本番アプリの開発中のアプリを共存できる。
2.アプリ名を変える
debugフォルダを作成し、そこにAndroidManifest.xmlをコピーする。
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.app.test"> <application android:allowBackup="true" tools:replace="label" tools:replace="icon" android:name=".Util.test" android:icon="@mipmap/ic_launcher_dev" android:label="@string/app_name_dev" > <activity android:name=".MainActivity" tools:replace="label" android:label="@string/app_name_dev" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- 追加 --> </application> </manifest>
xmlns:tools="http://schemas.android.com/tools"を宣言してあげて、
tools.replaceで変えたいところをしているすると変わります。