Could not determine the dependencies of task ‘:app:kaptDebugKotlin‘

kotlin日志

仅在项目或者demo中遇到的问题,做此笔记而已,不喜勿喷!!!



一、遇到的问题?

在引入kotlin语言中Jetpack库的时候遇到了一下问题,其实是一个很小的错误,因为版本我是全部在项目的build.gradle中控制时,错误日志如下:

Could not determine the dependencies of task ':app:kaptDebugKotlin'.
> Could not resolve all files for configuration ':app:kotlinKaptWorkerDependencies'.
   > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.4.30 because no repositories are defined.
     Required by:
         project :app

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

二、解决办法

1.解决方案

在项目中的build.gradle中添加了如下代码即解决:

allprojects {
    repositories {
        google()
        jcenter()
    }
}

完整的build.gradle文件内容为

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

buildscript {
    // Define versions in a single place
    ext {
        // Sdk and tools
        compileSdkVersion = 30
        minSdkVersion = 27
        targetSdkVersion = 30

        // App dependencies
        appCompatVersion = '1.1.0'
        constraintLayoutVersion = '2.0.0-beta3'
        coreTestingVersion = '2.0.0'
        coroutinesVersion = "1.4.2"
        espressoVersion = '3.1.1'
        fragmentVersion = '1.3.0'
        glideVersion = '4.10.0'
        gradleVersion = '4.1.2'
        gsonVersion = '2.8.2'
        hiltVersion = '2.31.2-alpha'
        junitVersion = '4.12'
        kotlinVersion = '1.4.30'
        ktlintVersion = '0.38.1'
        ktxVersion = '1.0.2'
        lifecycleVersion = '2.2.0'
        materialVersion = '1.2.0'
        navigationVersion = '2.3.3'
        okhttpLoggingVersion = '4.7.2'
        pagingVersion = '3.0.0-alpha02'
        recyclerViewVersion = '1.2.0-alpha04'
        retrofitVersion = '2.9.0'
        roomVersion = '2.2.5'
        runnerVersion = '1.0.1'
        truthVersion = '0.42'
        testExtJunit = '1.1.0'
        uiAutomatorVersion = '2.2.0'
        viewPagerVersion = '1.0.0'
        workVersion = '2.1.0'
    }

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:$gradleVersion"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hiltVersion"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

到此结束!!!


总结

提示:欢迎大家留言交流!!!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DT从零到壹

您的鼓励是我创作最大的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值