question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dagger 2 swallows errors

See original GitHub issue

Hi, i have an unexpected problem with my setup. Also to inform you, i heavily use the official android databinding in my project (in 10+ activities and 20+ fragments).

my app build.gradle is something like this:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    dataBinding {
        enabled = true
    }

    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }

    defaultConfig {
        applicationId "com.charbgr"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1"

        //Espresso
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        //RenderScript
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true

        multiDexEnabled true
    }

    packagingOptions {

        //Espresso excludes
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'LICENSE.txt'
        //Espresso excludes

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

}



dependencies {

    ...

    compile 'com.google.dagger:dagger:2.0.2'
    apt 'com.google.dagger:dagger-compiler:2.0.2'
    provided 'org.glassfish:javax.annotation:10.0-b28'
}

the root build.gradle is this one:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

In my code, i make an enforced error(i know that i cannot create an object with the same method name in a module). The enforced error looks like this:

@Module
public class AndroidModule {

    @Provides
    public Foo providesFoo(String bar) {
        return new Foo(bar);
    }

    @Provides
    public Foo providesFoo(String bar, String unusedArgument) {
        return new Foo(bar);
    }
}

For some reason, when i build my project i get 100+ errors from databinding with this output: cannot find symbol class BR

and dagger doesn’t prints this error Cannot have more than one @Provides method with the same name in a single module

Seems that Dagger “swallows” this error or the databinding overrides some behaviour of the annotation processor tool(apt).

Do you know what’s going on?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:27

github_iconTop GitHub Comments

52reactions
charbgrcommented, Feb 5, 2016

After couple of days of debugging, i found that javac outputs by default max 100 errors. So if anyone, come with this error just add to gradle to force javac to output over 100 errors.

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xmaxerrs" << "500"
    }
}

so @ronshapiro you can close this issue.

35reactions
tasomaniaccommented, Jul 4, 2017

The mentioned fix actually didn’t work for me with Gradle 4.0. It does not find the JavaCompile tasks. Here what I did instead (in my main build.gradle)

allprojects {
  afterEvaluate {
     tasks.withType(JavaCompile.class) {
       options.compilerArgs << "-Xmaxerrs" << "500"
     }
   }
 }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Android databinding swallows errors from other compilers
Temporarily, a workaround is to simply disable databinding V2: android.databinding.enableV2=true in gradle.properties. Still open to a better ...
Read more >
Beyond Basic RxJava Error Handling | by Elye - Medium
RxJava 2: Making error handling easy in Android (in Kotlin) ... This will swallow the exception away, that the RxJava is not aware...
Read more >
Handling Exceptions: The Easy Way - ProAndroidDev
Moreover, if the handling is complicated, it can cause even more bugs and will make the unit-testing harder for sure. Swallow and ignore: ......
Read more >
Improve error messages for exceptions thrown from Jetifier
Description. during build, following error is occured. FAILURE: Build failed with an exception. * What went wrong:
Read more >
Dagger2 + DataBinding踩坑之旅 - 简书
在最近的项目中,大量的使用到了Dagger2 和DataBinding,在实际操作的过程中,遇到了很多坑,这里把这些坑做个简单的 ... Dagger 2 swallows errors ...
Read more >

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found