美文网首页20300.编码积累
Google真坑爹!Android Studio中gradle配

Google真坑爹!Android Studio中gradle配

作者: slimhippo | 来源:发表于2015-08-11 17:09 被阅读1384次

    在开发的时候遇到服务器配置的问题,想在测试环境和开发环境中配置两套不同的服务器参数,于是想到在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

    相关文章

      网友评论

        本文标题:Google真坑爹!Android Studio中gradle配

        本文链接:https://www.haomeiwen.com/subject/okpiqttx.html