gpt4 book ai didi

android - "Cannot resolve class android.support.v4.widget.DrawerLayout"即使在 gradle 中添加依赖项之后

转载 作者:行者123 更新时间:2023-12-05 00:11:00 26 4
gpt4 key购买 nike

即使在添加了 DrawerLayout androidx.drawerlayout:drawerlayout:1.1.1 和我的 build.gradle 文件中的 Material com.google.android.material:material:1.0.0 实现。

我尝试添加其他实现,例如 com.android.support:support-compat:28.0.0com.android.support:design:25.0.0,但错误仍然存​​在,应用程序无法启动。

知道如何解决这个问题吗?

build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"

defaultConfig {
applicationId "edu.ktu.birthdaycalendar"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}

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

}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

def room_version = "2.2.5"
def lifecycle_version = "2.2.0"
def arch_version = "2.1.0"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:$room_version"
// optional - Test helpers
testImplementation "androidx.room:room-testing:$room_version"

//lifecycle
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
androidTestImplementation "androidx.arch.core:core-testing:$arch_version"

implementation "com.google.android.material:material:1.0.0"
/*implementation "com.android.support:support-compat:28.0.0"
implementation "com.android.support:design:25.0.0"

implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.android.support:support-v4:27.1.1"
implementation "com.android.support:design:27.1.1"
//implementation 'com.android.support.constraint:constraint-layout:1.1.0' */
}

最佳答案

您导入了错误版本的 DrawerLayout。 android.support.v4.widget.DrawerLayout

应该是import androidx.drawerlayout.widget.DrawerLayout

关于android - "Cannot resolve class android.support.v4.widget.DrawerLayout"即使在 gradle 中添加依赖项之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64388975/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com