Skip to content

Commit 884fbb0

Browse files
committed
Fix android gradle configuration
1 parent 4a9fa7a commit 884fbb0

File tree

4 files changed

+49
-33
lines changed

4 files changed

+49
-33
lines changed

rollbar_flutter/android/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ rootProject.allprojects {
2828
}
2929
}
3030

31-
apply plugin: 'com.android.library'
32-
apply plugin: 'checkstyle'
33-
apply plugin: "com.github.spotbugs"
31+
plugins {
32+
id "com.android.library"
33+
id "checkstyle"
34+
id "com.github.spotbugs"
35+
}
3436

3537
android {
3638
compileSdkVersion 31

rollbar_flutter/example/android/app/build.gradle

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ if (localPropertiesFile.exists()) {
66
}
77
}
88

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-
149
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1510
if (flutterVersionCode == null) {
1611
flutterVersionCode = '1'
@@ -21,8 +16,10 @@ if (flutterVersionName == null) {
2116
flutterVersionName = '1.0'
2217
}
2318

24-
apply plugin: 'com.android.application'
25-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
19+
plugins {
20+
id "com.android.application"
21+
id "dev.flutter.flutter-gradle-plugin"
22+
}
2623

2724
android {
2825
compileSdkVersion flutter.compileSdkVersion
@@ -38,7 +35,7 @@ android {
3835

3936
defaultConfig {
4037
applicationId "com.rollbar.flutter.example"
41-
minSdkVersion 19
38+
minSdkVersion flutter.minSdkVersion
4239
targetSdkVersion flutter.targetSdkVersion
4340
versionCode flutterVersionCode.toInteger()
4441
versionName flutterVersionName
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
buildscript {
2-
repositories {
3-
google()
4-
mavenCentral()
5-
}
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
69

7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:7.1.2'
9-
}
10-
}
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
1111

12-
allprojects {
1312
repositories {
1413
google()
1514
mavenCentral()
15+
gradlePluginPortal()
1616
}
1717
}
1818

19-
rootProject.buildDir = '../build'
20-
subprojects {
21-
project.buildDir = "${rootProject.buildDir}/${project.name}"
22-
}
23-
subprojects {
24-
project.evaluationDependsOn(':app')
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "7.1.2" apply false
2522
}
2623

27-
tasks.register("clean", Delete) {
28-
delete rootProject.buildDir
29-
}
24+
include ":app"
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
9+
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11+
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
18+
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
}
22+
123
include ':app'
224

325
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
@@ -6,6 +28,6 @@ def properties = new Properties()
628
assert localPropertiesFile.exists()
729
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
830

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"
31+
// def flutterSdkPath = properties.getProperty("flutter.sdk")
32+
// assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
33+
// apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

0 commit comments

Comments
 (0)