我是Kotlin的新手,我没能找到直接解决此问题的方法。我在项目中添加了片段类和布局,并且在执行过程中开始显示此问题。
错误指出, “无法解析以下类的超类。请确保您在类路径中具有正确的依赖项:androidx.app.appcompat.app.AppCompatActivty类,未解析的超类:androidx.core.app.TaskStackBuilder.SupportParentable”。 >
我已附上我的gradle文件内容。
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "mapp.com.sg.mappfinalassignment"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.+'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.android.support:recyclerview-v7:28.+'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-fragment:28.0.0'
implementation 'com.google.android:support-v4:r7'
}
repositories {
jcenter()
mavenCentral()
}
我如何使其运行?
答案 0 :(得分:0)
您不能将新的AndroidX依赖项与旧的依赖项一起使用。您可以尝试在Android Studio中运行Refactor > Migrate to AndroidX
或手动转换依赖关系。这是documentation,可以为您提供帮助。