Skip to content

Commit 210d43c

Browse files
Taym95ened
authored andcommitted
Add Github actions and Migrate to latest Android SDK, AGP and protobuf plugin (PhilipsHue#830)
* chore: Migrate to latest Android SDK, AGP and protobuf plugin * Remove unused files * Bumps to Dart 2.17 minimum and upgrades melos to 3.1.0 (PhilipsHue#762) * Bumps to Dart 2.17 minimum and upgrades melos to 3.1.0 * Update root pubspec.yaml with the correct workspace name * Add GitHub actions Co-authored-by: Taym Haddadi <[email protected]> Co-authored-by: Sebastian Roth <[email protected]>
1 parent 6c4695e commit 210d43c

File tree

14 files changed

+97
-107
lines changed

14 files changed

+97
-107
lines changed

.github/workflows/main.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "Build"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: macos-latest
13+
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v3
17+
18+
- name: Set Up Java
19+
uses: actions/[email protected]
20+
with:
21+
distribution: 'oracle'
22+
java-version: '19.0.2'
23+
24+
- name: Set Up Flutter
25+
uses: subosito/flutter-action@v2
26+
with:
27+
flutter-version: '3.16.3'
28+
channel: 'stable'
29+
30+
- name: Set up debug keystore
31+
run: |
32+
rm -f ~/.android/debug.keystore
33+
keytool -genkeypair \
34+
-alias androiddebugkey \
35+
-keypass android \
36+
-keystore ~/.android/debug.keystore \
37+
-storepass android \
38+
-dname 'CN=Android Debug,O=Android,C=US' \
39+
-keyalg 'RSA' \
40+
-keysize 2048 \
41+
-validity 10000
42+
43+
- name: Quality checks monorepo
44+
run: |
45+
./bin/quality_checks.sh
46+
47+
- name: Android native tests
48+
run: |
49+
#!/bin/bash -ex
50+
cd example/android && ls && ./gradlew detekt && ./gradlew testDebugUnitTest
51+
52+
- name: Build android app
53+
run: |
54+
cd example && flutter build apk --debug
55+
56+
- name: Build iOS app
57+
run: |
58+
find . -name "Podfile" -execdir pod install \;
59+
cd example && flutter build ios --debug --no-codesign

bin/quality_checks.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/bash -ex
2-
#workaround for codemagic CI since melos is not in bash
3-
echo 'export PATH="$PATH":"$FLUTTER_ROOT/.pub-cache/bin"' >>~/.bashrc
4-
echo 'export PATH="$PATH":"$FLUTTER_ROOT/bin"' >>~/.bashrc
5-
source ~/.bashrc
2+
export PATH="$PATH:$FLUTTER_ROOT/.pub-cache/bin"
3+
export PATH="$PATH:$FLUTTER_ROOT/bin"
64

75
dart pub global activate melos
86

codemagic.yaml

Lines changed: 0 additions & 58 deletions
This file was deleted.

example/android/app/build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 31
29+
compileSdkVersion 33
3030

3131
sourceSets {
3232
main.java.srcDirs += 'src/main/kotlin'
3333
}
3434

35-
lintOptions {
36-
disable 'InvalidPackage'
37-
}
3835

3936
compileOptions {
4037
sourceCompatibility JavaVersion.VERSION_1_8
@@ -48,7 +45,7 @@ android {
4845
defaultConfig {
4946
applicationId "com.signify.hue.reactivebleexample"
5047
minSdkVersion 21
51-
targetSdkVersion 31
48+
targetSdkVersion 33
5249
versionCode flutterVersionCode.toInteger()
5350
versionName flutterVersionName
5451
}
@@ -59,6 +56,11 @@ android {
5956
signingConfig signingConfigs.debug
6057
}
6158
}
59+
namespace 'com.signify.hue.reactivebleexample'
60+
61+
lint {
62+
disable 'InvalidPackage'
63+
}
6264
}
6365

6466
flutter {

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.signify.hue.reactivebleexample">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32

43
<uses-permission android:name="android.permission.INTERNET" />
54
<!-- required for API 18 - 30 -->

example/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
buildscript {
2-
ext.kotlin_version = '1.5.31'
2+
ext.kotlin_version = '1.8.21'
33
repositories {
44
mavenCentral()
55
google()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.0.2'
9+
classpath 'com.android.tools.build:gradle:8.0.2'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}

example/android/gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
android.enableJetifier=true
1+
android.defaults.buildfeatures.buildconfig=true
2+
android.enableJetifier=false
3+
android.nonFinalResIds=false
4+
android.nonTransitiveRClass=false
25
android.useAndroidX=true
36
org.gradle.jvmargs=-Xmx1536M

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip

example/android/settings.gradle

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
include ':app'
22

3-
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
3+
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4+
def properties = new Properties()
45

5-
def plugins = new Properties()
6-
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7-
if (pluginsFile.exists()) {
8-
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9-
}
6+
assert localPropertiesFile.exists()
7+
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
108

11-
plugins.each { name, path ->
12-
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13-
include ":$name"
14-
project(":$name").projectDir = pluginDirectory
15-
}
9+
def flutterSdkPath = properties.getProperty("flutter.sdk")
10+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11+
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

example/lib/src/ui/device_detail/device_detail_screen.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class _DeviceDetail extends StatelessWidget {
3030
final DiscoveredDevice device;
3131
final void Function(String deviceId) disconnect;
3232
@override
33-
Widget build(BuildContext context) => WillPopScope(
34-
onWillPop: () async {
33+
Widget build(BuildContext context) => PopScope(
34+
canPop: true,
35+
onPopInvoked: (_) async {
3536
disconnect(device.id);
36-
return true;
3737
},
3838
child: DefaultTabController(
3939
length: 2,

0 commit comments

Comments
 (0)