Fix flutter project with new android-studio version:

- upgrade gradle from 7.5 to 7.6.1
  - change java target from 1.8 to 17
  - set flutter jdk-dir to system-jdk (instead of now-incompatible android-studio bundled jdk)
    (android studio bundles jdk 21, jdk 21 needs gradle 8.4, flutetr does not work with gradle > 7.6.1 )
    => see https://docs.gradle.org/current/userguide/compatibility.html#java
    =>     https://www.liquidbcn.com/en/insights/solving-issues-android-studio-ladybug-java-21-flutter
This commit is contained in:
Mike Schwörer 2024-10-15 19:41:15 +02:00
parent 779c86d8ac
commit 05eb37bc80
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 19 additions and 7 deletions

View File

@ -1,14 +1,22 @@
# Setup
#
# flutter config --jdk-dir "/usr/lib/jvm/default-runtime/bin"
# sudo archlinux-java set java-17-openjdk
#
run:
flutter pub run build_runner build
flutter run
_JAVA_OPTIONS="" flutter run
run-android:
ping -c1 10.10.10.177
adb connect 10.10.10.177:5555
flutter pub run build_runner build
flutter run -d 10.10.10.177:5555
_JAVA_OPTIONS="" flutter run -d 10.10.10.177:5555
test:
dart analyze
@ -24,4 +32,8 @@ autoreload:
@_utils/autoreload.sh
icons:
flutter pub run flutter_launcher_icons -f "flutter_launcher_icons.yaml"
flutter pub run flutter_launcher_icons -f "flutter_launcher_icons.yaml"
clean:
cd android && ./gradlew clean
flutter clean

View File

@ -38,12 +38,12 @@ android {
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
sourceSets {

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip