在build.gradle中找不到参数的方法classpath()



大家好)我正在做一个关于kotlin天气的小android应用程序。我有这个问题,改变类路径

  • 无法在类型为org.gradle.api.internal.artifacts. dll .dependencies. defaultdependencyhandler *的对象上找到[android.arch.navigation:navigation- secure -args-gradle-plugin:2.1.0-alpha02]的方法classpath()

build.gradle(项目)

plugins {
id 'com.android.application' version '7.2.0' apply false
id 'com.android.library' version '7.2.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
dependencies {
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha02"
}

build.gradle (app)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"
apply plugin: 'androidx.navigation.safeargs'
android {
compileSdk 32
defaultConfig {
applicationId "com.example.kevychsolutionstest"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
androidExtensions {
experimental = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.4.1'
// Navigation
implementation "android.arch.navigation:navigation-fragment:$navigation_version"
implementation "android.arch.navigation:navigation-ui:$navigation_version"
implementation "android.arch.navigation:navigation-fragment-ktx:$navigation_version"
implementation "android.arch.navigation:navigation-ui-ktx:$navigation_version"
implementation "androidx.core:core-ktx:1.7.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
// Room
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
kapt "androidx.room:room-compiler:$room_version"
// Gson
implementation "com.google.code.gson:gson:2.8.9"
// Kotlin Android Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
// Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
// ViewModel
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
// Kodein
implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version"
// Better dateTime-time support even on older Android versions
implementation "com.jakewharton.threetenabp:threetenabp:1.1.0"
// Glide
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'
// Groupie RecyclerView
implementation 'com.xwray:groupie:2.1.0'
implementation 'com.xwray:groupie-kotlin-android-extensions:2.1.0'
// Preference
implementation "androidx.preference:preference:1.2.0"
// WeatherLocation
implementation "com.google.android.gms:play-services-location:19.0.1"
// New Material Design
implementation "com.google.android.material:material:1.6.0"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0-alpha06'
}

在build.gradle(Project)文件的顶部添加一个buildscript组

buildscript {
dependencies {
classpath("androidx.navigation.safeargs:androidx.navigation.safeargs.gradle.plugin:2.4.1")
}
}

然后将插件ID添加到build.gradle(Module)文件中的plugins组中。

id 'androidx.navigation.safeargs'

它可以帮助

更新安全参数"类路径">

val nav_version = "2.4.2"
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version")

不是

classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha02"

相关内容

  • 没有找到相关文章

最新更新