Как отключить Java 8 Source/Target Compalibity в приложении Flutter/AndroidAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Как отключить Java 8 Source/Target Compalibity в приложении Flutter/Android

Сообщение Anonymous »

Я только что создал новое приложение Flutter с Flutter Create turtiorm_flutter_redux_navigation -Platforms Android -EMPTY . Вот некоторая информация, я думаю, будет полезно предоставить контекст для моего вопроса. переопределить ">

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

[✓] Flutter (Channel stable, 3.24.4, on macOS 15.0.1 24A348 darwin-arm64, locale en-US)
• Flutter version 3.24.4 on channel stable at /Users/axiopisty/apps/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 603104015d (9 days ago), 2024-10-24 08:01:25 -0700
• Engine revision db49896cf2
• Dart version 3.5.4
• DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/axiopisty/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Users/axiopisty/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16B40
• CocoaPods version 1.15.0

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
• Android Studio at /Users/axiopisty/Applications/Android Studio.app/Contents
• 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
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.2.4)
• IntelliJ at /Users/axiopisty/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin version 82.0.3
• Dart plugin version 242.22855.32

[✓] Connected device (4 available)
• XQ DQ62 (mobile)                • QV7702KBJA            • android-arm64  • Android 14 (API 34)
• macOS (desktop)                 • macos                 • darwin-arm64   • macOS 15.0.1 24A348 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 15.0.1 24A348 darwin-arm64
• Chrome (web)                    • chrome                • web-javascript • Google Chrome 130.0.6723.92

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

• No issues found!
< /code>
gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
< /code>
settings.gradle:
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22"  apply false
}
< /code>
gradle.properties:
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
android/build.gradle:

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

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:

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

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 {

def javaVersion = JavaVersion.VERSION_1_8

namespace = "com.github.axiopisty.tutorial_flutter_redux_navigation"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

kotlinOptions {
jvmTarget = javaVersion
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.github.axiopisty.tutorial_flutter_redux_navigation"
// 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 = "../.."
}
< /code>
Когда я строю и запускаю приложение в отладчике, я вижу это сообщение: < /p>
Running Gradle task 'assembleDebug'...
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
Для меня неясно, что именно вызывает отображение этого предупреждения, но я думаю, что оно связано с совместимостью источника/цели, настроенной в Android/App/build.gradle , который имеет следующие определения: < /p>

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

android {
...
def javaVersion = JavaVersion.VERSION_1_8
compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

kotlinOptions {
jvmTarget = javaVersion
}
...
}
Желание исправить/удалить предупреждения об испаке, появляющиеся в журналах сборки, я попытался обновить javaversion из javaversion.version_1_8 до любой версии выше 1,8. Но это приводит к замене этого предупреждения о времени сборки в журналах ошибкой, которая предотвращает запуск приложения. Например, если я обновлю javaversion как javaversion.version_11 я вижу это сообщение об ошибке:
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':app:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: /Users/axiopisty/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar.
> Error while executing process /Users/axiopisty/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/jlink with arguments {--module-path /Users/axiopisty/.gradle/caches/transforms-3/d9e926982c2c139ff9125eb7b6be4144/transformed/output/temp/jmod --add-modules java.base --output /Users/axiopisty/.gradle/caches/transforms-3/d9e926982c2c139ff9125eb7b6be4144/transformed/output/jdkImage --disable-plugin system-modules}

< /code>
Учитывая эту информацию, я знаю, я могу просто жить с предупреждением об испаке в журналах сборки и оставляю вещи в покое (пока). По крайней мере, это успешно строится. Но когда я вижу предупреждения в журналах сборки, мне нравится обращаться к ним, чтобы убедиться, что мое приложение готово к будущим обновлениям/обновлениям.
Мой вопрос: Что нужно Сделано в моем проекте, чтобы выйти из совместимости Java 8 Source/Target , чтобы уступить предупреждениям журнала сборки? Новейшая версия Android Studio использует Java 21 для создания проекта. Я не ищу флаг, который можно передать в качестве аргумента в области сборки, чтобы подавить предупреждение.

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

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

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

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

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

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