diff --git a/app/android/app/build.gradle.kts b/app/android/app/build.gradle.kts index 620de1a..175175c 100644 --- a/app/android/app/build.gradle.kts +++ b/app/android/app/build.gradle.kts @@ -30,6 +30,7 @@ android { // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion + multiDexEnabled = true // Uses the version code from pubspec.yaml. When using split APKs, 1000 * ABI_VERSION // is added automatically by Flutter. (https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions) // You can force using the value of versionCode by specifying the `-P force-version-code-ignoring-abi=true` @@ -56,10 +57,8 @@ android { } else { signingConfigs.getByName("debug") } - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) + isMinifyEnabled = false + isShrinkResources = false } } } diff --git a/app/lib/core/services/ad_service.dart b/app/lib/core/services/ad_service.dart index 6841d92..0e57a98 100644 --- a/app/lib/core/services/ad_service.dart +++ b/app/lib/core/services/ad_service.dart @@ -37,7 +37,10 @@ class AdService { try { await MobileAds.instance.initialize(); _isInitialized = true; - loadRewardedAd(); + // Preload after the first UI frames have settled + Future.delayed(const Duration(seconds: 2), () { + loadRewardedAd(); + }); } catch (e) { debugPrint('AdService initialize error: $e'); } @@ -47,21 +50,27 @@ class AdService { if (_isFlutterTest || kIsWeb || _isLoading || _rewardedAd != null) return; _isLoading = true; - RewardedAd.load( - adUnitId: rewardedAdUnitId, - request: const AdRequest(), - rewardedAdLoadCallback: RewardedAdLoadCallback( - onAdLoaded: (ad) { - _rewardedAd = ad; - _isLoading = false; - }, - onAdFailedToLoad: (error) { - debugPrint('RewardedAd failed to load: $error'); - _rewardedAd = null; - _isLoading = false; - }, - ), - ); + try { + RewardedAd.load( + adUnitId: rewardedAdUnitId, + request: const AdRequest(), + rewardedAdLoadCallback: RewardedAdLoadCallback( + onAdLoaded: (ad) { + _rewardedAd = ad; + _isLoading = false; + }, + onAdFailedToLoad: (error) { + debugPrint('RewardedAd failed to load: $error'); + _rewardedAd = null; + _isLoading = false; + }, + ), + ); + } catch (e) { + debugPrint('RewardedAd.load exception: $e'); + _rewardedAd = null; + _isLoading = false; + } } Future showRewardedAd({required VoidCallback onUserEarnedReward}) async { diff --git a/app/lib/main.dart b/app/lib/main.dart index ef61633..54b60b4 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -38,7 +38,12 @@ void main() async { // Core services const feedbackService = FeedbackService(); - final adService = AdService()..initialize(); + final adService = AdService(); + try { + await adService.initialize(); + } catch (e) { + debugPrint('AdService init error: $e'); + } // Repositories final SettingsRepository settingsRepository = SettingsRepositoryImpl( diff --git a/app/pubspec.yaml b/app/pubspec.yaml index b937b14..b6c5aa9 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.5+6 +version: 1.0.6+7 environment: sdk: ^3.13.4