Skip to content

flutter-example: migrate legacy buildscript #2644

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

Merged
merged 3 commits into from
Jan 29, 2025
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
5 changes: 2 additions & 3 deletions flutter/example/android/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
cmake_minimum_required(VERSION 3.6)
project(sentry-sample LANGUAGES C CXX)

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

find_library(LOG_LIB log)

include (${ANDROID_GRADLE_NATIVE_BUNDLE_PLUGIN_MK})

target_link_libraries(
native-sample PRIVATE
${LOG_LIB}
${ANDROID_GRADLE_NATIVE_MODULES}
sentry_flutter_plugin # Use the alias defined in sentry-native.cmake
)
29 changes: 12 additions & 17 deletions flutter/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"

// uncomment this to upload proguard mapping file and debug symbols to Sentry
// and also set the token (sentry.properties) file
// id "io.sentry.android.gradle"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +16,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,15 +26,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

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

// uncomment this to upload proguard mapping file and debug symbols to Sentry
// and also set the token (sentry.properties) file
// apply plugin: 'io.sentry.android.gradle'

android {
namespace = "io.sentry.samples.flutter"
compileOptions {
Expand All @@ -41,7 +37,7 @@ android {
languageVersion = "1.4"
}

compileSdkVersion 34
compileSdkVersion 35

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -50,7 +46,7 @@ android {
defaultConfig {
applicationId "io.sentry.samples.flutter"
minSdkVersion flutter.minSdkVersion
targetSdkVersion 34
targetSdkVersion 35
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

Expand Down Expand Up @@ -99,7 +95,6 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "androidx.annotation:annotation:1.1.0"
}

Expand Down
16 changes: 0 additions & 16 deletions flutter/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
buildscript {
ext.kotlin_version = '2.0.21'

repositories {
google()
mavenCentral()
}

dependencies {
classpath 'io.sentry:sentry-android-gradle-plugin:4.12.0'
classpath 'com.android.tools.build:gradle:8.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.github.howardpang:androidNativeBundle:1.1.5'
}
}

allprojects {
repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 16 15:46:36 CEST 2024
#Wed Jan 29 14:45:29 CET 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
31 changes: 23 additions & 8 deletions flutter/example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.2.2" apply false
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
id "io.sentry.android.gradle" version "4.14.1" apply false
}

include ":app"
Loading