如何在调试版本变体中运行带有库的应用程序?

时间:2015-07-13 09:02:13

标签: android android-studio

我在调试构建类型中启动应用程序时遇到问题。我有依赖于库的应用程序,它取决于另一个库。我将所有内容都调整为调试版本变体,与图像相同。

enter image description here

Problrem是内部库我没有什么功能可以在调试中关闭,例如loggin和analytics,但每次编译时都会在发布版本类型中编译。
在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之后库里面是假的

如何在debug build variant中编译所有内容?

1 个答案:

答案 0 :(得分:5)

事实证明,这是已知问题,自2013年以来code.google.com就有错误报告 我创立了解决方案。要在您需要的构建变体中运行每个项目,您应该在依赖项目

中进行设置
android {
    publishNonDefault true
    ...
}

这在使用它的项目中

dependencies {
    releaseCompile project(path: ':theotherproject', configuration: 'release')
    debugCompile project(path: ':theotherproject', configuration: 'debug')
}