getsentry / sentry-dart

Sentry SDK for Dart and Flutter
https://sentry.io/for/flutter/
MIT License
761 stars 239 forks source link

Sentry doesn't work after version upgrades. #1614

Closed YusufAbdelaziz closed 1 year ago

YusufAbdelaziz commented 1 year ago

Platform

Flutter Mobile

Obfuscation

Enabled

Debug Info

Enabled

Doctor

[!] Flutter (Channel stable, 3.13.0, on Microsoft Windows [Version 10.0.22621.2134], locale en-US) • Flutter version 3.13.0 on channel stable at C:\Users**\FVM\3.13.0 ! Warning: flutter on your path resolves to C:\Users***\flutter, which is not inside your current Flutter SDK checkout at C:\Users**\FVM\3.13.0. Consider adding C:\Users**\FVM\3.13.0\bin to the front of your path. ! Warning: dart on your path resolves to C:\tools\dart-sdk\bin\dart.exe, which is not inside your current Flutter SDK checkout at C:\Users**\FVM\3.13.0. Consider adding C:\Users***\FVM\3.13.0\bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision efbf63d9c6 (10 days ago), 2023-08-15 21:05:06 -0500 • Engine revision 1ac611c64e • Dart version 3.1.0 • DevTools version 2.25.0 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at C:\Users\yusse\AppData\Local\Android\sdk • Platform android-33, build-tools 33.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps X Visual Studio not installed; this is necessary to develop Windows apps. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2022.3) • Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.111 • Edge (web) • edge • web-javascript • Microsoft Edge 114.0.1823.82

[√] Network resources • All expected network resources are available.

! Doctor found issues in 2 categories.

Version

7.9.0

Steps to Reproduce

Unfortunately, I can't reproduce it in a newly created app. I upgraded Flutter's version from 3.7.1 to 3.13.0 and Sentry's version from 6.15.1 to 7.9.0.

main.dart file:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  await EasyLocalization.ensureInitialized();
  final enableDevicePreview = kDebugMode;

  await SentryFlutter.init((options) {
    options.dsn = kDebugMode
        ? ""
        : dsn;
    options.debug = kDebugMode;
  },
      appRunner: () => runApp(MyApp()));
}

android\build.gradle file:

buildscript {
    ext.kotlin_version = '1.9.0'
    repositories {
        google()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
        classpath 'com.google.gms:google-services:4.3.14'
        classpath 'io.sentry:sentry-android-gradle-plugin:3.5.0'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

app\build.gradle file:

buildscript {
    repositories {
        // ...
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }

}

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'
}

def flutterCompileSdkVersion = localProperties.getProperty('flutter.compileSdkVersion')
if(flutterCompileSdkVersion == null)
    flutterCompileSdkVersion = 30

def flutterTargetSdkVersion = localProperties.getProperty('flutter.targetSdkVersion')
if(flutterTargetSdkVersion == null)
    flutterTargetSdkVersion = 30

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 33
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_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 "**"
        minSdkVersion 21
        targetSdkVersion 33
//        minSdkVersion flutter.minSdkVersion
//        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release

            minifyEnabled true

            shrinkResources true

            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
    }
    lint {
        disable 'InvalidPackage'
    }
    namespace 'com.**.**'
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.firebase:firebase-core:17.2.2'
//    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation 'com.facebook.android:facebook-login:8.1.0'
    implementation 'io.branch.sdk.android:library:5.0.5'
    implementation "androidx.annotation:annotation:1.1.0"
}
//apply plugin: 'com.google.gms.google-services'

Are there any extra configurations that I've missed while upgrading versions?

Expected Result

The library should work with no errors.

Actual Result

D/Sentry  (13648): Class not available:androidx.compose.ui.node.Owner
D/Sentry  (13648): java.lang.ClassNotFoundException: androidx.compose.ui.node.Owner
D/Sentry  (13648):  at java.lang.Class.classForName(Native Method)
D/Sentry  (13648):  at java.lang.Class.forName(Class.java:454)
D/Sentry  (13648):  at java.lang.Class.forName(Class.java:379)
D/Sentry  (13648):  at io.sentry.android.core.LoadClass.loadClass(LoadClass.java:21)
D/Sentry  (13648):  at io.sentry.android.core.LoadClass.isClassAvailable(LoadClass.java:39)
D/Sentry  (13648):  at io.sentry.android.core.LoadClass.isClassAvailable(LoadClass.java:44)
D/Sentry  (13648):  at io.sentry.android.core.AndroidOptionsInitializer.initializeIntegrationsAndProcessors(AndroidOptionsInitializer.java:145)
D/Sentry  (13648):  at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:127)
D/Sentry  (13648):  at io.sentry.android.core.SentryAndroid$$ExternalSyntheticLambda0.configure(Unknown Source:8)
D/Sentry  (13648):  at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:176)
D/Sentry  (13648):  at io.sentry.Sentry.init(Sentry.java:146)
D/Sentry  (13648):  at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:89)
D/Sentry  (13648):  at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:70)
D/Sentry  (13648):  at io.sentry.flutter.SentryFlutterPlugin.initNativeSdk(SentryFlutterPlugin.kt:124)
D/Sentry  (13648):  at io.sentry.flutter.SentryFlutterPlugin.onMethodCall(SentryFlutterPlugin.kt:55)
D/Sentry  (13648):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
D/Sentry  (13648):  at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
D/Sentry  (13648):  at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
D/Sentry  (13648):  at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
D/Sentry  (13648):  at android.os.Handler.handleCallback(Handler.java:938)
D/Sentry  (13648):  at android.os.Handler.dispatchMessage(Handler.java:99)
D/Sentry  (13648):  at android.os.Looper.loop(Looper.java:223)
D/Sentry  (13648):  at android.app.ActivityThread.main(ActivityThread.java:7656)
D/Sentry  (13648):  at java.lang.reflect.Method.invoke(Native Method)
D/Sentry  (13648):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
D/Sentry  (13648):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
D/Sentry  (13648): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.ui.node.Owner" on path: DexPathList[[zip file "/data/app/~~wBXqDndtVmTH5lqWQsSHdg==/co.prestoapp.www-PkWGN3eSpnj0lwZbRRHw2w==/base.apk"],nativeLibraryDirectories=[/data/app/~~wBXqDndtVmTH5lqWQsSHdg==/co.prestoapp.www-PkWGN3eSpnj0lwZbRRHw2w==/lib/x86, /data/app/~~wBXqDndtVmTH5lqWQsSHdg==/co.prestoapp.www-PkWGN3eSpnj0lwZbRRHw2w==/base.apk!/lib/x86, /system/lib, /system_ext/lib]]
D/Sentry  (13648):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
D/Sentry  (13648):  at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
D/Sentry  (13648):  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
D/Sentry  (13648):  ... 26 more

Are you willing to submit a PR?

None

vaind commented 1 year ago

Can you try a clean build (run flutter clean before building)? Also, I'd suggest fixing the flutter doctor warnings first - there seems to be something wrong with your installation. After those are ruled out as potential causes, please let us know to see if some actionable thing could be done in the SDK.

YusufAbdelaziz commented 1 year ago

I tried to do a clean build and fix warning messages, but the Android error message persisted. Despite this, the library now works. Thanks.