Skip to content

Commit 99188df

Browse files
committed
Update the android example setup with Flutter create (3.24.5).
1 parent 34b672b commit 99188df

File tree

14 files changed

+166
-102
lines changed

14 files changed

+166
-102
lines changed

example/.metadata

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 9b2d32b605630f28625709ebd9d78ab3016b2bf6
8-
channel: stable
7+
revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668"
8+
channel: "stable"
99

1010
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
17+
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
18+
- platform: android
19+
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
20+
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/android/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ gradle-wrapper.jar
77
GeneratedPluginRegistrant.java
88

99
# Remember to never publicly share your keystore.
10-
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
10+
# See https://flutter.dev/to/reference-keystore
1111
key.properties
12+
**/*.keystore
13+
**/*.jks

example/android/app/build.gradle

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,50 @@
1-
def localProperties = new Properties()
2-
def localPropertiesFile = rootProject.file('local.properties')
3-
if (localPropertiesFile.exists()) {
4-
localPropertiesFile.withReader('UTF-8') { reader ->
5-
localProperties.load(reader)
6-
}
7-
}
8-
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-
14-
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15-
if (flutterVersionCode == null) {
16-
flutterVersionCode = '1'
17-
}
18-
19-
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20-
if (flutterVersionName == null) {
21-
flutterVersionName = '1.0'
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5+
id "dev.flutter.flutter-gradle-plugin"
226
}
237

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
8+
// flutter. variables commented for backwards compatibility with Flutter 3.16 and 3.19.
289
android {
29-
compileSdkVersion 34
30-
31-
namespace 'com.xraph.plugin.flutter_unity_widget_example'
10+
namespace = "com.xraph.plugin.flutter_unity_widget_example"
11+
compileSdk = 34 // flutter.compileSdkVersion
12+
// ndkVersion = flutter.ndkVersion
3213

33-
sourceSets {
34-
main.java.srcDirs += 'src/main/kotlin'
14+
compileOptions {
15+
sourceCompatibility = JavaVersion.VERSION_1_8
16+
targetCompatibility = JavaVersion.VERSION_1_8
3517
}
3618

37-
lintOptions {
38-
disable 'InvalidPackage'
19+
kotlinOptions {
20+
// if you change this value, also change it in android/build.gradle subprojects{}
21+
jvmTarget = JavaVersion.VERSION_1_8
3922
}
4023

4124
defaultConfig {
42-
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
43-
applicationId "com.xraph.plugin.flutter_unity_widget_example"
44-
minSdkVersion 28 // >= unity minSdk in player settings
45-
targetSdkVersion 34
46-
versionCode flutterVersionCode.toInteger()
47-
versionName flutterVersionName
25+
applicationId = "com.xraph.plugin.flutter_unity_widget_example"
26+
// You can update the following values to match your application needs.
27+
// For more information, see: https://flutter.dev/to/review-gradle-config.
28+
minSdk = 24 // flutter.minSdkVersion
29+
targetSdk = 34 // flutter.targetSdkVersion
30+
versionCode = 1 // flutter.versionCode
31+
versionName = "1.0.0" // flutter.versionName
4832
}
4933

5034
buildTypes {
5135
release {
5236
// TODO: Add your own signing config for the release build.
5337
// Signing with the debug keys for now, so `flutter run --release` works.
54-
signingConfig signingConfigs.debug
38+
signingConfig = signingConfigs.debug
5539
}
5640
}
5741
}
5842

5943
flutter {
60-
source '../..'
44+
source = "../.."
6145
}
6246

6347
dependencies {
6448
implementation project(':unityLibrary')
6549
implementation project(':flutter_unity_widget')
66-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6750
}

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

Lines changed: 3 additions & 3 deletions
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.xraph.plugin.flutter_unity_widget_example">
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"/>
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.xraph.plugin.flutter_unity_widget_example">
3-
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
4-
calls FlutterMain.startInitialization(this); in its onCreate method.
5-
In most cases you can leave this as-is, but you if you want to provide
6-
additional functionality it is fine to subclass or reimplement
7-
FlutterApplication and put your custom class here. -->
2+
package="com.xraph.plugin.flutter_unity_widget_example">
83
<application
94
android:name="${applicationName}"
105
android:label="flutter_unity_widget_example"
116
android:icon="@mipmap/ic_launcher">
127
<activity
138
android:name=".MainActivity"
149
android:launchMode="singleTop"
10+
android:taskAffinity=""
1511
android:theme="@style/LaunchTheme"
1612
android:exported="true"
1713
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
@@ -25,20 +21,13 @@
2521
android:name="io.flutter.embedding.android.NormalTheme"
2622
android:resource="@style/NormalTheme"
2723
/>
28-
<!-- Displays an Android View that continues showing the launch screen
29-
Drawable until Flutter paints its first frame, then this splash
30-
screen fades out. A splash screen is useful to avoid any visual
31-
gap between the end of Android's launch screen and the painting of
32-
Flutter's first frame. -->
33-
<meta-data
34-
android:name="io.flutter.embedding.android.SplashScreenDrawable"
35-
android:resource="@drawable/launch_background"
36-
/>
3724
<intent-filter>
3825
<action android:name="android.intent.action.MAIN"/>
3926
<category android:name="android.intent.category.LAUNCHER"/>
4027
</intent-filter>
4128
</activity>
29+
30+
<!-- This Activity is only needed if you want to open Unity a separate activity outside of Flutter -->
4231
<activity
4332
android:name="com.xraph.plugin.flutter_unity_widget.OverrideUnityActivity"
4433
android:theme="@style/UnityThemeSelector"
@@ -47,6 +36,8 @@
4736
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"
4837
android:hardwareAccelerated="false"
4938
android:process=":Unity"
39+
android:taskAffinity=""
40+
android:exported="true"
5041
>
5142
<meta-data android:name="com.xraph.plugins.flutter_unity_widget.OverrideUnityActivity" android:value="true" />
5243
</activity>
@@ -56,4 +47,15 @@
5647
android:name="flutterEmbedding"
5748
android:value="2" />
5849
</application>
50+
<!-- Required to query activities that can process text, see:
51+
https://developer.android.com/training/package-visibility and
52+
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
53+
54+
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
55+
<queries>
56+
<intent>
57+
<action android:name="android.intent.action.PROCESS_TEXT"/>
58+
<data android:mimeType="text/plain"/>
59+
</intent>
60+
</queries>
5961
</manifest>

example/android/app/src/main/kotlin/com/xraph/plugin/flutter_unity_widget_example/MainActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.xraph.plugin.flutter_unity_widget_example
22

3+
// import io.flutter.embedding.android.FlutterActivity
34
import com.xraph.plugin.flutter_unity_widget.FlutterUnityActivity;
45

56
class MainActivity: FlutterUnityActivity() {
@@ -19,4 +20,4 @@ class ActivityExample: SomeActivity(), IFlutterUnityActivity {
1920
mUnityPlayer = unityPlayer;
2021
}
2122
}
22-
*/
23+
*/
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Modify this file to customize your launch splash screen -->
3+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item android:drawable="?android:colorBackground" />
5+
6+
<!-- You can insert your own image assets here -->
7+
<!-- <item>
8+
<bitmap
9+
android:gravity="center"
10+
android:src="@mipmap/launch_image" />
11+
</item> -->
12+
</layer-list>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
4+
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
5+
<!-- Show a splash screen on the activity. Automatically removed when
6+
the Flutter engine draws its first frame -->
7+
<item name="android:windowBackground">@drawable/launch_background</item>
8+
</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.Black.NoTitleBar">
16+
<item name="android:windowBackground">?android:colorBackground</item>
17+
</style>
18+
</resources>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<!-- Theme applied to the Android Window while the process is starting -->
4-
<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">
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. -->
15-
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
16-
<item name="android:windowBackground">@android:color/white</item>
15+
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
16+
<item name="android:windowBackground">?android:colorBackground</item>
1717
</style>
1818
</resources>

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

Lines changed: 3 additions & 3 deletions
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.xraph.plugin.flutter_unity_widget_example">
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

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
buildscript {
2-
ext.kotlin_version = '1.8.22'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
// Unity recommended gradle version https://docs.unity3d.com/Manual/android-gradle-overview.html (higher versions do often work)
10-
classpath 'com.android.tools.build:gradle:7.1.2'
11-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12-
}
13-
}
14-
15-
161
allprojects {
172
repositories {
183
flatDir {
@@ -24,14 +9,42 @@ allprojects {
249
}
2510
}
2611

27-
rootProject.buildDir = '../build'
12+
rootProject.buildDir = "../build"
2813
subprojects {
2914
project.buildDir = "${rootProject.buildDir}/${project.name}"
3015
}
16+
17+
18+
// This subprojects block is only for this example's backwards compatibility.
19+
// Older fuw plugin versions (2022.2.1 or earlier) don't have a `namespace` or 'kotlinOptions' property, which will throw errors.
20+
// This block overrides these settings in the plugin's build.gradle.
21+
subprojects {
22+
// make sure this is above any use of "evaluationDependsOn"
23+
afterEvaluate {
24+
25+
if (project.plugins.hasPlugin("com.android.application")
26+
|| project.plugins.hasPlugin("com.android.library")) {
27+
28+
if (project.name == "flutter_unity_widget") {
29+
project.android {
30+
// add namespace if it is missing
31+
if (namespace == null) {
32+
namespace = project.group
33+
}
34+
}
35+
project.android.kotlinOptions {
36+
// if you change this value, also change it in android/app/build.gradle
37+
jvmTarget = JavaVersion.VERSION_1_8
38+
}
39+
}
40+
}
41+
}
42+
}
43+
3144
subprojects {
32-
project.evaluationDependsOn(':app')
45+
project.evaluationDependsOn(":app")
3346
}
3447

35-
task clean(type: Delete) {
48+
tasks.register("clean", Delete) {
3649
delete rootProject.buildDir
3750
}

example/android/gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
org.gradle.jvmargs=-Xmx1536M
1+
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true
4-
android.enableR8=true
Lines changed: 1 addition & 2 deletions
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-7.2-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip

0 commit comments

Comments
 (0)