提问人:Eden Zane 提问时间:10/27/2023 最后编辑:Eden Zane 更新时间:10/29/2023 访问量:50
Gradle 错误:无法解析 androidx.appcompat:appcompat:1.0.0
Gradle Error: Could not resolve androidx.appcompat:appcompat:1.0.0
问:
我在使用 Gradle 的 Flutter 项目中遇到了一个问题,同时尝试解决 .错误消息指出:androidx.appcompat:appcompat:1.3.0 dependency
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve androidx.appcompat:appcompat:1.3.0.
Required by:
project :app
我添加了这一行,
module:
androidX: true # Add this line.
如本页所示,但它没有解决问题。
我已经尝试了这个问题、它的评论和答案中建议的解决方案。没有一个帮助。
请提出一个解决方案,感谢您参加这次会议。
编辑:这是我的android\build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
这是android\app\build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.shopx"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
//implementation 'androidx.appcompat:appcompat:1.3.1'
implementation group: 'com.google.android.material', name: 'material', version: '1.6.1'
implementation 'androidx.core:core-ktx:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
是gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
答:
0赞
Daniel
10/29/2023
#1
也许更新 gradle 会有所帮助。
android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
android/build.gradle:
classpath 'com.android.tools.build:gradle:7.1.2'
评论
0赞
Eden Zane
10/29/2023
这是我的gradle-wrapper.properties,distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
评论
google()
google()
mavenCentral()
gradle.properties
android.enableJetifier=true android.useAndroidX=true