Skip to content

Commit 929d83c

Browse files
MonsieurRzMoralCode
authored andcommitted
Migration to a flutter 3 android compatible config.
graddle bump from version 6.7 to 8.5 kotlin bump from version 1.6.21 to 1.9.10 permission_handler upgrade from 10.2.0 to 11.1.0
1 parent 4d58051 commit 929d83c

6 files changed

Lines changed: 47 additions & 60 deletions

File tree

example/android/app/build.gradle

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,23 @@
1-
def localProperties = new Properties()
2-
def localPropertiesFile = rootProject.file('local.properties')
3-
if (localPropertiesFile.exists()) {
4-
localPropertiesFile.withReader('UTF-8') { reader ->
5-
localProperties.load(reader)
6-
}
7-
}
8-
9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
14-
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15-
if (flutterVersionCode == null) {
16-
flutterVersionCode = '1'
17-
}
18-
19-
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20-
if (flutterVersionName == null) {
21-
flutterVersionName = '1.0'
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
225
}
236

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
287
android {
8+
namespace "com.example.fresh_example"
299
// Any value starting with "flutter." get its value from
3010
// the Flutter Gradle plugin.
3111
compileSdk flutter.compileSdkVersion
3212

13+
compileOptions {
14+
sourceCompatibility JavaVersion.VERSION_17
15+
targetCompatibility JavaVersion.VERSION_17
16+
}
17+
18+
kotlinOptions {
19+
jvmTarget = '17'
20+
}
3321
sourceSets {
3422
main.java.srcDirs += 'src/main/kotlin'
3523
}
@@ -38,11 +26,11 @@ android {
3826
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3927
applicationId "com.example.fresh_example"
4028
// You can update the following value to match your application needs.
41-
minSdkVersion flutter.minSdkVersion
42-
targetSdkVersion flutter.targetSdkVersion
29+
minSdk flutter.minSdkVersion
30+
targetSdk flutter.targetSdkVersion
4331
// You can set these values in the property declaration or use a variable
44-
versionCode flutterVersionCode.toInteger()
45-
versionName flutterVersionName
32+
versionCode flutter.versionCode.toInteger()
33+
versionName flutter.versionName
4634
}
4735

4836
buildTypes {
@@ -57,7 +45,3 @@ android {
5745
flutter {
5846
source '../..'
5947
}
60-
61-
dependencies {
62-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
63-
}

example/android/build.gradle

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
buildscript {
2-
ext.kotlin_version = '1.6.21'
3-
repositories {
4-
google()
5-
jcenter()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.4.1'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()
17-
jcenter()
4+
mavenCentral()
185
}
196
}
207

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#Fri Jun 23 08:50:38 CEST 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip

example/android/settings.gradle

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
include ':app'
21

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
2+
pluginManagement {
3+
def flutterSdkPath = {
4+
def properties = new Properties()
5+
file("local.properties").withInputStream { properties.load(it) }
6+
def flutterSdkPath = properties.getProperty("flutter.sdk")
7+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
8+
return flutterSdkPath
9+
}()
510

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
11+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
812

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"
13+
repositories {
14+
google()
15+
mavenCentral()
16+
gradlePluginPortal()
17+
}
18+
}
19+
20+
plugins {
21+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
22+
id "com.android.application" version "8.2.1" apply false
23+
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
24+
}
25+
26+
include ":app"

example/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1818
version: 1.0.0+1
1919

2020
environment:
21-
sdk: ">=2.12.0 <3.0.0"
21+
sdk: '>=3.2.0 <4.0.0'
2222

2323
dependencies:
2424
flutter:
@@ -31,7 +31,7 @@ dependencies:
3131

3232
c2bluetooth:
3333
path: ../
34-
permission_handler: ^10.2.0
34+
permission_handler: ^11.1.0
3535

3636
dev_dependencies:
3737
flutter_test:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 0.1.6
44
repository: https://github.com/CrewLAB/c2bluetooth
55

66
environment:
7-
sdk: ">=2.15.0 <3.0.0"
7+
sdk: '>=3.2.0 <4.0.0'
88
flutter: ">=1.17.0"
99

1010
dependencies:

0 commit comments

Comments
 (0)