Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update Android project to Android Gradle Plugin 8.2 #43

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 144 additions & 35 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,161 @@
name: Build and Test
on: [push, pull_request]
on:
techouse marked this conversation as resolved.
Show resolved Hide resolved
push:
pull_request:
defaults:
run:
shell: bash
env:
PUB_ENVIRONMENT: bot.github
# pinned to latest stable version
FLUTTER_SDK_VERSION: 3.19.3

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Flutter SDK
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_SDK_VERSION }}
channel: "stable"
cache: true
- name: Install dependencies
run: flutter pub get
- name: Run tests
run: flutter test
- name: Cleanup
if: ${{ always() }}
run: |
if command -v flutter &>/dev/null; then
flutter clean
fi
build-android:
needs: test
name: Build Android flutter app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: "12.x"
- uses: subosito/flutter-action@v2
distribution: "temurin"
java-version: "17"
cache: "gradle"
- name: Setup Flutter SDK
uses: subosito/flutter-action@v2
with:
flutter-version: "3.3.8"
channel: 'stable'
- run: |
cd example
flutter pub get
flutter test
flutter build apk
flutter build appbundle
flutter-version: ${{ env.FLUTTER_SDK_VERSION }}
channel: "stable"
cache: true
- name: Install example dependencies
working-directory: example
run: flutter pub get
- name: Test example
working-directory: example
run: flutter test
- name: Build example APK
working-directory: example
run: flutter build apk
- name: Check if example APK exists
working-directory: example
run: |
set -e
if [ ! -f build/app/outputs/apk/release/app-release.apk ]; then
echo "APK file not found!"
exit 1
fi
- name: Build example App Bundle
working-directory: example
run: flutter build appbundle
- name: Check if example App Bundle exists
working-directory: example
run: |
set -e
if [ ! -f build/app/outputs/bundle/release/app-release.aab ]; then
echo "App Bundle not found!"
exit 1
fi
- name: Cleanup
if: ${{ always() }}
working-directory: example
run: |
rm -rf build
if command -v flutter &>/dev/null; then
flutter clean
fi
build-ios:
needs: test
name: Build iOS flutter app
runs-on: macos-latest
runs-on: macos-14
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v1
with:
java-version: "12.x"
- uses: subosito/flutter-action@v2
- uses: actions/checkout@v4
- name: Setup Flutter SDK
uses: subosito/flutter-action@v2
with:
flutter-version: "3.3.8"
channel: 'stable'
- run: |
cd example
flutter pub get
flutter test
flutter build apk
flutter build ios --release --no-codesign
flutter-version: ${{ env.FLUTTER_SDK_VERSION }}
channel: "stable"
cache: true
- name: Install example dependencies
working-directory: example
run: flutter pub get
- name: Test
working-directory: example
run: flutter test
- name: Build unsigned example Xcode archive
working-directory: example
run: flutter build ipa --no-codesign
- name: Check if unsigned example Xcode archive exists
working-directory: example
run: |
set -e
if [ ! -d build/ios/archive/Runner.xcarchive ]; then
echo "Xcode archive not found!"
exit 1
fi
- name: Cleanup
if: ${{ always() }}
working-directory: example
run: |
rm -rf build
if command -v flutter &>/dev/null; then
flutter clean
fi
build-web:
needs: test
name: Build web flutter app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- uses: actions/checkout@v4
- name: Setup Flutter SDK
uses: subosito/flutter-action@v2
with:
flutter-version: "3.3.8"
channel: 'stable'
- run: |
cd example
flutter pub get
flutter build web
flutter-version: ${{ env.FLUTTER_SDK_VERSION }}
channel: "stable"
cache: true
- name: Install example dependencies
working-directory: example
run: flutter pub get
- name: Test example
working-directory: example
run: flutter test
- name: Build example web
working-directory: example
run: flutter build web
- name: Check if example web exists
working-directory: example
run: |
set -e
if [ ! -f build/web/flutter.js ]; then
echo "Web build not found!"
exit 1
fi
- name: Cleanup
if: ${{ always() }}
working-directory: example
run: |
rm -rf build
if command -v flutter &>/dev/null; then
flutter clean
fi
19 changes: 15 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'com.mparticle.mparticle_flutter_sdk'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.7.21'
ext.kotlin_version = '1.9.22'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -25,18 +25,29 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 33
namespace "com.mparticle.mparticle_flutter_sdk"

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion 16
compileSdkVersion 34
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.mparticle:android-core:5+'

// Required for gathering Android Advertising ID (see below)
Expand Down
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mparticle.mparticle_flutter_sdk">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
30 changes: 21 additions & 9 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "dev.flutter.flutter-gradle-plugin"
id "org.jetbrains.kotlin.android"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -21,12 +27,19 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
namespace "com.mparticle.mparticle_flutter_sdk_example"

compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -35,7 +48,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mparticle.mparticle_flutter_sdk_example"
minSdkVersion 16
minSdkVersion flutter.minSdkVersion
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand All @@ -55,12 +68,11 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.mparticle:android-core:5+'

// Required for gathering Android Advertising ID (see below)
implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'

// Recommended to query the Google Play install referrer
implementation 'com.android.installreferrer:installreferrer:1.0'
implementation 'com.android.installreferrer:installreferrer:2.2'
}
3 changes: 1 addition & 2 deletions example/android/app/src/main/AndroidManifest.xml
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="com.mparticle.mparticle_flutter_sdk_example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name=".ExampleApplication"
android:label="mparticle_flutter_sdk_example"
Expand Down
21 changes: 5 additions & 16 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
buildscript {
ext.kotlin_version = '1.7.21'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
subprojects {
project.evaluationDependsOn(":app")
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
6 changes: 5 additions & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx4G
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.enableR8.fullMode=false
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
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.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
Loading