Last active
February 27, 2025 05:10
-
-
Save DRSchlaubi/f42be0da6fbd8864565b043b3da3b8b2 to your computer and use it in GitHub Desktop.
Flutter Kotlin Gradle DSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Properties | |
import java.nio.file.Files | |
val localProperties = Properties() | |
val localPropertiesFile = rootProject.file("local.properties").toPath() | |
if (Files.exists(localPropertiesFile)) { | |
Files.newBufferedReader(localPropertiesFile).use { reader -> | |
localProperties.load(reader) | |
} | |
} | |
val flutterRoot = localProperties.getProperty("flutter.sdk") | |
?: throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | |
val flutterVersionCode = localProperties.getProperty("flutter.versionCode") ?: "1" | |
val flutterVersionName = localProperties.getProperty("flutter.versionName") ?: "1.0" | |
plugins { | |
id("com.android.application") | |
kotlin("android") | |
kotlin("android.extensions") | |
} | |
apply("$flutterRoot/packages/flutter_tools/gradle/flutter.gradle") | |
android { | |
compileSdkVersion(30) | |
lintOptions { | |
disable("InvalidPackage") | |
} | |
defaultConfig { | |
applicationId = "com.linkdesk.android.automator" | |
minSdkVersion(23) | |
targetSdkVersion(30) | |
versionCode = flutterVersionCode.toInt() | |
versionName = flutterVersionName | |
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | |
} | |
signingConfigs { | |
create("release") { | |
storeFile = file("<>") | |
storePassword = "<>" | |
keyAlias = "<>" | |
keyPassword = "<>" | |
} | |
} | |
buildTypes { | |
getByName("release") { | |
// Signing with the debug keys for now, so `flutter run --release` works. | |
signingConfig = signingConfigs.getByName("release") | |
} | |
} | |
buildToolsVersion = "29.0.3" | |
compileOptions { | |
sourceCompatibility = JavaVersion.VERSION_1_8 | |
targetCompatibility = JavaVersion.VERSION_1_8 | |
} | |
kotlinOptions { | |
jvmTarget = "1.8" | |
} | |
} | |
project.extensions.getByName("flutter").apply { | |
this::class.java.getMethod("source", String::class.java).invoke(this, "../..") | |
} | |
dependencies { | |
testImplementation("junit:junit:4.13") | |
androidTestImplementation("androidx.test.ext:junit:1.1.1") | |
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0") | |
implementation("androidx.core:core-ktx:1.3.1") | |
implementation(kotlin("stdlib-jdk7")) | |
} | |
apply(plugin = "io.fabric") | |
// Google Play services Gradle plugin | |
apply(plugin = "com.google.gms.google-services") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
extra.set("kotlin_version", "1.3.72") | |
repositories { | |
google() | |
jcenter() | |
maven("https://maven.fabric.io/public") | |
} | |
dependencies { | |
classpath("com.android.tools.build:gradle:4.0.1") | |
classpath("com.google.gms:google-services:4.3.3") // Google Services plugin | |
classpath(kotlin("gradle-plugin", version = "1.3.72")) | |
} | |
} | |
allprojects { | |
repositories { | |
google() | |
jcenter() | |
} | |
} | |
rootProject.buildDir = file("../build") | |
subprojects { | |
project.buildDir = file("${rootProject.buildDir}/${project.name}") | |
project.evaluationDependsOn(":app") | |
} | |
tasks { | |
task<Delete>("clean") { | |
delete( rootProject.buildDir) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.file.Files | |
import java.util.* | |
include(":app") | |
val flutterProjectRoot = rootDir.toPath().parent | |
val plugins = Properties() | |
val pluginsFile = flutterProjectRoot.resolve(".flutter-plugins") | |
if (Files.exists(pluginsFile)) { | |
Files.newBufferedReader(pluginsFile).use { plugins.load(it) } | |
} | |
plugins.forEach { name, path -> | |
val pluginDirectory = flutterProjectRoot.resolve(path as String).resolve("android") | |
include(":$name") | |
project(":$name").projectDir = pluginDirectory.toFile() | |
} |
flutter build appbundle
caused this. (flutter 3.16.7)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. To migrate
your project, follow the steps at:
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The detected reason was:
No `/Users/jeiea/Documents/project/android/AndroidManifest.xml` file
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Build failed due to use of deprecated Android v1 embedding.
flutter build appbundle
caused this. (flutter 3.16.7)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Warning ────────────────────────────────────────────────────────────────────────────── Your Flutter application is created using an older version of the Android embedding. It is being deprecated in favor of Android embedding v2. To migrate your project, follow the steps at: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ The detected reason was: No `/Users/jeiea/Documents/project/android/AndroidManifest.xml` file ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Build failed due to use of deprecated Android v1 embedding.
I had same error too. In my case, I've updated flutter version from 3.19.6
to 3.22.3
, and it worked.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stuck infinity on 8.3.0-alpha03 + gradle-8.3-bin