Skip to content

Commit

Permalink
chore: jnigen 0.13.0, misc other things (#184)
Browse files Browse the repository at this point in the history
- build example app with java 21
- set targetCompatebility, sourceCompatebility to java 11 to remove
warnings on build
- migrate jni/jnigen to 0.13.0 (null safety)
- add Helpers kotlin class to workaround jnigen generation issues 
- use android 15 (sdk 35) in ci
  • Loading branch information
josxha authored Dec 22, 2024
1 parent cab97e0 commit 3629b10
Show file tree
Hide file tree
Showing 176 changed files with 64,716 additions and 44,669 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
strategy:
fail-fast: false
matrix:
api-level: [ 23, 34 ] # TODO: add 21
api-level: [ 23, 35 ] # TODO: add 21
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
Expand All @@ -102,7 +102,7 @@ jobs:
cache: true
- uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: "Get Flutter dependencies"
Expand All @@ -122,7 +122,7 @@ jobs:
script: cd example && flutter test integration_test/main.dart --timeout=1800s -r expanded --coverage --coverage-package maplibre
- name: "Run Codecov"
uses: codecov/codecov-action@v5
if: ${{ matrix.api-level == '34' }}
if: ${{ matrix.api-level == '35' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# integration-test-web:
Expand Down Expand Up @@ -185,7 +185,7 @@ jobs:
cache: true
- uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: "Get Flutter dependencies"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/flutter-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- uses: subosito/flutter-action@v2
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ android {
compileSdk = 34

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

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
jvmTarget = JavaVersion.VERSION_11
}

sourceSets {
Expand Down
27 changes: 27 additions & 0 deletions android/src/main/kotlin/com/github/josxha/maplibre/Helpers.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.josxha.maplibre

import androidx.annotation.Keep
import org.maplibre.android.geometry.LatLngBounds
import org.maplibre.android.offline.OfflineTilePyramidRegionDefinition

@Keep
object Helpers {
/**
* The genreation of OfflineTilePyramidRegionDefinition fails in
* version 0.13.0 of jnigen. That's why this helper function gets used.
*/
fun createOfflineTilePyramidRegionDefinition(
styleURL: String?,
bounds: LatLngBounds,
minZoom: Double,
maxZoom: Double,
pixelRatio: Float,
): OfflineTilePyramidRegionDefinition =
OfflineTilePyramidRegionDefinition(
styleURL,
bounds,
minZoom,
maxZoom,
pixelRatio,
)
}
1 change: 1 addition & 0 deletions example/android/MapLibreAndroid/build.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
configurations.maybeCreate("default")
// https://repo1.maven.org/maven2/org/maplibre/gl/android-sdk/11.7.0/android-sdk-11.7.0.aar
artifacts.add("default", file('android-sdk-11.7.0.aar'))
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
ndkVersion = "26.1.10909125" // flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

defaultConfig {
Expand Down
17 changes: 12 additions & 5 deletions jnigen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ maven_downloads:
- 'org.maplibre.gl:android-sdk-geojson:6.0.1'
preamble: |
// Autogenerated by jnigen. DO NOT EDIT!
// ignore_for_file: public_member_api_docs
// ignore_for_file: require_trailing_commas
// ignore_for_file: unnecessary_raw_strings
Expand All @@ -20,7 +20,7 @@ preamble: |
android_sdk_config:
add_gradle_deps: true
android_example: 'example/'
suspend_fun_to_async: true
#suspend_fun_to_async: true
output:
dart:
path: 'lib/src/platform/android/jni/'
Expand All @@ -30,11 +30,12 @@ classes:
# https://github.com/maplibre/maplibre-native/tree/main/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android
- 'android.graphics.PointF'
- 'android.location.Location'
- 'com.github.josxha.maplibre.Helpers'
- 'com.github.josxha.maplibre.MapLibreRegistry'
- 'java.net.URI'
- 'java.net.URL'
# - 'io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding'
# - 'io.flutter.plugin.common.PluginRegistry'
- 'io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding'
- 'io.flutter.plugin.common.PluginRegistry'
- 'org.maplibre.android.MapLibre'
- 'org.maplibre.android.attribution'
- 'org.maplibre.android.camera'
Expand All @@ -45,7 +46,13 @@ classes:
- 'org.maplibre.android.location'
- 'org.maplibre.android.log'
- 'org.maplibre.android.maps'
- 'org.maplibre.android.offline'
# error - 'org.maplibre.android.offline'
# - 'org.maplibre.android.offline.OfflineGeometryRegionDefinition'
- 'org.maplibre.android.offline.OfflineManager'
- 'org.maplibre.android.offline.OfflineRegion'
- 'org.maplibre.android.offline.OfflineRegionDefinition'
- 'org.maplibre.android.offline.OfflineRegionError'
- 'org.maplibre.android.offline.OfflineRegionStatus'
- 'org.maplibre.android.storage'
- 'org.maplibre.android.style.layers'
- 'org.maplibre.android.style.light'
Expand Down
6 changes: 3 additions & 3 deletions lib/src/platform/android/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extension LngLatBoundsExt on LngLatBounds {
longitudeEast,
latitudeSouth,
longitudeWest,
);
)!;
}

/// Extension methods for the [jni.LatLngBounds] class. Not exported publicly.
Expand Down Expand Up @@ -103,11 +103,11 @@ extension OfflineRegionExt on jni.OfflineRegion {
// TODO add getMetadata();
final region = OfflineRegion(
id: getId(),
bounds: jDefinition.getBounds().toLngLatBounds(releaseOriginal: true),
bounds: jDefinition.getBounds()!.toLngLatBounds(releaseOriginal: true),
minZoom: jDefinition.getMinZoom(),
maxZoom: jDefinition.getMaxZoom(),
pixelRatio: jDefinition.getPixelRatio(),
styleUrl: jDefinition.getStyleURL().toDartString(releaseOriginal: true),
styleUrl: jDefinition.getStyleURL()!.toDartString(releaseOriginal: true),
);
jDefinition.release();
return region;
Expand Down
Loading

0 comments on commit 3629b10

Please sign in to comment.