diff --git a/example/.metadata b/example/.metadata index cd984dd0..fb51cb0b 100644 --- a/example/.metadata +++ b/example/.metadata @@ -4,7 +4,27 @@ # This file should be version controlled and should not be manually edited. version: - revision: 9b2d32b605630f28625709ebd9d78ab3016b2bf6 - channel: stable + revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668" + channel: "stable" project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668 + base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668 + - platform: android + create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668 + base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/example/android/.gitignore b/example/android/.gitignore index 0a741cb4..55afd919 100644 --- a/example/android/.gitignore +++ b/example/android/.gitignore @@ -7,5 +7,7 @@ gradle-wrapper.jar GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. -# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +# See https://flutter.dev/to/reference-keystore key.properties +**/*.keystore +**/*.jks diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index c33f636e..38ddf6e3 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,67 +1,50 @@ -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.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') -if (flutterVersionCode == null) { - flutterVersionCode = '1' -} - -def flutterVersionName = localProperties.getProperty('flutter.versionName') -if (flutterVersionName == null) { - flutterVersionName = '1.0' +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - +// flutter. variables commented for backwards compatibility with Flutter 3.16 and 3.19. android { - compileSdkVersion 34 - - namespace 'com.xraph.plugin.flutter_unity_widget_example' + namespace = "com.xraph.plugin.flutter_unity_widget_example" + compileSdk = 34 // flutter.compileSdkVersion + // ndkVersion = flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } - lintOptions { - disable 'InvalidPackage' + kotlinOptions { + // if you change this value, also change it in android/build.gradle subprojects{} + jvmTarget = JavaVersion.VERSION_1_8 } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.xraph.plugin.flutter_unity_widget_example" - minSdkVersion 28 // >= unity minSdk in player settings - targetSdkVersion 34 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + applicationId = "com.xraph.plugin.flutter_unity_widget_example" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = 24 // flutter.minSdkVersion + targetSdk = 34 // flutter.targetSdkVersion + versionCode = 1 // flutter.versionCode + versionName = "1.0.0" // flutter.versionName } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } } flutter { - source '../..' + source = "../.." } dependencies { implementation project(':unityLibrary') implementation project(':flutter_unity_widget') - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index 6a3cb784..399f6981 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 89d35599..25739d81 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,10 +1,5 @@ - + package="com.xraph.plugin.flutter_unity_widget_example"> - - + + @@ -56,4 +47,15 @@ android:name="flutterEmbedding" android:value="2" /> + + + + + + + diff --git a/example/android/app/src/main/kotlin/com/xraph/plugin/flutter_unity_widget_example/MainActivity.kt b/example/android/app/src/main/kotlin/com/xraph/plugin/flutter_unity_widget_example/MainActivity.kt index 15280ffe..8299ea66 100644 --- a/example/android/app/src/main/kotlin/com/xraph/plugin/flutter_unity_widget_example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/xraph/plugin/flutter_unity_widget_example/MainActivity.kt @@ -1,5 +1,6 @@ package com.xraph.plugin.flutter_unity_widget_example +// import io.flutter.embedding.android.FlutterActivity import com.xraph.plugin.flutter_unity_widget.FlutterUnityActivity; class MainActivity: FlutterUnityActivity() { @@ -19,4 +20,4 @@ class ActivityExample: SomeActivity(), IFlutterUnityActivity { mUnityPlayer = unityPlayer; } } -*/ \ No newline at end of file +*/ diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 1f83a33f..cb1ef880 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,18 +1,18 @@ - - - diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml index 6a3cb784..399f6981 100644 --- a/example/android/app/src/profile/AndroidManifest.xml +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/example/android/build.gradle b/example/android/build.gradle index 116fd51b..5aa11d7d 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,18 +1,3 @@ -buildscript { - ext.kotlin_version = '1.8.22' - repositories { - google() - mavenCentral() - } - - dependencies { - // Unity recommended gradle version https://docs.unity3d.com/Manual/android-gradle-overview.html (higher versions do often work) - classpath 'com.android.tools.build:gradle:7.1.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - - allprojects { repositories { flatDir { @@ -24,14 +9,42 @@ allprojects { } } -rootProject.buildDir = '../build' +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } + + +// This subprojects block is only for this example's backwards compatibility. +// Older fuw plugin versions (2022.2.1 or earlier) don't have a `namespace` or 'kotlinOptions' property, which will throw errors. +// This block overrides these settings in the plugin's build.gradle. +subprojects { + // make sure this is above any use of "evaluationDependsOn" + afterEvaluate { + + if (project.plugins.hasPlugin("com.android.application") + || project.plugins.hasPlugin("com.android.library")) { + + if (project.name == "flutter_unity_widget") { + project.android { + // add namespace if it is missing + if (namespace == null) { + namespace = project.group + } + } + project.android.kotlinOptions { + // if you change this value, also change it in android/app/build.gradle + jvmTarget = JavaVersion.VERSION_1_8 + } + } + } + } +} + subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index a6738207..25971708 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,3 @@ -org.gradle.jvmargs=-Xmx1536M +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true -android.enableR8=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 595fb867..5e6b5427 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 9006d257..aef2abf3 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +1,30 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -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" +// Kotlin and AGP versions generated by Flutter 3.24.5, with small updates to fix warnings. +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.2.1" apply false + id "org.jetbrains.kotlin.android" version "1.8.22" apply false +} +// Unity recommended versions: https://docs.unity3d.com/Manual/android-gradle-overview.html (higher versions do work) +include ":app" include ":unityLibrary" project(":unityLibrary").projectDir = file("./unityLibrary")