eunjae.lee
eunjae.lee

Reputation: 155

Configuring package names in layout xmls when using Gradle flavor feature

Let's say I've configured a product flavor configuration like the following:

android {
    ...

    defaultConfig {
        minSdkVersion 8
        versionCode 10
    }

    productFlavors {
        flavor1 {
            packageName "com.example.flavor1"
            versionCode 20
        }

        flavor2 {
            packageName "com.example.flavor2"
            minSdkVersion 14
        }
    }
}

However, I currently have customized views used in layout xmls like the following:

<com.example.flavor.customview.TitleBarView
    android:id="@+id/titlebar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/titlebar_height"
    android:layout_alignParentTop="true" />

What about that package name? Should I extract that package name to strings.xml? That doesn't sound pretty.

Does anyone know how to manage package names in xml when having different package names?

Thanks in advance.

Upvotes: 1

Views: 358

Answers (1)

Xavier Ducrohet
Xavier Ducrohet

Reputation: 28539

The package name that you override through the product flavor is only for the package name in the manifest (the one that uniquely identify your app on Android and the Play Store).

It has no impact on any of your classes, so you can keep using them normally.

Upvotes: 3

Related Questions