0

我在我的应用程序中有两个模块,一个用于API,一个用于应用程序。 在API模块I定义API是否已在debugrelease模式编译2 API端点取决于:错误的构建变体

buildTypes { 
    all { 
     buildConfigField "String", "API_DEVICE_TYPE", "\"android-phone\"" 
    } 

    debug { 
     buildConfigField "String", "API_ENDPOINT", "\"https://beta-api.company.com/\"" 
    } 

    release { 
     buildConfigField "String", "API_ENDPOINT", "\"https://api.company.com/\"" 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

在Android Studio中的Build variant面板I选择用于两个应用程序和API模块调试变体。但是当我按下play/clean/rebuild /手动删除所有编译目录/ resync gradle时,无论我做什么,都是每次都编译的release API。

任何提示?

尝试使用gradle构建工具2.1.02.2.0-aplha3

回答

1

只是在你的子模块中添加此代码的build.gradle

// There is a limitation in gradle: You can't pick what submodule of app you want to compile your app with. 
// This attribut define which build variant you want your api to be compiled against. 
// https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Library-Publication 
defaultPublishConfig "debug"