From c4dd9f854e5808512aa9dbefe8da74be22e37c78 Mon Sep 17 00:00:00 2001 From: Codel1417 Date: Fri, 29 Nov 2024 10:58:24 -0500 Subject: [PATCH] disable cronet if google play services unavailable --- .github/actions/build_android/action.yml | 2 +- android/app/build.gradle | 6 ++++-- android/app/src/main/AndroidManifest.xml | 3 +++ lib/Frontend/utils.dart | 5 ++++- pubspec.lock | 24 ++++++++++++++++++++++++ pubspec.yaml | 1 + 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.github/actions/build_android/action.yml b/.github/actions/build_android/action.yml index 37d9d51e..92310227 100644 --- a/.github/actions/build_android/action.yml +++ b/.github/actions/build_android/action.yml @@ -49,7 +49,7 @@ runs: - name: Build APK if: inputs.build-mode == 'apk' shell: bash - run: flutter build apk --split-debug-info=./symbols --build-number="$BUILD_NUMBER" --build-name="$VERSION" --dart-define=SENTRY_DSN="$SENTRY_DSN" --dart-define=cronetHttpNoPlay=true + run: flutter build apk --split-debug-info=./symbols --build-number="$BUILD_NUMBER" --build-name="$VERSION" --dart-define=SENTRY_DSN="$SENTRY_DSN" env: VERSION: ${{ inputs.version }} BUILD_NUMBER: ${{ inputs.build-number }} diff --git a/android/app/build.gradle b/android/app/build.gradle index 1aa0e4c7..a156548c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -103,13 +103,15 @@ dependencies { // https://developer.android.com/jetpack/androidx/releases/test/#1.2.0 coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.3" } - +configurations.configureEach { + exclude group: "io.sentry", module: "sentry-android-ndk" +} sentry { ignoredBuildTypes = System.getenv("SENTRY_ORG") != null ? ["debug"] : ["debug", "release"] // Disables or enables debug log output, e.g. for for sentry-cli. // Default is disabled. debug = false - + // The slug of the Sentry organization to use for uploading proguard mappings/source contexts. org = System.getenv("SENTRY_ORG") diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 4cdfc6f7..9c96c794 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -90,6 +90,9 @@ + initDio({skipSentry = false}) async { ], ), ); - dio.httpClientAdapter = NativeAdapter(); + if (platform.isIOS || (await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability()) == GooglePlayServicesAvailability.success) { + dio.httpClientAdapter = NativeAdapter(); + } if (!skipSentry) { /// This *must* be the last initialization step of the Dio setup, otherwise /// your configuration of Dio might overwrite the Sentry configuration. diff --git a/pubspec.lock b/pubspec.lock index b4f1aba9..ce68c9a4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -828,6 +828,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.7.1" + google_api_availability: + dependency: "direct main" + description: + name: google_api_availability + sha256: "3e9548cfd991d983d11425a2436d5bd957d048c279cc9e145ffe3f36fd847385" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + google_api_availability_android: + dependency: transitive + description: + name: google_api_availability_android + sha256: d95429ae78083585c312de2c6578085e7d53d100a94656d691bce0bb0ce435be + url: "https://pub.dev" + source: hosted + version: "1.0.1" + google_api_availability_platform_interface: + dependency: transitive + description: + name: google_api_availability_platform_interface + sha256: "65b7da62fe5b582bb3d508628ad827d36d890710ea274766a992a56fa5420da6" + url: "https://pub.dev" + source: hosted + version: "1.0.1" graphs: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 842b6179..48a4f5e0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -110,6 +110,7 @@ dependencies: # play services in_app_review: ^2.0.10 upgrader: ^11.3.0 + google_api_availability: ^5.0.0 # Spicy plausible_analytics: ^0.3.0 # Privacy Preserving analytics