Skip to content

Commit 1c79a62

Browse files
[Example] android: re-run flutter create to update to current recommended project setup
1 parent 8b19773 commit 1c79a62

File tree

17 files changed

+122
-91
lines changed

17 files changed

+122
-91
lines changed

example/.metadata

+21-6
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,35 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "13c049b42ceac219503e0662eaee9b9bb171ac3a"
8-
channel: "master"
7+
revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4"
8+
channel: "stable"
99

1010
project_type: app
1111

1212
# Tracks metadata for the flutter migrate command
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 13c049b42ceac219503e0662eaee9b9bb171ac3a
17-
base_revision: 13c049b42ceac219503e0662eaee9b9bb171ac3a
16+
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
17+
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
18+
- platform: android
19+
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
20+
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
1821
- platform: ios
19-
create_revision: 13c049b42ceac219503e0662eaee9b9bb171ac3a
20-
base_revision: 13c049b42ceac219503e0662eaee9b9bb171ac3a
22+
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
23+
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
24+
- platform: linux
25+
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
26+
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
27+
- platform: macos
28+
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
29+
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
30+
- platform: web
31+
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
32+
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
33+
- platform: windows
34+
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
35+
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
2136

2237
# User provided section
2338

example/android/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java
99
# Remember to never publicly share your keystore.
1010
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
1111
key.properties
12+
**/*.keystore
13+
**/*.jks

example/android/app/build.gradle

+29-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
17
def localProperties = new Properties()
28
def localPropertiesFile = rootProject.file('local.properties')
39
if (localPropertiesFile.exists()) {
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
612
}
713
}
814

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-
1415
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1516
if (flutterVersionCode == null) {
1617
flutterVersionCode = '1'
@@ -21,17 +22,31 @@ if (flutterVersionName == null) {
2122
flutterVersionName = '1.0'
2223
}
2324

24-
apply plugin: 'com.android.application'
25-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26-
2725
android {
28-
compileSdkVersion 31
26+
namespace "com.rmawatson.example"
27+
compileSdkVersion flutter.compileSdkVersion
28+
ndkVersion flutter.ndkVersion
29+
30+
compileOptions {
31+
sourceCompatibility JavaVersion.VERSION_1_8
32+
targetCompatibility JavaVersion.VERSION_1_8
33+
}
34+
35+
kotlinOptions {
36+
jvmTarget = '1.8'
37+
}
38+
39+
sourceSets {
40+
main.java.srcDirs += 'src/main/kotlin'
41+
}
2942

3043
defaultConfig {
3144
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
32-
applicationId "com.example.flutterisolateexample"
33-
minSdkVersion 19
34-
targetSdkVersion 30
45+
applicationId "com.rmawatson.example"
46+
// You can update the following values to match your application needs.
47+
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
48+
minSdkVersion flutter.minSdkVersion
49+
targetSdkVersion flutter.targetSdkVersion
3550
versionCode flutterVersionCode.toInteger()
3651
versionName flutterVersionName
3752
}
@@ -48,3 +63,5 @@ android {
4863
flutter {
4964
source '../..'
5065
}
66+
67+
dependencies {}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.example.flutterisolateexample">
3-
<!-- Flutter needs it to communicate with the running application
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<!-- The INTERNET permission is required for development. Specifically,
3+
the Flutter tool needs it to communicate with the running application
44
to allow setting breakpoints, to provide hot reload, etc.
55
-->
66
<uses-permission android:name="android.permission.INTERNET"/>

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

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.example.flutterisolateexample">
3-
4-
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
5-
calls FlutterMain.startInitialization(this); in its onCreate method.
6-
In most cases you can leave this as-is, but you if you want to provide
7-
additional functionality it is fine to subclass or reimplement
8-
FlutterApplication and put your custom class here. -->
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
92
<application
10-
android:name=".MainApplication"
11-
android:label="flutter_isolate_example"
3+
android:label="example"
4+
android:name="${applicationName}"
125
android:icon="@mipmap/ic_launcher">
136
<activity
147
android:name=".MainActivity"
8+
android:exported="true"
159
android:launchMode="singleTop"
1610
android:theme="@style/LaunchTheme"
17-
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
11+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1812
android:hardwareAccelerated="true"
1913
android:windowSoftInputMode="adjustResize">
14+
<!-- Specifies an Android theme to apply to this Activity as soon as
15+
the Android process has started. This theme is visible to the user
16+
while the Flutter UI initializes. After that, this theme continues
17+
to determine the Window background behind the Flutter UI. -->
18+
<meta-data
19+
android:name="io.flutter.embedding.android.NormalTheme"
20+
android:resource="@style/NormalTheme"
21+
/>
2022
<intent-filter>
2123
<action android:name="android.intent.action.MAIN"/>
2224
<category android:name="android.intent.category.LAUNCHER"/>
2325
</intent-filter>
2426
</activity>
25-
27+
<!-- Don't delete the meta-data below.
28+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
2629
<meta-data
2730
android:name="flutterEmbedding"
2831
android:value="2" />

example/android/app/src/main/java/com/example/flutterisolateexample/CustomPluginRegistrant.java

-18
This file was deleted.

example/android/app/src/main/java/com/example/flutterisolateexample/MainActivity.java

-6
This file was deleted.

example/android/app/src/main/java/com/example/flutterisolateexample/MainApplication.java

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.rmawatson.example
2+
3+
import io.flutter.embedding.android.FlutterActivity
4+
5+
class MainActivity: FlutterActivity() {
6+
}

example/android/app/src/main/res/values-night/styles.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
44
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
55
<!-- Show a splash screen on the activity. Automatically removed when
6-
Flutter draws its first frame -->
6+
the Flutter engine draws its first frame -->
77
<item name="android:windowBackground">@drawable/launch_background</item>
88
</style>
99
<!-- Theme applied to the Android Window as soon as the process has started.
1010
This theme determines the color of the Android Window while your
1111
Flutter UI initializes, as well as behind your Flutter UI while its
1212
running.
13-
13+
1414
This Theme is only used starting with V2 of Flutter's Android embedding. -->
1515
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
1616
<item name="android:windowBackground">?android:colorBackground</item>
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
3+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
4+
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
45
<!-- Show a splash screen on the activity. Automatically removed when
5-
Flutter draws its first frame -->
6+
the Flutter engine draws its first frame -->
67
<item name="android:windowBackground">@drawable/launch_background</item>
78
</style>
9+
<!-- Theme applied to the Android Window as soon as the process has started.
10+
This theme determines the color of the Android Window while your
11+
Flutter UI initializes, as well as behind your Flutter UI while its
12+
running.
13+
14+
This Theme is only used starting with V2 of Flutter's Android embedding. -->
15+
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
16+
<item name="android:windowBackground">?android:colorBackground</item>
17+
</style>
818
</resources>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.example.flutterisolateexample">
3-
<!-- Flutter needs it to communicate with the running application
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<!-- The INTERNET permission is required for development. Specifically,
3+
the Flutter tool needs it to communicate with the running application
44
to allow setting breakpoints, to provide hot reload, etc.
55
-->
66
<uses-permission android:name="android.permission.INTERNET"/>

example/android/build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
buildscript {
2+
ext.kotlin_version = '1.7.10'
23
repositories {
34
google()
45
mavenCentral()
56
}
67

78
dependencies {
8-
classpath 'com.android.tools.build:gradle:4.1.3'
9+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
910
}
1011
}
1112

@@ -24,6 +25,6 @@ subprojects {
2425
project.evaluationDependsOn(':app')
2526
}
2627

27-
task clean(type: Delete) {
28+
tasks.register("clean", Delete) {
2829
delete rootProject.buildDir
2930
}

example/android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
org.gradle.jvmargs=-Xmx1536M
1+
org.gradle.jvmargs=-Xmx4G
22
android.useAndroidX=true
33
android.enableJetifier=true
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri Jun 23 08:50:38 CEST 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

example/android/settings.gradle

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
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+
}
9+
settings.ext.flutterSdkPath = flutterSdkPath()
210

3-
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
11+
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
412

5-
def plugins = new Properties()
6-
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7-
if (pluginsFile.exists()) {
8-
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
13+
repositories {
14+
google()
15+
mavenCentral()
16+
gradlePluginPortal()
17+
}
18+
19+
plugins {
20+
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
21+
}
922
}
1023

11-
plugins.each { name, path ->
12-
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13-
include ":$name"
14-
project(":$name").projectDir = pluginDirectory
24+
plugins {
25+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
26+
id "com.android.application" version "7.3.0" apply false
1527
}
28+
29+
include ":app"

example/android/settings_aar.gradle

-1
This file was deleted.

0 commit comments

Comments
 (0)