Skip to content

Commit

Permalink
Update gradle config to declarative plugin blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaumeise03 committed Sep 15, 2024
1 parent a911650 commit a9e038a
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 36 deletions.
55 changes: 41 additions & 14 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
// def localProperties = new Properties()
// def localPropertiesFile = rootProject.file('local.properties')
// if (localPropertiesFile.exists()) {
// localPropertiesFile.withReader('UTF-8') { reader ->
// localProperties.load(reader)
// }
// }
//
// 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.")
// }
//

// apply plugin: 'com.android.application'
// apply plugin: 'kotlin-android'
// apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
// apply plugin: 'com.google.gms.google-services' // Google Services plugin
// apply plugin: 'com.google.firebase.crashlytics'

plugins {
id 'com.android.application'
id 'kotlin-android'
id "dev.flutter.flutter-gradle-plugin"
id 'com.google.gms.google-services' // Google Services plugin
id 'com.google.firebase.crashlytics'
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,29 +34,17 @@ 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'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
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.google.gms.google-services' // Google Services plugin
apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 33
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -62,10 +78,21 @@ android {
}

buildTypes {
/* Notes for the minifyEnable: Flutter 3.19+ does not compile with minSdkVersion <24, unless
* this option is set to true. For more information, see
* https://stackoverflow.com/a/78019688 and https://stackoverflow.com/a/78149818
*/
release {
signingConfig signingConfigs.release
// shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//minifyEnabled true fixes this issue and allows you to use minSdkVersion 21
minifyEnabled true
}

debug {
//minifyEnabled true fixes this issue and allows you to use minSdkVersion 21
minifyEnabled true
}
}

Expand All @@ -81,6 +108,6 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
28 changes: 14 additions & 14 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
buildscript {
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.14' // Google Services plugin
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
}
}
// buildscript {
// ext.kotlin_version = '1.8.20'
// repositories {
// google()
// mavenCentral()
// }
//
// dependencies {
// classpath 'com.android.tools.build:gradle:7.4.2'
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath 'com.google.gms:google-services:4.3.14' // Google Services plugin
// classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
// }
// }

allprojects {
repositories {
Expand Down
46 changes: 38 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
include ':app'
// include ':app'
//
// def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
// def properties = new Properties()
//
// assert localPropertiesFile.exists()
// localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
//
// 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"

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
localPropertiesFile.withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

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"
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.4.2" apply false
id "org.jetbrains.kotlin.android" version "1.8.20" apply false
id 'com.google.gms.google-services' version "4.3.1" apply false // Google Services plugin
id 'com.google.firebase.crashlytics' version "2.9.9" apply false
}

include ":app"
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import file_selector_macos
import firebase_analytics
import firebase_core
import firebase_crashlytics
import firebase_remote_config
import flutter_local_notifications
import package_info_plus
import path_provider_foundation
Expand All @@ -21,6 +22,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAnalyticsPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin"))
FLTFirebaseRemoteConfigPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseRemoteConfigPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
Expand Down

0 comments on commit a9e038a

Please sign in to comment.