设置buildConfigField的IS_PUBLIC无用 一个app,两个module,一个是application module,另外一个是library module; 在library中设置buildConfigField,如下
release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField("boolean", "IS_PUBLIC", "true") } debug{ buildConfigField("boolean", "IS_PUBLIC", "false") }用来控制http及debug在测试环境,和正式环境的不同; 然而,无论如何都只能得到IS_PUBLIC为false;
最后子stackoverflow上得到了解决 http://stackoverflow.com/questions/20176284/buildconfig-debug-always-false-when-building-library-projects-with-gradle
With Android Studio 1.1 and having also the gradle version at 1.1 it is possible:
Library
android { publishNonDefault true }App
dependencies { releaseCompile project(path: ':library', configuration: 'release') debugCompile project(path: ':library', configuration: 'debug') }亲测好用!