我在 Android env(模拟器)上使用共享首选项版本 2.1.0 后遇到问题。 问题是这样表述的(如果你愿意回答我的问题,非常感谢):
What went wrong:
A problem occurred configuring project ':shared_preferences_android'.
> Could not load compiled classes for build file 'C:\Users\rakhtama\AppData\Local\Pub\Cache\hosted\pub.dev\shared_preferences_android-2.1.0\android\build.gradle' from cache.
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':shared_preferences_android' of type org.gradle.api.Project.
> Could not get unknown property 'android' for project ':shared_preferences_android' of type org.gradle.api.Project.
这是与错误相关的文件:
C:\用户 akhtama\AppData\Local\Pub\Cache\hosted\pub.dev\shared_preferences_android-2.1.0 android uild.gradle :
group 'io.flutter.plugins.sharedpreferences'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 33
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency'
baseline file("lint-baseline.xml")
}
dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-inline:5.0.0'
}
testOptions {
unitTests.includeAndroidResources = true
unitTests.returnDefaultValues = true
unitTests.all {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}
{项目文件夹} android\gradle\wrapper\gradler-wrapper.properties
{项目文件夹} android\gradle.properties :
如果您愿意回答我的问题,非常感谢
我尝试运行“flutter clean”和“.\gradlew clean build”,但错误仍然存在。
只需按照以下步骤即可解决,
在终端
中运行
flutter clean
Pug 从 pubspec.yamal 获取