Changing .BuildConfig package
Asked Answered
C

4

8

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

Carafe answered 14/12, 2015 at 17:49 Comment(2)
Btw what do you want to achieve?Dramatization
I am building an app with dynamic package name and need programatically to find the BuildConfiguration file. I don't want to use flavours with different package names, only the package of the generated file to be under the dynamic applicationId (or any other flags needed)Carafe
R
6

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.

Ruprecht answered 22/4, 2019 at 17:0 Comment(0)
D
2

The applicationId field just changes the packagename in the manifest. All classes will be still in the original package.

Dramatization answered 14/12, 2015 at 18:1 Comment(1)
I know. I want to change the package of the generated file. Any Idea how to do so?Carafe
S
1

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.

Slub answered 12/12, 2020 at 12:22 Comment(0)
A
0

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.

Altis answered 14/8 at 14:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.