Android Gradle merge resource strings

I would like to create 2 different APKs (release and debugging) using Gradle, and I want to use different names for them ('appName' and 'appName debug').

I found several solutions, but for me this does not work:
link 1
link 2

I would like to install both apks on the device, but I have the following error:

 Duplicate resources: 
 ...\src\release\res\values\config.xml:string/config_app_name,
 ...\src\main\res\values\config.xml:string/config_app_name

If I remove the key config_app_namefrom main\res\values\config.xml, then Gradle says that the key was not found.

I have 3 manifest files:

...\src\main\AndroidManifest.xml (this uses the `android:label="@string/config_app_name"`)

...\src\release\AndroidManifest.xml

...\src\debug\AndroidManifest.xml

buildTypes {

    debug {
        packageNameSuffix ".debug"
        versionNameSuffix "-debug"
        buildConfig "public static final String PROVIDER_AUTHORITY = \"" + PROVIDER_DEBUG + "\";"
        signingConfig signingConfigs.debug
    }
    release {
        buildConfig "public static final String PROVIDER_AUTHORITY = \"" + PROVIDER_RELEASE + "\";"
        signingConfig signingConfigs.release
    }
}

sourceSets {
    debug {
        java.srcDirs = [
                'src/main/java']
        res.srcDirs = [
                'src/main/res',
                'src/debug/res']
    }

    release {
        java.srcDirs = [
                'src/main/java']
        res.srcDirs = [
                'src/main/res',
                'src/release/res']
    }
}

Is it possible to use one common key (strings, integers, sizes) in the main part of the project and override it in the release / debugging part?

Thanks in advance.

+4
2

, . . .

.

+1

: http://tools.android.com/tech-docs/new-build-system/resource-merging

. .

, . , .

sourceSets {

    main {
        java.srcDirs = ['src/main/java']
        res.srcDirs = ['src/debug/res']

    }

    debug {
        res.srcDirs = ['src/debug/res']
    }

    release {
        res.srcDirs = ['src/release/res']
    }
}

.

+1

All Articles