opentok / opentok-android-sdk-samples

Sample applications illustrating best practices using OpenTok Android SDK.
https://tokbox.com/developer/sdks/android/
MIT License
211 stars 169 forks source link

ClassNotFoundException on release mode #382

Closed bilalsammour closed 1 year ago

bilalsammour commented 3 years ago

Hi there.

The app exits when opening the video call on release mode only.

I have investigated then found where the issue is, I have found the issues, the issue is: No pending exception expected: java.lang.ClassNotFoundException: com.opentok.android.SubscriberKit$SubscriberAudioStats.

I have attached the full error message as a text file, and screenshot as well.

Please advise.

TokBox error TokBox error.txt

supriyaBharti15 commented 3 years ago

Hi, I also having the same issue with release build. App is crashing while starting audio or video call. Development build its not crashing. Please suggest the solution for this. image

supriyaBharti15 commented 3 years ago

Hi there.

The app exits when opening the video call on release mode only.

I have investigated then found where the issue is, I have found the issues, the issue is: No pending exception expected: java.lang.ClassNotFoundException: com.opentok.android.SubscriberKit$SubscriberAudioStats.

I have attached the full error message as a text file, and screenshot as well.

Please advise.

TokBox error TokBox error.txt

Hi bilalsammour, Just add below code to you proguard-rule file of your project. Its fixed crash in my kotlin project.

opentok

-keep class com.opentok.android.v3. { ; } -keep class com.opentok.android.v3.$ { ; } -keep public class * extends com.opentok.android.v3.OpentokException -keep class com.opentok.android. { ; } -keep class com.opentok.android.Session { ; } -keep class com.opentok.client. { *; } -keep class com.opentok.impl. { *; } -keep class com.opentok.otc. { *; } -keep class org.webrtc.* { ; } -keep class org.otwebrtc. { *; } -keep class org.otwebrtc.voiceengine. { ; } -keep class org.otwebrtc.WebRtcClassLoader {;} -keep class org.otwebrtc.voiceengine61. { ; } -keep class org.otwebrtc.voiceengine.BuildInfo { ; }

-dontwarn com.opentok. -keepclassmembers class com.opentok. { *; }

bilalsammour commented 3 years ago

Hi, I also having the same issue with release build. App is crashing while starting audio or video call. Development build its not crashing. Please suggest the solution for this. image

I found a workaround to fix the issue:

minifyEnabled false
shrinkResources false

useProguard true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

-keep class androidx.lifecycle.DefaultLifecycleObserver

That is it.

emartynov commented 2 years ago

Do you guys consider to have example with the obfuscation rules? Do you guys consider to ship with obfuscation rules inside aar file?

CamiiloAF commented 7 months ago

useProguard was removed in gradle 7.0.0. If you're using gradle >7.0.0 just add the following lines under buildTypes :

minifyEnabled false shrinkResources false