20300.编码积累

Google真坑爹!Android Studio中gradle配

2015-08-11  本文已影响1384人  slimhippo

在开发的时候遇到服务器配置的问题,想在测试环境和开发环境中配置两套不同的服务器参数,于是想到在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一查,原来这是已知bug,并且过了好久都没见修复。。。。

详情见这个链接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

上一篇 下一篇

猜你喜欢

热点阅读