Webview not working when we updated smack to 4.4.4

After searching on different platforms we didn’t find any help regarding this issue. we are using Smack version 4.4.4 in my app, Everything is working fine in dev flavor when proguard is not enabled but when we are making release build WebView is not working because our proguard is active and minifyEnabled and shrinkResources property is true.
The issue related directly with smack 4.4.4 because when we remove proguard rule of smackx WebView starts to work.

we are using this proguard rule for smack 4.4.4
-keep class org.jivesoftware.smackx.** { ; }
-keep class org.jivesoftware.smack.
* { *; }

Did you follow instructions in this link?
I don’t remember what I did in the other App using Smack. But I don’t remember if I had to define rules anywhere

try to follow configurations explained in the link and remove the rules and see if it helps

After following the above configuration i am getting this exception while initializing smack

java.lang.ExceptionInInitializerError
        at iv.x.b(Smack.java:38)
        at iv.x.a(Smack.java:64)
        at iv.n.<clinit>(ConnectionConfiguration.java:115)
        at ow.l.y(XMPPTCPConnectionConfiguration.java:64)
        at cp.k0.B(XmppConnectionManager.kt:195)
        at cp.k0.t(XmppConnectionManager.kt:166)
        at cp.k0.c(XmppConnectionManager.kt:49)
        at cp.k0$c.l(XmppConnectionManager.kt:93)
        at ds.a.g(ContinuationImpl.kt:33)
        at ss.u0.run(DispatchedTask.kt:106)
        at xs.a.u(CoroutineScheduler.kt:571)
        at xs.a$b.c(CoroutineScheduler.kt:738)
        at xs.a$b.m(CoroutineScheduler.kt:678)
        at xs.a$b.run(CoroutineScheduler.kt:665)
     Caused by: java.lang.IllegalStateException: Could not parse Smack configuration file
        at iv.c0.<clinit>(SmackInitialization.java:106)
        at iv.x.b(Smack.java:38) 
        at iv.x.a(Smack.java:64) 
        at iv.n.<clinit>(ConnectionConfiguration.java:115) 
        at ow.l.y(XMPPTCPConnectionConfiguration.java:64) 
        at cp.k0.B(XmppConnectionManager.kt:195) 
        at cp.k0.t(XmppConnectionManager.kt:166) 
        at cp.k0.c(XmppConnectionManager.kt:49) 
        at cp.k0$c.l(XmppConnectionManager.kt:93) 
        at ds.a.g(ContinuationImpl.kt:33) 
        at ss.u0.run(DispatchedTask.kt:106) 
        at xs.a.u(CoroutineScheduler.kt:571) 
        at xs.a$b.c(CoroutineScheduler.kt:738) 
        at xs.a$b.m(CoroutineScheduler.kt:678) 
        at xs.a$b.run(CoroutineScheduler.kt:665) 
     Caused by: java.lang.ClassNotFoundException: org.jivesoftware.smack.initializer.VmArgInitializer
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at iv.c0.a(SmackInitialization.java:210)
        at iv.c0.b(SmackInitialization.java:190)
        at iv.c0.d(SmackInitialization.java:164)
        at iv.c0.c(SmackInitialization.java:154)
        at iv.c0.<clinit>(SmackInitialization.java:103)
        at iv.x.b(Smack.java:38) 
        at iv.x.a(Smack.java:64) 
        at iv.n.<clinit>(ConnectionConfiguration.java:115) 
        at ow.l.y(XMPPTCPConnectionConfiguration.java:64) 
        at cp.k0.B(XmppConnectionManager.kt:195) 
        at cp.k0.t(XmppConnectionManager.kt:166) 
        at cp.k0.c(XmppConnectionManager.kt:49) 
        at cp.k0$c.l(XmppConnectionManager.kt:93) 
        at ds.a.g(ContinuationImpl.kt:33) 
        at ss.u0.run(DispatchedTask.kt:106) 
        at xs.a.u(CoroutineScheduler.kt:571) 
        at xs.a$b.c(CoroutineScheduler.kt:738) 
        at xs.a$b.m(CoroutineScheduler.kt:678) 
        at xs.a$b.run(CoroutineScheduler.kt:665) 

Can you post your gradle file? full (removing any private info of course)

type or paste code hereapply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'


repositories {
    flatDir {
        dirs 'libs'
    }
}

android {
    compileSdkVersion 31
    defaultConfig {
        applicationId "***.***.****"
        minSdkVersion 19
        targetSdkVersion 31
        // Enabling multidex support.
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true

    }

    buildTypes {
        release {
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            minifyEnabled true

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true

            // Includes the default ProGuard rules files that are packaged with
            // the Android Gradle plugin. To learn more, go to the section about
            // R8 configuration files.
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'

            ndk {
                abiFilters 'armeabi-v7a', 'arm64-v8a'
            }
        }

        debug {
            minifyEnabled false

            ndk {
                abiFilters 'armeabi-v7a', 'arm64-v8a', '5x86', 'x86_64' , 'x86'
            }
            firebaseCrashlytics {
                // If you don't need crash reporting for your debug build,
                // you can speed up your build by disabling mapping file uploading.
                mappingFileUploadEnabled false
            }
        }
    }
    flavorDimensions "dev"
    productFlavors {
        tellotalkDev {
            // Assigns this product flavor to the "version" flavor dimension.
            // This property is optional if you are using only one dimension.
            dimension "dev"
            versionNameSuffix "-dev"
            applicationId '****.*****.****'
            applicationIdSuffix ".dev"
            versionCode 5000
            versionName '1.0'
        }
        tellotalkLive {
            dimension "dev"
            applicationId '***.****.****'
            versionCode 0000
            versionName "0.0.0"
        }
    }
    buildFeatures {
        dataBinding true
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    bundle {
        language {
            enableSplit = false
        }
    }
    useLibrary 'org.apache.http.legacy'

}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')

    //Android dependencies
    //Appcompat
    implementation 'androidx.appcompat:appcompat:1.4.1'

    //Recycler View
    implementation 'androidx.recyclerview:recyclerview:1.2.1'

    //Constraint Layout
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'

    //Card View
    implementation 'androidx.cardview:cardview:1.0.0'

    //Android core
    implementation 'androidx.core:core-ktx:1.7.0'

    //Pallette
    implementation 'androidx.palette:palette:1.0.0'

    //Room database
    implementation 'androidx.room:room-runtime:2.4.1'
    annotationProcessor 'androidx.room:room-compiler:2.4.1'

    //Fragment kotlin library
    implementation 'androidx.fragment:fragment-ktx:1.4.1'

    //WorkManager
    implementation 'androidx.work:work-runtime:2.7.1'

    implementation "androidx.concurrent:concurrent-futures:1.1.0"
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.4.1'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'


    //Google Dependencies
    //Google play services
    implementation 'com.google.android.gms:play-services-analytics:18.0.1'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-basement:18.0.0'
    implementation 'com.google.android.gms:play-services-drive:17.0.0'
    implementation 'com.google.android.gms:play-services-base:18.0.1'
    implementation 'com.google.android.gms:play-services-auth:20.1.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
    implementation 'com.google.android.play:core:1.10.3'
    implementation 'com.google.android.gms:play-services-maps:18.0.2'
    //Exo Player
    implementation 'com.google.android.exoplayer:exoplayer:2.16.1'
    //Places
    implementation 'com.google.android.libraries.places:places:1.0.0'
    //Firebase
    implementation platform('com.google.firebase:firebase-bom:29.0.4')
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    implementation 'com.google.firebase:firebase-messaging-ktx'
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-dynamic-links-ktx'
    //  Dagger Dependencies
    annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
    annotationProcessor "com.google.dagger:dagger-android-processor:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger-android:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"
    //Zxing QR Scanner
    implementation 'com.google.zxing:core:3.3.3'
    implementation 'com.google.zxing:android-integration:3.2.1'
    //Flex box
    implementation 'com.google.android:flexbox:2.0.1'
    //Gson
    implementation 'com.google.code.gson:gson:2.8.6'


    //Third Party Dependencies

    //smack
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.igniterealtime.smack:smack-android-extensions:4.4.4"
implementation "org.igniterealtime.smack:smack-experimental:4.4.4"
implementation "org.igniterealtime.smack:smack-tcp:4.4.4"
implementation 'org.jxmpp:jxmpp-stringprep-libidn:0.6.0'
implementation 'org.jxmpp:jxmpp-core:1.0.3'
implementation 'org.jxmpp:jxmpp-jid:1.0.3'

    // Retrofit
    implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
    implementation "com.squareup.retrofit2:converter-moshi:$rootProject.retrofitVersion"
    implementation 'com.squareup.okio:okio:1.17.4'
    implementation 'com.squareup.moshi:moshi:1.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'

    // OKHTTP3
    implementation "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"
    implementation "com.squareup.okhttp3:logging-interceptor:$rootProject.okhttpVersion"

    //Glide Image loading
    implementation 'com.github.bumptech.glide:glide:4.11.0'

    //Picasso image loading
    implementation 'com.squareup.picasso:picasso:2.71828'

    //Job Queue
    implementation 'com.birbit:android-priority-jobqueue:2.0.1'
    
    //Facebook SDK
    implementation 'com.facebook.android:facebook-android-sdk:12.3.0'

    //Mixpanel Analytics
    implementation 'com.mixpanel.android:mixpanel-android:6.0.0'

    //stetho
    implementation "com.facebook.stetho:stetho:$rootProject.stethoVersion"
    implementation "com.facebook.stetho:stetho-okhttp3:$rootProject.stethoVersion"

    //event bus
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.8.9'

    //Fresco image loading
    implementation 'com.facebook.fresco:fresco:1.13.0'
    implementation 'com.facebook.fresco:animated-gif:1.13.0'
    implementation "com.facebook.fresco:imagepipeline-okhttp3:1.13.0"
    implementation(name: 'tenor-android-core', ext: 'aar') {
        transitive = true
    }

    implementation('com.theartofdev.edmodo:android-image-cropper:2.7.0') {
        exclude module: 'appcompat-v7'
    }
    implementation 'io.tus.java.client:tus-java-client:0.3.2'
    implementation 'com.jakewharton.timber:timber:4.6.1'

    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

    //S3
    implementation 'com.amazonaws:aws-android-sdk-core:2.2.22'
    implementation 'com.amazonaws:aws-android-sdk-cognito:2.2.22'
    implementation 'com.amazonaws:aws-android-sdk-s3:2.2.22'
    implementation 'com.amazonaws:aws-android-sdk-ddb:2.2.22'

    //socket
    implementation('io.socket:socket.io-client:1.0.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }


    implementation 'com.sothree.slidinguppanel:library:3.4.0'
    implementation 'com.birbit:android-priority-jobqueue:2.0.1'
    implementation 'com.github.zomato:androidphotofilters:1.0.1'

    //OpenTok
    implementation 'pub.devrel:easypermissions:0.4.0'
    implementation 'com.opentok.android:opentok-android-sdk:2.19.1'

    implementation 'com.googlecode.mp4parser:isoparser:1.1.22'
    implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.4'
    implementation files('libs/bcprov-ext-jdk15on-1.58.jar')
    implementation 'org.jsoup:jsoup:1.13.1'


    implementation 'com.mahc.custombottomsheetbehavior:googlemaps-like:0.9.2'
    implementation project(path: ':lib')


    implementation 'io.fotoapparat:fotoapparat:2.7.0'
    implementation 'com.camerakit:camerakit:1.0.0-beta3.11'
    implementation 'com.camerakit:jpegkit:0.1.0'

    implementation 'com.github.danylovolokh:list-visibility-utils:0.2.0'

    //RxJava Dependency
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.6'

    //Action Sheet Library
    implementation 'com.github.mkhoiron:Actionsheet-android:0.1'

    implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
    implementation 'com.amitshekhar.android:android-networking:1.0.2'
    implementation 'me.relex:photodraweeview:1.1.3'

    implementation 'com.treebo:internetavailabilitychecker:1.0.4'
    implementation 'com.intuit.ssp:ssp-android:1.0.6'
    implementation 'com.intuit.sdp:sdp-android:1.0.6'

    implementation 'com.github.barteksc:pdfium-android:1.4.0'


    implementation 'commons-io:commons-io:2.6'


    configurations {
        all*.exclude group: 'com.google.guava', module: 'listenablefuture'
        all*.exclude group: 'xpp3', module: 'xpp3'
        all*.exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
    }

}

//build a jar with source files
task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    failOnError false
    source = android.sourceSets.main.java.sourceFiles
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    classpath += configurations.implementation
}

// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}
android {
    packagingOptions {
        resources {
            excludes += ['META-INF/androidx.exifinterface_exifinterface.version']
        }
    }
    /** Any other configurations here */
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
    lint {
        checkReleaseBuilds false
    }
}


Can you check if any of the solution here works?

This class is probably removed by ProGuard’s minification. Adjust your ProGuard rules accordingly.

@FaizanAbbas72 were you able to find a solution? I am facing this same exact problem, but I do not see the ClassNotFoundException - I just see WebViews not working.

This is a very strange error.

There are no exceptions in our app, but the WebView chromium side is complaining about handshake exception.

03-02 09:25:27.510 11988 12269 E chromium: [ERROR:ssl_client_socket_impl.cc(996)] handshake failed; returned -1, SSL error code 1, net_error -2

03-02 09:25:27.512 11988 11988 W System.err: chromium: onReceivedError: net::ERR_FAILED code=-1

If I removing smack or revert to Smack 4.3.1 - then this exact code works.

The WebView appears to be using some other Bouncy Castle implementation when smack is included:
| ±-- org.igniterealtime.smack:smack-openpgp:4.4.4
| | ±-- org.igniterealtime.smack:smack-core:4.4.4 ()
| | ±-- org.igniterealtime.smack:smack-extensions:4.4.4
| | | ±-- org.igniterealtime.smack:smack-core:4.4.4 (
)
| | | — org.igniterealtime.smack:smack-im:4.4.4 ()
| | ±-- org.igniterealtime.smack:smack-experimental:4.4.4
| | | ±-- org.igniterealtime.smack:smack-core:4.4.4 (
)
| | | ±-- org.igniterealtime.smack:smack-extensions:4.4.4 (*)
| | | — org.hsluv:hsluv:0.2
| | — org.pgpainless:pgpainless-core:0.1.0
| | ±-- org.bouncycastle:bcprov-jdk15on:1.65
| | ±-- com.google.code.findbugs:jsr305:3.0.2
| | — org.bouncycastle:bcpg-jdk15on:1.65
| | — org.bouncycastle:bcprov-jdk15on:1.65

Yep, I also suspect that this is caused by Smack installing Bouncy Castle’s security provider in the first place. You could try either, undoing the changes that Smack does in the security provider setting or, remove smack-openpgp from you classpath (because this is the component of Smack that modifies the security provider). Note that this behavior is removed in Smack’s master branch:

I can get it working if I explicitly keep the BC from getting obfuscated.

-keep class org.bouncycastle.** { *; }

Seems like Chromium is using some reflection to check the certs?

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.