Gradle在更新后不再显示dagger2组件图

时间:2018-04-13 01:00:37

标签: android gradle android-gradle dagger-2 gradle-plugin

最近,我已将Gradle版本和gradle插件更新为: 4.6和3.1.1。现在,当我尝试编译具有一些依赖性问题的项目时,gradle只指向一个编译错误,说它无法找到类DaggerApplicationComponent。

之前,当存在匕首依赖性问题时,它显示了不满足的依赖性和依赖性树。喜欢:

"Dagger 2 cannot be provided without an @Provides-annotated method"

"Error:(51, 10) error: .BaseActivity cannot be provided without an @Provides-annotated method. BaseActivity is injected at AppComponent.inject(baseActivity) Error:(75, 10) error: MainActivity cannot be provided without an @Inject constructor or from an @Provides-annotated method. MainActivity is injected at .AppComponent.inject(mainActivity)"

现在它显示了这个:

enter image description here

enter image description here

不满足的依赖性来自java库中的类。它的gradle文件是:

apply plugin: 'java-library'
apply plugin: 'net.ltgt.apt'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.google.dagger:dagger:2.15'

    apt 'com.google.dagger:dagger-compiler:2.15'


    api 'com.squareup.retrofit2:retrofit:2.4.0'

    api 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'


    implementation 'com.squareup.retrofit2:converter-moshi:2.4.0'
    implementation 'com.squareup.okhttp:logging-interceptor:2.6.0'

    implementation 'io.reactivex.rxjava2:rxjava:2.1.12'


    api 'com.squareup.moshi:moshi:1.5.0'
    /*implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.google.code.gson:gson:2.8.2'*/



}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"

根gradle文件是:

// Top-level build file whesugre you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        classpath 'com.google.gms:google-services:3.1.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }



}



plugins {
    id "net.ltgt.apt" version "0.15"

}

allprojects {


    repositories {
        jcenter()

        maven { url 'https://maven.google.com' }
        google()
    }



}


task clean(type: Delete) {
    delete rootProject.buildDir
}


Android Studio 3.1.1
Build #AI-173.4697961, built on April 3, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.14.0-deepin2-amd64

是否需要其他配置?

编辑:

现在我解决了它通过命令行运行构建。

./ gradlew build

它显示:

home/alexandre/dev/projetos/gitlab/BeerCollection/app/src/main/java/com/github/alexpfx/udacity/beercollection/dagger/ApplicationComponent.java:22: error: [com.github.alexpfx.udacity.beercollection.dagger.HomeSubComponent.inject(com.github.alexpfx.udacity.beercollection.ui.home.HomeFragment)] com.github.alexpfx.udacity.beercollection.databaselib.search.BeerRemoteDataSource cannot be provided without an @Provides-annotated method.
public interface ApplicationComponent {
       ^
      com.github.alexpfx.udacity.beercollection.databaselib.search.BeerRemoteDataSource is injected at
          com.github.alexpfx.udacity.beercollection.favorite.FavoriteInteractorImpl.<init>(…, beerRemoteDataSource)
      com.github.alexpfx.udacity.beercollection.favorite.FavoriteInteractorImpl is injected at
          com.github.alexpfx.udacity.beercollection.dagger.FavoriteModule.providesFavoriteInteractor(favoriteInteractor)
      com.github.alexpfx.udacity.beercollection.favorite.FavoriteInteractor is injected at
          com.github.alexpfx.udacity.beercollection.databaselib.search.DefaultSearchPresenter.<init>(…, arg2)
      com.github.alexpfx.udacity.beercollection.databaselib.search.DefaultSearchPresenter is injected at
          com.github.alexpfx.udacity.beercollection.dagger.SearchModule.searchPresenter(searchPresenter)
      com.github.alexpfx.udacity.beercollection.databaselib.search.SearchPresenter is injected at
          com.github.alexpfx.udacity.beercollection.ui.home.HomeFragment.searchPresenter
      com.github.alexpfx.udacity.beercollection.ui.home.HomeFragment is injected at
          com.github.alexpfx.udacity.beercollection.dagger.HomeSubComponent.inject(homeFragment)
2 errors

我无法在构建标签上显示它,但对我来说没关系

1 个答案:

答案 0 :(得分:4)

单击“构建”选项卡上的Toggle View可以找到gradle输出。

enter image description here