Googleは本当にお父さんですね.Android Studioでgradle構成されているライブラリlibraryではreleaseパラメータしか使用できません

1248 ワード

開発時にサーバ構成の問題に遭遇し、テスト環境と開発環境で2つの異なるサーバパラメータを構成したいと考え、gradleでbuildConfigFieldを使用して構成し、libraryで読み取る
debug {
            debuggable true
            signingConfig signingConfigs.release
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "SERVER_CONFIG", "\"apptest.properties\""

        }
        release {
            signingConfig signingConfigs.debug
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "SERVER_CONFIG", "\"app.properties\""
        }

しかし、いずれにしてもデバッグ中にSERVER_に読み込まれます.CONFIGの値はreleaseの値です.stackoverflowで調べてみると、これは既知のバグで、長い間修復されていませんでした...
詳細はこのリンクを参照
This is expected behavior for this. Library projects only publish their release variants for consumption by other projects or modules. We're working at fixing this but this is non trivial and requires a significant amount of work. You can track the issue at https://code.google.com/p/android/issues/detail?id=52962