From e76538c6f6c56916a409ebea7c4dd5ee2c39169d Mon Sep 17 00:00:00 2001 From: Bhargav Raviya <46953122+bhargavraviya@users.noreply.github.com> Date: Mon, 11 Dec 2023 21:21:54 +0530 Subject: [PATCH] Upgrade Flutter Version - Sample App Open (#965) * upgrade flutter version * change in main funtion * change print to debugPrint --- samples/admob/app_open_example/.gitignore | 5 +- samples/admob/app_open_example/.metadata | 27 +- samples/admob/app_open_example/README.md | 22 +- .../app_open_example/analysis_options.yaml | 1 + .../admob/app_open_example/android/.gitignore | 2 + .../app_open_example/android/app/build.gradle | 33 +- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 34 +- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- .../app_open_example/android/build.gradle | 7 +- .../android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- .../app_open_example/android/settings.gradle | 34 +- samples/admob/app_open_example/ios/.gitignore | 1 + .../ios/Flutter/Debug.xcconfig | 1 - .../ios/Flutter/Release.xcconfig | 1 - samples/admob/app_open_example/ios/Podfile | 41 -- .../ios/Runner.xcodeproj/project.pbxproj | 222 +++++--- .../contents.xcworkspacedata | 3 - .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 564 -> 295 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 1283 -> 406 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 1588 -> 450 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 1025 -> 282 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 1716 -> 462 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 1920 -> 704 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 1283 -> 406 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 1895 -> 586 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 2665 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 2665 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 3831 -> 1674 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 1888 -> 762 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 3294 -> 1226 bytes .../Icon-App-83.5x83.5@2x.png | Bin 3612 -> 1418 bytes .../app_open_example/ios/Runner/Info.plist | 502 +++++++++--------- .../ios/RunnerTests/RunnerTests.swift | 12 + .../lib/app_lifecycle_reactor.dart | 3 +- .../lib/app_open_ad_manager.dart | 22 +- samples/admob/app_open_example/lib/main.dart | 28 +- samples/admob/app_open_example/pubspec.yaml | 62 +-- 41 files changed, 550 insertions(+), 539 deletions(-) create mode 100644 samples/admob/app_open_example/analysis_options.yaml delete mode 100644 samples/admob/app_open_example/ios/Podfile create mode 100644 samples/admob/app_open_example/ios/RunnerTests/RunnerTests.swift diff --git a/samples/admob/app_open_example/.gitignore b/samples/admob/app_open_example/.gitignore index 0fa6b675c..29a3a5017 100644 --- a/samples/admob/app_open_example/.gitignore +++ b/samples/admob/app_open_example/.gitignore @@ -8,6 +8,7 @@ .buildlog/ .history .svn/ +migrate_working_dir/ # IntelliJ related *.iml @@ -26,14 +27,10 @@ .dart_tool/ .flutter-plugins .flutter-plugins-dependencies -.packages .pub-cache/ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # Symbolication related app.*.symbols diff --git a/samples/admob/app_open_example/.metadata b/samples/admob/app_open_example/.metadata index 56bfc2c4d..6c1bf2fff 100644 --- a/samples/admob/app_open_example/.metadata +++ b/samples/admob/app_open_example/.metadata @@ -4,7 +4,30 @@ # This file should be version controlled and should not be manually edited. version: - revision: f4abaa0735eba4dfd8f33f73363911d63931fe03 - channel: stable + revision: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a" + channel: "stable" project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a + base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a + - platform: android + create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a + base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a + - platform: ios + create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a + base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a + + # 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/samples/admob/app_open_example/README.md b/samples/admob/app_open_example/README.md index 43f683117..d22df77f2 100644 --- a/samples/admob/app_open_example/README.md +++ b/samples/admob/app_open_example/README.md @@ -74,7 +74,7 @@ public class AppOpenAdManager { _appOpenAd = ad; }, onAdFailedToLoad: (error) { - print('AppOpenAd failed to load: $error'); + debugPrint('AppOpenAd failed to load: $error'); // Handle the error. }, ), @@ -94,28 +94,28 @@ public class AppOpenAdManager { public void showAdIfAvailable() { if (!isAdAvailable) { - print('Tried to show ad before available.'); + debugPrint('Tried to show ad before available.'); loadAd(); return; } if (_isShowingAd) { - print('Tried to show ad while already showing an ad.'); + debugPrint('Tried to show ad while already showing an ad.'); return; } // Set the fullScreenContentCallback and show the ad. _appOpenAd!.fullScreenContentCallback = FullScreenContentCallback( onAdShowedFullScreenContent: (ad) { _isShowingAd = true; - print('$ad onAdShowedFullScreenContent'); + debugPrint('$ad onAdShowedFullScreenContent'); }, onAdFailedToShowFullScreenContent: (ad, error) { - print('$ad onAdFailedToShowFullScreenContent: $error'); + debugPrint('$ad onAdFailedToShowFullScreenContent: $error'); _isShowingAd = false; ad.dispose(); _appOpenAd = null; }, onAdDismissedFullScreenContent: (ad) { - print('$ad onAdDismissedFullScreenContent'); + debugPrint('$ad onAdDismissedFullScreenContent'); _isShowingAd = false; ad.dispose(); _appOpenAd = null; @@ -246,12 +246,12 @@ class AppOpenAdManager { request: AdRequest(), adLoadCallback: AppOpenAdLoadCallback( onAdLoaded: (ad) { - print('$ad loaded'); + debugPrint('$ad loaded'); {{''}}_appOpenLoadTime = DateTime.now();{{''}} _appOpenAd = ad; }, onAdFailedToLoad: (error) { - print('AppOpenAd failed to load: $error'); + debugPrint('AppOpenAd failed to load: $error'); }, ), ); @@ -263,16 +263,16 @@ class AppOpenAdManager { /// new ad. void showAdIfAvailable() { if (!isAdAvailable) { - print('Tried to show ad before available.'); + debugPrint('Tried to show ad before available.'); loadAd(); return; } if (_isShowingAd) { - print('Tried to show ad while already showing an ad.'); + debugPrint('Tried to show ad while already showing an ad.'); return; } {{''}}if (DateTime.now().subtract(maxCacheDuration).isAfter(_appOpenLoadTime!)) { - print('Maximum cache duration exceeded. Loading another ad.'); + debugPrint('Maximum cache duration exceeded. Loading another ad.'); _appOpenAd!.dispose(); _appOpenAd = null; loadAd(); diff --git a/samples/admob/app_open_example/analysis_options.yaml b/samples/admob/app_open_example/analysis_options.yaml new file mode 100644 index 000000000..f9b303465 --- /dev/null +++ b/samples/admob/app_open_example/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/samples/admob/app_open_example/android/.gitignore b/samples/admob/app_open_example/android/.gitignore index 0a741cb43..6f568019d 100644 --- a/samples/admob/app_open_example/android/.gitignore +++ b/samples/admob/app_open_example/android/.gitignore @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties +**/*.keystore +**/*.jks diff --git a/samples/admob/app_open_example/android/app/build.gradle b/samples/admob/app_open_example/android/app/build.gradle index 3f88b2233..f2ae17dc9 100644 --- a/samples/admob/app_open_example/android/app/build.gradle +++ b/samples/admob/app_open_example/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -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' @@ -21,19 +22,29 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { + namespace "com.example.app_open_example" compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.app_open_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() @@ -42,6 +53,8 @@ android { 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 } } @@ -52,7 +65,7 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.multidex:multidex:2.0.1' // If you do not want to target android 12, then explicitly override the // WorkManager dependency. implementation('androidx.work:work-runtime') { diff --git a/samples/admob/app_open_example/android/app/src/debug/AndroidManifest.xml b/samples/admob/app_open_example/android/app/src/debug/AndroidManifest.xml index 5a1cb4a3d..399f6981d 100644 --- a/samples/admob/app_open_example/android/app/src/debug/AndroidManifest.xml +++ b/samples/admob/app_open_example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/samples/admob/app_open_example/android/app/src/main/AndroidManifest.xml b/samples/admob/app_open_example/android/app/src/main/AndroidManifest.xml index 0da2e19d0..916e30236 100644 --- a/samples/admob/app_open_example/android/app/src/main/AndroidManifest.xml +++ b/samples/admob/app_open_example/android/app/src/main/AndroidManifest.xml @@ -1,11 +1,8 @@ - - + - + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" + /> + + + + - - - - + android:name="io.flutter.embedding.android.SplashScreenDrawable" + android:resource="@drawable/launch_background" + /> + - + \ No newline at end of file diff --git a/samples/admob/app_open_example/android/app/src/main/res/values-night/styles.xml b/samples/admob/app_open_example/android/app/src/main/res/values-night/styles.xml index 449a9f930..06952be74 100644 --- a/samples/admob/app_open_example/android/app/src/main/res/values-night/styles.xml +++ b/samples/admob/app_open_example/android/app/src/main/res/values-night/styles.xml @@ -3,14 +3,14 @@