Is there a way to dynamically change the package of the generated file .BuildConfig?
I want to use build.gradle
file to use the applicationId
and change the package name between different builds.
Thanks
Is there a way to dynamically change the package of the generated file .BuildConfig?
I want to use build.gradle
file to use the applicationId
and change the package name between different builds.
Thanks
I had also ApplicationId or Package declared in AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="xxx">
Replacing xxx
fixed my problem.
The applicationId field just changes the packagename in the manifest. All classes will be still in the original package.
Change code in: Build.gradle (module):
defaultConfig {
applicationId "com.xxxxx.yyyy" <-----!!!
minSdkVersion ?
targetSdkVersion ?
versionCode ?
versionName ?
multiDexEnabled true
}
After sync, APPLICATION_ID from BuildConfig has updated.
If you have problems with installation in emulator. Go to AVD Manager, and make STOP and Cold Boot Now.
If you want to change only for different builds, for example, release and debug, then add the following code to the build.gradle file:
buildTypes {
debug {
applicationIdSuffix '.dev'
}
}
And this gives us when building will change and in the BuildConfig file.
© 2022 - 2024 — McMap. All rights reserved.