Is there an easy way to have a test version of an app and a release version installed on an android phone?

StackOverflow https://stackoverflow.com/questions/23574745

  •  19-07-2023
  •  | 
  •  

문제

Say I have a production version com.android.xyz and this is production then I am developing something and i want to load both this version and the production version on my phone so it's side by side. I know I can create a new package like com.android.abc and then I would have a second app which is basically a clone of com.android.xyz.

Thoughts?

Thanks in advance, Reid

도움이 되었습니까?

해결책

IF you are using Android Studio with Gradle, there is an easy way to do this. I still keep the the same packageName in AndroidManifest.xml (at least current gradle needs this duplicate definition)

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="internalOnly"
package="com.android.xyz">

build.gradle

def devBuildName = "dev"
def testBuildName = "test"

android {
defaultConfig {
    versionCode 70
    versionName "2.2.3"
    minSdkVersion 10
    targetSdkVersion 19
    packageName "com.android.xyz"
}

buildTypes {
    debug {
        packageNameSuffix "."+devBuildName
        versionNameSuffix "-"+devBuildName.toUpperCase()
    }

    test.initWith(buildTypes.debug)
    test {
        packageNameSuffix "."+testBuildName
        versionNameSuffix "-"+testBuildName.toUpperCase()
    }
}
}

You can look at my full dev/release example at github.

다른 팁

You need to change the package name. IMO the easiest way to do this is by writing a perl/python script to iterate through the files and change the package name based on the build type. Or run a C style macro preprocessor over the files first.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top