Skip to content

Commit

Permalink
Support JDK 21 (Android)
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k committed Oct 28, 2024
1 parent 3475631 commit 6849cd0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 32 deletions.
38 changes: 12 additions & 26 deletions packages/smooth_app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,20 @@ plugins {
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

android {
compileSdkVersion 34
ndkVersion "25.1.8937393"
namespace = "org.openfoodfacts.app"
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
coreLibraryDesugaringEnabled true
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = JavaVersion.VERSION_17
}

sourceSets {
Expand All @@ -41,10 +26,10 @@ android {

defaultConfig {
applicationId "org.openfoodfacts.scanner"
minSdkVersion 21
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
multiDexEnabled true
}

Expand Down Expand Up @@ -73,4 +58,5 @@ flutter {

dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.openfoodfacts.app"
android:installLocation="auto">

<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
21 changes: 21 additions & 0 deletions packages/smooth_app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ allprojects {
google()
mavenCentral()
}

subprojects {
afterEvaluate {
if (it.hasProperty('android')) {
it.android.compileSdkVersion = 35
it.android.defaultConfig.targetSdkVersion = 35
it.android.compileOptions.sourceCompatibility = JavaVersion.VERSION_21
it.android.compileOptions.targetCompatibility = JavaVersion.VERSION_21
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.jvmTarget = JavaVersion.VERSION_21
}
if (it.android.namespace == null) {
def manifest = new XmlSlurper().parse(file(it.android.sourceSets.main.manifest.srcFile))
def packageName = manifest.@package.text()
android.namespace = packageName
println("Updating namespace ${packageName}")
}
}
}
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
}

rootProject.buildDir = '../build'
Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip

7 changes: 4 additions & 3 deletions packages/smooth_app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ pluginManagement {
}

plugins {

id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
id "com.android.application" version "8.7.1" apply false
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
}

include ":app"
include ":app"

0 comments on commit 6849cd0

Please sign in to comment.