gpt4 book ai didi

android - Flutter Android SDK 版本 28 错误,但我使用的是 30

转载 作者:行者123 更新时间:2023-12-05 06:10:50 24 4
gpt4 key购买 nike

当我创建一个新的 flutter 应用程序时,它会启动 android sdk 版本 28,但我使用的是 android sdk 30。Flutter doctor 还显示了 Platform android-30,build-tools 30.0.2。当我尝试安装像 url_launcher 或 shared_preferences 这样的包时,我收到错误它寻找 Android sdk 30。另外,每次我从 build.gradle 更改 android sdk verison 时。

这是我的 flutter doctor 输出:

flutter doctor -v
[✓] Flutter (Channel stable, 1.22.0, on Linux, locale en_US.UTF-8)
• Flutter version 1.22.0 at /home/felix/snap/flutter/common/flutter
• Framework revision d408d302e2 (7 days ago), 2020-09-29 11:49:17 -0700
• Engine revision 5babba6c4d
• Dart version 2.10.0


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /home/felix/Android/Sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /home/felix/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6626763/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[!] Android Studio (version 4.0)
• Android Studio at /home/felix/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6626763
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593

)

网址启动器包错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':url_launcher:parseDebugLibraryResources'.
> Could not resolve all files for configuration ':url_launcher:androidApis'.
> Failed to transform file 'android.jar' to match attributes {artifactType=android-platform-attr, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}
> Execution failed for PlatformAttrTransform: /home/computer/Android/Sdk/platforms/android-28/android.jar.
> /home/computer/Android/Sdk/platforms/android-28/android.jar (No such file or directory)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

异常:Gradle 任务 assembleDebug 失败,退出代码为 1

我的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 30

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.appdeals"
minSdkVersion 16
targetSdkVersion 30
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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

shared_preferences 错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared_preferences:parseDebugLibraryResources'.
> Could not resolve all files for configuration ':shared_preferences:androidApis'.
> Failed to transform file 'android.jar' to match attributes {artifactType=android-platform-attr, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}
> Execution failed for PlatformAttrTransform: /home/computer/Android/Sdk/platforms/android-28/android.jar.
> /home/computer/Android/Sdk/platforms/android-28/android.jar (No such file or directory)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org

BUILD FAILED in 8s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

最佳答案

试试这个,

minSdkVersion 16
compileSdkVersion 28
targetSdkVersion 29

关于android - Flutter Android SDK 版本 28 错误,但我使用的是 30,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64223595/

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