Как исправить ошибку разметки POM flutter_embedding_debug при использованииshared_preferences во Flutter?JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Как исправить ошибку разметки POM flutter_embedding_debug при использованииshared_preferences во Flutter?

Сообщение Anonymous »

Я столкнулся с проблемой в своем проекте Flutter: при сборке проекта после добавления зависимостиshared_preferences я получаю следующее сообщение об ошибке:

Код: Выделить всё

Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
[Fatal Error] flutter_embedding_debug-1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262.pom:2:90: The markup in the document following the root element must be well-formed.
[Fatal Error] flutter_embedding_debug-1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262.pom:2:90: The markup in the document following the root element must be well-formed.
[Fatal Error] flutter_embedding_debug-1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262.pom:2:90: The markup in the document following the root element must be well-formed.
[Fatal Error] flutter_embedding_debug-1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262.pom:2:90: The markup in the document following the root element must be well-formed.
[Fatal Error] flutter_embedding_debug-1.0.0-a18df97ca57a249df5d8d68cd0820600223ce262.pom:2:90: The markup in the document following the root element must be well-formed.
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
Ошибка возникает, когда пакет Shared_preferences включен в качестве зависимости.
Удаление Shared_preferences из файла pubspec.yaml решает проблему, предполагая, что ошибка связана с этим конкретным пакетом.
Я использую Java 17, но Android Studio по-прежнему использует Java 21 для сборки проекта, что также может усугублять проблему.
Моя версия Java:

Код: Выделить всё

java -version
java version "17.0.12" 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.12+8-LTS-286, mixed mode, sharing)

Flutter Doctor:

Код: Выделить всё

flutter doctor -v
[√] Flutter (Channel stable, 3.24.5, on Microsoft Windows [Version 10.0.26120.1912], locale en-IN)
• Flutter version 3.24.5 on channel stable at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision dec2ee5c1f (3 weeks ago), 2024-11-13 11:13:06 -0800
• Engine revision a18df97ca5
• Dart version 3.5.4
• DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\admin\AppData\Local\Android\Sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.8.34330.188
• Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = C:\Program Files\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[√] VS Code (version 1.95.2)
• VS Code at C:\Users\admin\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
• RMX3471 (mobile)  • 192.168.0.0:00000 • android-arm64  • Android 14 (API 34)
• Windows (desktop) • windows           • windows-x64    • Microsoft Windows [Version 10.0.26120.1912]
• Chrome (web)      • chrome            • web-javascript • Google Chrome 131.0.6778.87
• Edge (web)        • edge              • web-javascript • Microsoft Edge 132.0.2957.26

[√] Network resources
• All expected network resources are available.

• No issues found!

Версия Android Studio:

Код: Выделить всё

Android Studio Ladybug | 2024.2.1 Patch 3
settings.gradle:

Код: Выделить всё

pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.2" apply false
id "org.jetbrains.kotlin.android" version "2.0.21"  apply false
}

include ":app"

app\build.gradle:

Код: Выделить всё

plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}

android {
namespace = "com.example.savory_chef"
compileSdk = flutter.compileSdkVersion
ndkVersion = "25.1.8937393"

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.savory_chef"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}

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 = "../.."
}
для получения дополнительной информации я использую последнюю версию пакетаshared_preferences:

Код: Выделить всё

shared_preferences: ^2.3.2
Что я пробовал:
если вы собираетесь предложить изменить версию jdk с

Код: Выделить всё

Build, Execution, Deployment > Build Tools > Gradle
или добавив путь jdk в gradle.properties, оба эти варианта не работают в этой последней версии студии Android, не знаю, почему в Инструментах сборки > Gradle даже нет возможности изменить gradle, jdk может быть перемещен Наверное.
В чем мне нужна помощь:
Как устранить ошибку неправильного формата POM-файла (flutter_embedding_debug), вызванную параметромshared_preferences зависимость.
Как убедиться, что Android Studio использует Java 17 вместо Java 21 во время процесса сборки, учитывая, что версия java показывает, что установлена ​​Java 17.
Любые дополнительные шаги, которые я мог пропустить для исправления зависимости. конфликт зависимостей или проблема с файлом POM.

Подробнее здесь: https://stackoverflow.com/questions/792 ... preference
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»