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
}
到此结束!!!
总结
提示:欢迎大家留言交流!!!