How to change the Android app package name when assembling with Gradle?

前端 未结 5 1141

Is it possible to change the package name of an Android application using Gradle?

I need to compile two copies of the same app, having a unique package name (so I c

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 01:50

    I did not want to use Flavors, so I found a way to do so with buildTypes. I did this by changing my app/build.gradle file as follows:

    defaultConfig {
            applicationId "com" // See buildTypes.type.applicationIdSuffix
            ...
        }
    
        ...
    
        buildTypes {
            debug {
                applicationIdSuffix ".domain.name.debug"
                ...
            }
            releaseStaging {
                applicationIdSuffix ".compagny.staging"
                ...
            }
            release {
                applicationIdSuffix ".domain.name"
                ...
            }
        }
    

    This allows me to have 3 apps next to each other on my devices.

    I hope this helps others.

提交回复
热议问题