Skip to content

Commit e7cce5b

Browse files
committed
Upgrade example/android to use gradle.kts
1 parent 0b7e4bd commit e7cce5b

File tree

12 files changed

+125
-107
lines changed

12 files changed

+125
-107
lines changed

example/android/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ gradle-wrapper.jar
55
/gradlew.bat
66
/local.properties
77
GeneratedPluginRegistrant.java
8+
.cxx/
89

910
# Remember to never publicly share your keystore.
10-
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
# See https://flutter.dev/to/reference-keystore
1112
key.properties
1213
**/*.keystore
1314
**/*.jks

example/android/app/build.gradle

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import java.util.Properties
2+
import java.io.FileInputStream
3+
4+
plugins {
5+
id("com.android.application")
6+
id("kotlin-android")
7+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
8+
id("dev.flutter.flutter-gradle-plugin")
9+
}
10+
11+
val keystoreProperties = Properties()
12+
val keystorePropertiesFile = rootProject.file("key.properties")
13+
if (keystorePropertiesFile.exists()) {
14+
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
15+
}
16+
17+
android {
18+
namespace = "dev.flchart.app"
19+
compileSdk = flutter.compileSdkVersion
20+
ndkVersion = flutter.ndkVersion
21+
22+
compileOptions {
23+
sourceCompatibility = JavaVersion.VERSION_11
24+
targetCompatibility = JavaVersion.VERSION_11
25+
}
26+
27+
kotlinOptions {
28+
jvmTarget = JavaVersion.VERSION_11.toString()
29+
}
30+
31+
defaultConfig {
32+
applicationId = "dev.flchart.app"
33+
minSdk = flutter.minSdkVersion
34+
targetSdk = flutter.targetSdkVersion
35+
versionCode = flutter.versionCode
36+
versionName = flutter.versionName
37+
}
38+
39+
signingConfigs {
40+
create("release") {
41+
keyAlias = keystoreProperties["keyAlias"] as String
42+
keyPassword = keystoreProperties["keyPassword"] as String
43+
storeFile = keystoreProperties["storeFile"]?.let { file(it) }
44+
storePassword = keystoreProperties["storePassword"] as String
45+
}
46+
}
47+
48+
buildTypes {
49+
release {
50+
signingConfig = signingConfigs.getByName("release")
51+
}
52+
}
53+
}
54+
55+
flutter {
56+
source = "../.."
57+
}

example/android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="dev.flchart.app">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32
<!-- The INTERNET permission is required for development. Specifically,
43
the Flutter tool needs it to communicate with the running application
54
to allow setting breakpoints, to provide hot reload, etc.

example/android/app/src/main/AndroidManifest.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="dev.flchart.app">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32
<uses-permission android:name="android.permission.INTERNET"/>
43
<queries>
54
<intent>
@@ -10,6 +9,16 @@
109
<action android:name="android.intent.action.VIEW" />
1110
<data android:scheme="https" />
1211
</intent>
12+
13+
<!-- Required to query activities that can process text, see:
14+
https://developer.android.com/training/package-visibility and
15+
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
16+
17+
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
18+
<intent>
19+
<action android:name="android.intent.action.PROCESS_TEXT"/>
20+
<data android:mimeType="text/plain"/>
21+
</intent>
1322
</queries>
1423
<application
1524
android:label="FL Chart App"
@@ -19,6 +28,7 @@
1928
android:name=".MainActivity"
2029
android:exported="true"
2130
android:launchMode="singleTop"
31+
android:taskAffinity=""
2232
android:theme="@style/LaunchTheme"
2333
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
2434
android:hardwareAccelerated="true"

example/android/app/src/profile/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="dev.flchart.app">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32
<!-- The INTERNET permission is required for development. Specifically,
43
the Flutter tool needs it to communicate with the running application
54
to allow setting breakpoints, to provide hot reload, etc.

example/android/build.gradle

Lines changed: 0 additions & 18 deletions
This file was deleted.

example/android/build.gradle.kts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
allprojects {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
}
7+
8+
val newBuildDir: Directory =
9+
rootProject.layout.buildDirectory
10+
.dir("../../build")
11+
.get()
12+
rootProject.layout.buildDirectory.value(newBuildDir)
13+
14+
subprojects {
15+
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
16+
project.layout.buildDirectory.value(newSubprojectBuildDir)
17+
}
18+
subprojects {
19+
project.evaluationDependsOn(":app")
20+
}
21+
22+
tasks.register<Delete>("clean") {
23+
delete(rootProject.layout.buildDirectory)
24+
}

example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
1+
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip

0 commit comments

Comments
 (0)