gpt4 book ai didi

android - 错误 : Failed to resolve: fragment Affected Modules: app

转载 作者:行者123 更新时间:2023-12-03 04:56:24 47 4
gpt4 key购买 nike

我正在使用 Android Studio 3.5.3 版。问题是当我想用 Java 创建项目时,我遇到了无法解析 fragment 的错误和 Activity 的相同错误。但是当我使用 Kotlin 创建项目时,我没有遇到问题。你可以在下面看到 Gradle 文件。

Project Gradle


buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

App Module Gradle


apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

有错误日志。

enter image description here

最佳答案

我通过更新 Gradle 解决了我的问题来自 5.4.1 的版本至6.0.1 .
顺便说一句,它应该可以与基于 Google Document 的先前 Gradle 版本一起使用.但是Java有问题应用。

您可以在此图像中找到具有所需 Gradle 版本的插件版本 Android Studio。

enter image description here

关于android - 错误 : Failed to resolve: fragment Affected Modules: app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59451039/

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