2015-07-13 173 views
1

我在調試構建類型中啓動應用程序時遇到問題。我有依賴於庫的應用程序,依賴於另一個庫。我將所有東西都切換到調試構建版本,與圖像相同。如何在調試版本變體中使用庫運行應用程序?

enter image description here

Problrem是庫內我有我想要在調試關閉,如洛和分析一些功能,但庫每次在發佈版本類型編譯。
在Gradle控制檯中,我看到應用程序在調試版本中編譯,但它依賴於在發佈版本中編譯的每個項目。

Executing tasks: [:app:assembleDebug] 

Parallel execution with configuration on demand is an incubating feature. 
/home/cooperok/AndroidStudioWorkspace/MyApp/app/build/outputs/apk/app-debug.apk 
app-debug-1.0.5.apk 
/home/cooperok/AndroidStudioWorkspace/MyApp/app/build/outputs/apk/app-release.apk 
app-release-1.0.5.apk 
:app:preBuild 
:library:compileLint UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:library:copyReleaseLint UP-TO-DATE 
:library:preBuild 
:library-2:compileLint UP-TO-DATE 
:library-2:copyReleaseLint UP-TO-DATE 
:library:preReleaseBuild 
:library-2:mergeReleaseProguardFiles UP-TO-DATE 
:library:checkReleaseManifest 
:library:preReleaseUnitTestBuild UP-TO-DATE 
:library:generateReleaseBuildConfig UP-TO-DATE 
:library-2:preBuild UP-TO-DATE 
:library-2:preReleaseBuild UP-TO-DATE 
:library-2:checkReleaseManifest 
:library-2:prepareReleaseDependencies UP-TO-DATE 
:library:generateReleaseAssets UP-TO-DATE 
:library:generateReleaseResValues UP-TO-DATE 
:library:processReleaseJavaRes UP-TO-DATE 
:library:mergeReleaseProguardFiles UP-TO-DATE 
:library:compileReleaseNdk UP-TO-DATE 
:library:packageReleaseJniLibs UP-TO-DATE 
:library:packageReleaseLocalJar UP-TO-DATE 
:library:packageReleaseRenderscript 
:library-2:compileReleaseAidl UP-TO-DATE 
:app:generateDebugBuildConfig UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:generateDebugResValues UP-TO-DATE 
:library:preReleaseBuild UP-TO-DATE 
:library-2:compileReleaseRenderscript 
:app:processDebugJavaRes UP-TO-DATE 
:app:compileDebugNdk UP-TO-DATE 
:app:validateDebugSigning 
:library-2:compileReleaseRenderscript UP-TO-DATE 
:library-2:generateReleaseBuildConfig UP-TO-DATE 
:library-2:generateReleaseAssets UP-TO-DATE 
:library-2:mergeReleaseAssets UP-TO-DATE 
:library-2:generateReleaseResValues UP-TO-DATE 
:library-2:generateReleaseResources UP-TO-DATE 
:library-2:packageReleaseResources UP-TO-DATE 
:library-2:processReleaseManifest UP-TO-DATE 
:library-2:processReleaseResources UP-TO-DATE 
:library-2:generateReleaseSources UP-TO-DATE 
:library-2:processReleaseJavaRes UP-TO-DATE 
:library-2:compileReleaseJava UP-TO-DATE 
:library-2:packageReleaseJar UP-TO-DATE 
:library-2:compileReleaseNdk UP-TO-DATE 
:library-2:packageReleaseJniLibs UP-TO-DATE 
:library-2:packageReleaseLocalJar UP-TO-DATE 
:library-2:packageReleaseRenderscript UP-TO-DATE 
:library-2:bundleRelease UP-TO-DATE 
:library:prepareComAndroidSupportSupportV42211Library UP-TO-DATE 
:library:prepareComCrashlyticsSdkAndroidAnswers122Library UP-TO-DATE 
:library:prepareComCrashlyticsSdkAndroidBeta112Library UP-TO-DATE 
:library:prepareComCrashlyticsSdkAndroidCrashlytics232Library UP-TO-DATE 
:library:prepareComCrashlyticsSdkAndroidCrashlyticsCore232Library UP-TO-DATE 
:library:prepareComGoogleAndroidGmsPlayServicesBase730Library UP-TO-DATE 
:library:prepareComGoogleAndroidGmsPlayServicesMaps730Library UP-TO-DATE 
:library:prepareIoFabricSdkAndroidFabric133Library UP-TO-DATE 
:library:prepareReleaseDependencies 
:library:compileReleaseAidl 
:library:compileReleaseRenderscript UP-TO-DATE 
:library:mergeReleaseAssets UP-TO-DATE 
:library:generateReleaseResources UP-TO-DATE 
:library:mergeReleaseResources UP-TO-DATE 
:library:processReleaseManifest UP-TO-DATE 
:library:processReleaseResources UP-TO-DATE 
:library:generateReleaseSources 
:library:compileReleaseJava 

所以編譯庫內項目變量BuildConfig.DEBUG後爲假

如何編譯調試構建變量的一切嗎?

回答

5

事實證明,這是已知的問題,並且自2013年起在code.google.com有bug報告。
我在那裏建立了解決方案。要以構建變量每個項目,你需要,你應在相關項目

android { 
    publishNonDefault true 
    ... 
} 

,並使用它

dependencies { 
    releaseCompile project(path: ':theotherproject', configuration: 'release') 
    debugCompile project(path: ':theotherproject', configuration: 'debug') 
} 
項目設置此此
相關問題