0

내 앱에 2 개의 모듈이 있습니다. 하나는 API 용이고 다른 하나는 앱용입니다. 이 API 모듈에서 나는 API가 debug 또는 release 모드로 컴파일 된 경우 2 API 엔드 포인트가 따라 정의 : 안드로이드 Studio의 Build variant 패널에서빌드 변형이 잘못되었습니다.

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' 
    } 
} 

나는 응용 프로그램 및 API 모듈 모두에 대한 디버그 변형을 선택했다. 하지만 play/clean/rebuild/remove/resync gradle을 사용하여 모든 빌드 디렉토리를 제거 할 때마다이 작업을 수행 할 때마다 매번 컴파일되는 릴리스 API가 필요합니다.

힌트가 있습니까?

그래 브 빌드 도구 2.1.02.2.0-aplha3으로 시도했습니다.

답변

1

그냥

// 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" 
build.gradle 당신의 서브 모듈에이 코드를 추가