老师dagger编译失败

来源:2-10 Dagger2-依赖注入

MoriartyZ

2018-09-04

Error:FAILURE: Build failed with an exception.


* What went wrong:

Circular dependency between the following tasks:

:Baselibrary:compileDebugKotlin

\--- :Baselibrary:kaptDebugKotlin

     \--- :Baselibrary:compileDebugKotlin (*)


(*) - details omitted (listed previously)



* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.


* Get more help at https://help.gradle.org


BUILD FAILED in 1s

Baselibrary=====================================

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
   compileSdkVersion 26
   buildToolsVersion "26.0.1"


   defaultConfig {
       minSdkVersion 19
       targetSdkVersion 26
       versionCode 1
       versionName "1.0"

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

   }
   buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
   }
}

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
       exclude group: 'com.android.support', module: 'support-annotations'
   })
   testCompile 'junit:junit:4.12'
   compile 'com.android.support:appcompat-v7:26.+'
   compile 'com.android.support.constraint:constraint-layout:1.0.2'
   compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

   // Anko Commons
   compile "org.jetbrains.anko:anko-commons:$anko_version"
   // Support-v4 (only Anko Commons)
   compile "org.jetbrains.anko:anko-support-v4-commons:$anko_version"

   // RxKotlin and RxAndroid
   compile "io.reactivex:rxkotlin:$rx_kotlin_version"
   compile "io.reactivex:rxandroid:${rx_android_version}"
   //Retrofit
   compile "com.squareup.okhttp3:okhttp:${ok_http_version}"
   compile "com.squareup.retrofit2:retrofit:${retrofit_version}"
   compile "com.squareup.okhttp3:logging-interceptor:${ok_http_version}"
   compile "com.squareup.retrofit2:converter-gson:${retrofit_version}"
   compile "com.squareup.retrofit2:adapter-rxjava:${retrofit_version}"

   //Dagger2
   compile "com.google.dagger:dagger:$dagger_version"
   kapt "com.google.dagger:dagger-compiler:$dagger_version"
}

UserCenter====================

if (isUserModule.toBoolean()) {
   apply plugin: 'com.android.library'
} else {
   apply plugin: 'com.android.application'
}

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'


android {
   compileSdkVersion 26
   buildToolsVersion "26.0.1"


   defaultConfig {
       minSdkVersion 19
       targetSdkVersion 26
       versionCode 1
       versionName "1.0"

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

   }
   buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
   }

   sourceSets{
       main{
           if (isUserModule.toBoolean()){
               manifest.srcFile "src/main/release/AndroidManifest.xml"
           }else {
               manifest.srcFile "src/main/debug/AndroidManifest.xml"
           }
       }
   }
}

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
       exclude group: 'com.android.support', module: 'support-annotations'
   })

   testCompile 'junit:junit:4.12'
   compile project(':Provider')

   //Dagger2
   kapt "com.google.dagger:dagger-compiler:$dagger_version"
}

写回答

1回答

MoriartyZ

提问者

2018-09-04

问题解决了,本地的kotlin版本太低,升级就行了。

0
0

Kotlin打造完整电商APP 模块化+MVP+主流框架

全网稀缺Kotlin项目实战,打造新一代Android工程师的核心竞争力

694 学习 · 209 问题

查看课程