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

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

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

以前有dagger依赖问题的时候,会显示什么依赖不满足,以及依赖树。喜欢:

"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 构建

它显示:

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

我无法让它显示在构建选项卡上,但对我来说没问题

最佳答案

您可以在“构建”选项卡上单击切换 View 时找到 gradle 输出。

enter image description here

关于android - Gradle 更新后不再显示 dagger2 组件图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49807826/

相关文章:

android - Google map 和列表合二为一

java - Android - 每单位时间执行操作

android - 膨胀异常 : Binary XML file line #8: Error inflating class ImageView

android - xml中如何使用gradle placeholder applicationId做唯一的contentProvider权限

android - Gradle 同步失败 : Version: 8. 4.0 低于 google-services 插件所需的最低版本 (9.0.0)

android - activity_main.xml : Failed to find the style corresponding to the id 2130771996

gradle - 使用适用于Java的Google Cloud Translation客户端库时遇到错误(Android)

java - 如何找到提供注释处理器的依赖项

Gradle 多个 Maven 存储库

android - java.util.zip.ZipException : duplicate entry