Skip to content

Commit

Permalink
feat(android): Add support for AGP 8 in example, add compileOptions t…
Browse files Browse the repository at this point in the history
…o build.gradle (#1503)

# Description

* Add support for AGP 8 in example
* Set kotlinOptions & compileOptions: sourceCompatibility and targetCompatibility
* Bump version of core-ktx

## Related Issues

#1514

---------

Co-authored-by: Gustl22 <git@reb0.org>
  • Loading branch information
Skyost and Gustl22 authored Jul 20, 2023
1 parent 9f662f3 commit 7c08e4e
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ jobs:
if: inputs.enable_android
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
# AGP8 needs JDK 17
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,16 @@ jobs:
if: inputs.enable_android
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
# AGP8 needs JDK 17
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: 'stable'
# TODO: use `inputs.flutter_version` and change to `stable`, when flutter/flutter#125657 has been released.
flutter-version: '3.13.0-0.1.pre'
channel: 'beta'
- uses: bluefireteam/melos-action@main

- name: Download Android emulator image
Expand Down
10 changes: 6 additions & 4 deletions packages/audioplayers/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdk 33

namespace 'xyz.luan.audioplayers.example'

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
kotlin {
jvmToolchain(17)
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xyz.luan.audioplayers.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xyz.luan.audioplayers.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xyz.luan.audioplayers.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
4 changes: 2 additions & 2 deletions packages/audioplayers/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.9.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
11 changes: 10 additions & 1 deletion packages/audioplayers_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ android {
namespace 'xyz.luan.audioplayers'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
Expand All @@ -59,7 +68,7 @@ allprojects {
}

dependencies {
implementation "androidx.core:core-ktx:1.9.0"
implementation "androidx.core:core-ktx:1.10.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
Expand Down

0 comments on commit 7c08e4e

Please sign in to comment.