Android gradle单独的res /文件夹构建

时间:2013-11-22 23:38:13

标签: android gradle android-gradle

我正在尝试按国家/地区生成apk,其中每个国家/地区特定的drawable将在其中 countrycode / res /

(现在有2个国家/地区,“我们”和“它”) 而公共资源只是简单地解析/

res/drawable/generic.png
res/drawable/specific.png
it/res/drawable/specific.png
us/res/drawable/specific.png

这是我的构建文件

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 15
    buildToolsVersion "18.1.0"

    flavorGroups "lang"

    productFlavors {
        it {
            flavorGroup "lang"
        }

        us {
            flavorGroup "lang"
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        it{
            res.srcDirs = ['it/res']
        }

        us{
            res.srcDirs = ['us/res']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }



    signingConfigs {

        release {
            storeFile file("signing/mykey.keystore")
            storePassword "******"
            keyAlias "myalias"
            keyPassword "******"
        }
    }

    buildTypes {
        debug {
            versionNameSuffix "-DEBUG"
            packageNameSuffix ".debug"
        }
        release {
            debuggable false
            signingConfig signingConfigs.release
        }
        debugRelease.initWith(buildTypes.release)
        debugRelease {
            debuggable true
            packageNameSuffix '.debugrelease'
            signingConfig signingConfigs.release
        }
   }



}

但它无法构建错误:java.lang.StackOverflowError 你能帮我设置这个版本吗?非常感谢

1 个答案:

答案 0 :(得分:0)

我终于成功了,这篇博文给了我很多帮助: http://apporia.blogspot.fr/2013/11/gradle-and-flavor-groups.html

stackOverflowError错误来自风味名称,我只是将“it”重命名为“italy”,将“us”重命名为“usa”,并且构建成功,我需要花费数小时来计算出来......