Skip to content

Commit

Permalink
disable cronet if google play services unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Nov 29, 2024
1 parent 1f3cf6b commit c4dd9f8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build_android/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 4 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
<meta-data
android:name="io.flutter.embedding.android.EnableImpeller"
android:value="true" />
<meta-data
android:name="io.sentry.ndk.enable"
android:value="false" />

<!-- Add android:stopWithTask option only when necessary. -->
<service
Expand Down
5 changes: 4 additions & 1 deletion lib/Frontend/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:dio/dio.dart';
import 'package:dio_smart_retry/dio_smart_retry.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_api_availability/google_api_availability.dart';
import 'package:logarte/logarte.dart';
import 'package:logging/logging.dart';
import 'package:native_dio_adapter/native_dio_adapter.dart';
Expand Down Expand Up @@ -82,7 +83,9 @@ Future<Dio> 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.
Expand Down
24 changes: 24 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4dd9f8

Please sign in to comment.