Skip to content

Commit a24a1db

Browse files
authored
flutter-example: migrate legacy buildscript (#2644)
* migrate flutter android to use declarative plugins block * formatting * formatting
1 parent 9a0bac7 commit a24a1db

File tree

5 files changed

+39
-46
lines changed

5 files changed

+39
-46
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
cmake_minimum_required(VERSION 3.6)
22
project(sentry-sample LANGUAGES C CXX)
33

4+
include("${CMAKE_CURRENT_SOURCE_DIR}/../../../sentry-native/sentry-native.cmake")
45
add_library(native-sample SHARED src/main/cpp/native-sample.cpp)
56

67
find_library(LOG_LIB log)
78

8-
include (${ANDROID_GRADLE_NATIVE_BUNDLE_PLUGIN_MK})
9-
109
target_link_libraries(
1110
native-sample PRIVATE
1211
${LOG_LIB}
13-
${ANDROID_GRADLE_NATIVE_MODULES}
12+
sentry_flutter_plugin # Use the alias defined in sentry-native.cmake
1413
)

flutter/example/android/app/build.gradle

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
6+
// uncomment this to upload proguard mapping file and debug symbols to Sentry
7+
// and also set the token (sentry.properties) file
8+
// id "io.sentry.android.gradle"
9+
}
10+
111
def localProperties = new Properties()
212
def localPropertiesFile = rootProject.file('local.properties')
313
if (localPropertiesFile.exists()) {
@@ -6,11 +16,6 @@ if (localPropertiesFile.exists()) {
616
}
717
}
818

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-
1419
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1520
if (flutterVersionCode == null) {
1621
flutterVersionCode = '1'
@@ -21,15 +26,6 @@ if (flutterVersionName == null) {
2126
flutterVersionName = '1.0'
2227
}
2328

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
apply plugin: 'com.ydq.android.gradle.native-aar.import'
28-
29-
// uncomment this to upload proguard mapping file and debug symbols to Sentry
30-
// and also set the token (sentry.properties) file
31-
// apply plugin: 'io.sentry.android.gradle'
32-
3329
android {
3430
namespace = "io.sentry.samples.flutter"
3531
compileOptions {
@@ -41,7 +37,7 @@ android {
4137
languageVersion = "1.4"
4238
}
4339

44-
compileSdkVersion 34
40+
compileSdkVersion 35
4541

4642
sourceSets {
4743
main.java.srcDirs += 'src/main/kotlin'
@@ -50,7 +46,7 @@ android {
5046
defaultConfig {
5147
applicationId "io.sentry.samples.flutter"
5248
minSdkVersion flutter.minSdkVersion
53-
targetSdkVersion 34
49+
targetSdkVersion 35
5450
versionCode flutterVersionCode.toInteger()
5551
versionName flutterVersionName
5652

@@ -99,7 +95,6 @@ flutter {
9995
}
10096

10197
dependencies {
102-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
10398
implementation "androidx.annotation:annotation:1.1.0"
10499
}
105100

flutter/example/android/build.gradle

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
buildscript {
2-
ext.kotlin_version = '2.0.21'
3-
4-
repositories {
5-
google()
6-
mavenCentral()
7-
}
8-
9-
dependencies {
10-
classpath 'io.sentry:sentry-android-gradle-plugin:4.12.0'
11-
classpath 'com.android.tools.build:gradle:8.3.2'
12-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13-
classpath 'io.github.howardpang:androidNativeBundle:1.1.5'
14-
}
15-
}
16-
171
allprojects {
182
repositories {
193
google()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Oct 16 15:46:36 CEST 2024
1+
#Wed Jan 29 14:45:29 CET 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists
Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
include ':app'
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+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

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"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.2.2" apply false
22+
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
23+
id "io.sentry.android.gradle" version "4.14.1" apply false
24+
}
25+
26+
include ":app"

0 commit comments

Comments
 (0)