euc-releases / wsone-sdk-flutter

2 stars 1 forks source link

Android app crashes at start up (java.lang.ClassNotFoundException,com.vmware.ws1.wha.ApplicationAccessStatusListener) #5

Closed YuriyRum closed 2 years ago

YuriyRum commented 2 years ago

Hello,

our android app with airwatch SDK crashes at start up. We managed to identifier possible cause of these crashes:

am_crash: [java.lang.ClassNotFoundException,com.vmware.ws1.wha.ApplicationAccessStatusListener,NULL,23]

Version of the plugin:

workspaceone_sdk_flutter: ^22.1.0

Build.gradle:

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

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0.1'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.zzz.yyy.qqq.test"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    signingConfigs {
        release {
            file("./signing.properties").with { propFile ->
                if (propFile.canRead()) {
                    def properties = new Properties()
                    properties.load(new FileInputStream(propFile))

                    storeFile file(properties['keystorePath'])
                    storePassword properties['keystorePassword']
                    keyAlias properties['keyAlias']
                    keyPassword properties['keyPassword']
                } else {
                    println 'Unable to read signing.properties'
                }
            }
        }
    }

    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
            signingConfig signingConfigs.release
        }
    }

    packagingOptions {
        pickFirst 'lib/**/libc++_shared.so'
        pickFirst 'lib/**/libcrypto.1.0.2.so'
        pickFirst 'lib/**/libssl.1.0.2.so'
        pickFirst 'lib/**/libsettings.so'
        pickFirst 'lib/**/libxsw_crypto.so'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/kotlinx-serialization-runtime.kotlin_module'
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "androidx.multidex:multidex:2.0.1"
}   

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zzz.yyy.qqq">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.USE_FINGERPRINT"/>

   <application
        android:name=".Application"
        android:icon="@mipmap/launcher_imager"
        android:allowBackup="false">

        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
        </activity>
        <activity
            android:name="com.airwatch.login.ui.activity.SDKSplashActivity" 
            android:label="IC4 Dashboard"
            android:launchMode="singleTop"
            android:exported="true"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" /> 
            </intent-filter>
        </activity>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

flutter doctor -v

[√] Flutter (Channel stable, 2.10.0, on Microsoft Windows [Version 10.0.19043.1526], locale en-US) • Flutter version 2.10.0 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5f105a6ca7 (2 weeks ago), 2022-02-01 14:15:42 -0800 • Engine revision 776efd2034 • Dart version 2.16.0 • DevTools version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK • Platform android-31, build-tools 30.0.2 • Java binary • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.10.2) • Visual Studio • Visual Studio Community 2019 version 16.10.31410.357 • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 4.2) • Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[√] IntelliJ IDEA Community Edition (version 2021.1) • IntelliJ • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.64.2) • VS Code • Flutter extension version 3.32.0

[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1526] • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.82 • Edge (web) • edge • web-javascript • Microsoft Edge 98.0.1108.50

[√] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

Please let me know if you need additional info.

Thanks!

BR, Yuriy

YuriyRum commented 2 years ago

This might be helpful. The crash log from Google Play Console:

java.lang.NoClassDefFoundError: at com.airwatch.app.KoinModule$appModules$1$75.invoke (KoinModule.java:23) at com.airwatch.app.KoinModule$appModules$1$75.invoke (KoinModule.java:4) at org.koin.core.instance.InstanceFactory.create (InstanceFactory.java:50) at org.koin.core.instance.SingleInstanceFactory.create (SingleInstanceFactory.java:38) at org.koin.core.instance.SingleInstanceFactory.get (SingleInstanceFactory.java:48) at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core (InstanceRegistry.java:87) at org.koin.core.scope.Scope.resolveInstance (Scope.java:214) at org.koin.core.scope.Scope.get (Scope.java:181) at org.koin.core.Koin.get (Koin.java:113) at org.koin.java.KoinJavaComponent.get (KoinJavaComponent.java:63) at org.koin.java.KoinJavaComponent.get$default (KoinJavaComponent.java:60) at com.airwatch.app.AWSDKApplicationDelegate.initializeWorkHourAccessControl (AWSDKApplicationDelegate.java:4) at com.airwatch.app.AWApplication.initializeWorkHourAccessControl (AWApplication.java:2) at com.airwatch.app.AWSDKApplicationDelegate.onCreate (AWSDKApplicationDelegate.java:178) at com.airwatch.app.AWApplication.onCreate (AWApplication.java:7) at com.vmware.workspaceone_sdk_flutter.WorkspaceOneSdkApplication.onCreate (WorkspaceOneSdkApplication.java:14) at com.airwatch.app.AWApplication.onCreate (AWApplication.java:3) at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1211) at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7429) at android.app.ActivityThread.access$1700 (ActivityThread.java:309) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2268) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loopOnce (Looper.java:226) at android.os.Looper.loop (Looper.java:313) at android.app.ActivityThread.main (ActivityThread.java:8582) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:563) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1133)

ananyajoshi commented 2 years ago

Can you try building the app again after updating the Koin version?

fwgh commented 2 years ago

Might this be related to this issue? https://www.javafixing.com/2022/02/fixed-flutter-crashes-on-startup-didn.html

YuriyRum commented 2 years ago

Might this be related to this issue? https://www.javafixing.com/2022/02/fixed-flutter-crashes-on-startup-didn.html

Thanks for the idea. In my case build process happens remotely in the GitLab, but I may not have set up the environment correctly.

YuriyRum commented 2 years ago

Hello, Version 1.2.0 of the plugin works fine! It's a good solution for us. Thanks!