Changing only Application ID, not package name

2019-06-26 03:17发布

I only want to change application id in gradle file, but dont want to change package name.
Is it possible?

3条回答
Lonely孤独者°
2楼-- · 2019-06-26 03:53

No problem. You can change your application Id as long as your app is not on store. If you change your application id, It would immediately become a different app for google play.

I have many apps with different package name and application ids.

查看更多
放我归山
3楼-- · 2019-06-26 04:00

Yes you can change androidId in defaultConfig.

    android {
        compileSdkVersion 27
        buildToolsVersion '27.0.3'

        defaultConfig {
            applicationId "com.somepkg" // <- we can change applicationId in defaultConfig
            minSdkVersion 21
            targetSdkVersion 26

            vectorDrawables.useSupportLibrary = true
            ....
        }
}

Also we can change applicationId in flavors use suffix or override it:

flavorDimensions "app"
productFlavors {
        qa {
            dimension "app"
            applicationIdSuffix = ".qa" // <- add suffix (it will be )
        }
        production {
            applicationId = "com.someotherpkg" // <- we can change applicationId in flavors
            dimension "app"
        }
}

However your src files will be still in the same folders.

查看更多
一夜七次
4楼-- · 2019-06-26 04:16

It is not recommended to change your application id. What you can do is change your application suffix.

As an example, if your application id is com.example.my_app then add different suffixes for different build types, such as com.example.myapp.dev for debug.

Go to app/build.gradle file and on android block add the suffix you want:

buildTypes {
        release {
            applicationIdSuffix ".production"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            applicationIdSuffix ".dev"
            versionNameSuffix '-DEBUG'
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

Read more about it here

查看更多
登录 后发表回答