相关疑难解决方法(0)

使用gradle构建库项目时,BuildConfig.DEBUG始终为false

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

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

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

}
Run Code Online (Sandbox Code Playgroud)

并在发布文件夹中:

public static final boolean DEBUG = false;
Run Code Online (Sandbox Code Playgroud)

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

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

<application
        android:name=".MyPrj" ...
Run Code Online (Sandbox Code Playgroud)

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

android gradle android-library

81
推荐指数
6
解决办法
4万
查看次数

在android中使用数据绑定时出错

我想测试数据绑定的指南中给出这里.我已将其包含在我的build.gradle文件中(模块应用程序):

compileSdkVersion 'android-MNC'
buildToolsVersion '23.0.0 rc2'
Run Code Online (Sandbox Code Playgroud)

在项目build.gradle文件中,我已将其包含在我的依赖项中:

classpath "com.android.tools.build:gradle:1.3.0-beta2"
classpath "com.android.databinding:dataBinder:1.0-rc0"
Run Code Online (Sandbox Code Playgroud)

布局文件与指南中给出的文件完全相同.

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
   <variable name="user" type="com.example.User"/>
</data>
<LinearLayout
   android:orientation="vertical"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   <TextView android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@{user.firstName}"/>
   <TextView android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@{user.lastName}"/>
</LinearLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)

最初它给出了一个错误Element layout does not have the required attribute layout_width and layout_height.

我尝试通过为两者分配match_parent来修复它.然后我Error parsing XML: duplicate attribute在我指定的线layout_heightlayout_width线性布局上得到了错误 .

我再次试图通过删除这些属性来解决这个问题.现在,每当我尝试编译时,我都会看到 - error: package my.package.name.databinding不存在.

代码完成在我的Fragment中完美运行,我试图使用这个布局.

那么我错过了什么?

data-binding android android-fragments

33
推荐指数
2
解决办法
3万
查看次数