使用 gradle 构建库项目时 BuildConfig.DEBUG 始终为 false [英] BuildConfig.DEBUG always false when building library projects with gradle

查看:44
本文介绍了使用 gradle 构建库项目时 BuildConfig.DEBUG 始终为 false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在调试模式下运行我的应用程序时,BuildConfig.DEBUG 不起作用(= 逻辑上设置为 false).我使用 Gradle 构建.我有一个图书馆项目,我在那里做这个检查.BuildConfig.java 在构建调试文件夹中看起来像这样:

BuildConfig.DEBUG is not working (= logically set to false) when I run my app in debug mode. I use Gradle to build. I have a library project where I do this check. BuildConfig.java looks like this in the build debug folder:

/** Automatically generated the file. DO NOT MODIFY */
package common.myProject;

public final class BuildConfig {
    public static final boolean DEBUG = Boolean.parseBoolean("true");

}

在发布文件夹中:

public static final boolean DEBUG = false;

在库项目和应用程序项目中.

both in the library project and in the application project.

我试图通过检查一个变量来解决这个问题,该变量设置了我的项目的类.该类继承自库并在启动时启动.

I tried to get around this by checking a variable which is set a class of my project. This class inherits from the library and starts on startup.

<application
        android:name=".MyPrj" ...

这导致了另一个问题:我在应用程序类之前运行的 DataBaseProvider 中使用了我的 DEBUG 变量,并且由于这个错误它无法正常运行.

This leads to another problem: is that I use my DEBUG variable in a DataBaseProvider which runs before the application class, and it will not run properly due to this bug.

推荐答案

这是预期的行为.

库项目仅发布其发布变体供其他项目或模块使用.

Library projects only publish their release variants for consumption by other projects or modules.

我们正在努力解决这个问题,但这不是微不足道的,需要大量的工作.

We're working at fixing this but this is non trivial and requires a significant amount of work.

您可以在 https://code.google 上跟踪问题.com/p/android/issues/detail?id=52962

这篇关于使用 gradle 构建库项目时 BuildConfig.DEBUG 始终为 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆