voximplant / react-native-voximplant

Voximplant mobile SDK for React Native (iOS/Android)
http://voximplant.com
205 stars 39 forks source link

Force close app when build release apk with enableSeparateBuildPerCPUArchitecture and enableProguardInReleaseBuilds = true #119

Closed gandarain closed 2 years ago

gandarain commented 4 years ago

I try to implement chat feature with voximplant in. my React Native app and I use react native voximplant sdk, for my project. In debug mode, everything is fine. In release mode with set enableSeparateBuildPerCPUArchitecture and enableProguardInReleaseBuilds equal to false, everything is working fine too. But when I try to set enableSeparateBuildPerCPUArchitecture and enableProguardInReleaseBuilds equal to true. My react native app will force close. I try to figure out, what happend and what fuction will make a force close app. And I found this

async loginVoximplant() {
    let clientConfig = {}
    let client = Voximplant.getInstance(clientConfig)
    try {
      await client.disconnect()
      let state = await client.getClientState()
      if (state === Voximplant.ClientState.DISCONNECTED) {
        await client.connect()
      }
      let authResult = await client.login(this.props.profile.voximplant_username, this.props.profile.voximplant_password)
      console.log('Response from login voximplant ', authResult)
      this.getTransactionChat(this.props.profile.type)
    } catch (e) {
      console.log('Error from login voximplant ', e)
    }
  }

I call this function in my component did mount, when I command this function, everything working fine with enableSeparateBuildPerCPUArchitecture and enableProguardInReleaseBuilds equal to true. I dont know why. Please give me an solution for this problem

YuliaGrigorieva commented 4 years ago

Hello @gandarain ,

I think the issue might be cause by enableProguardInReleaseBuilds = true and proguard strips some parts of the Voximplant native SDK.

Please add to the proguard rules the following:

-keep class org.webrtc.voiceengine.** {*;}
-keep class org.webrtc.** {*;}
-keepnames public class org.webrtc.voiceengine.** {*;}
-keepnames public class org.webrtc.** {*;}
-keepclasseswithmembernames class * { native <methods>; }

-keepclassmembers enum * {
    public static **[] values();    public static ** valueOf(java.lang.String);}

-keep public class com.zingaya.voximplant.* {
      public protected *;}

-keep public class com.voximplant.sdk.* {
      public protected *;}

and the rules from our dependencies: https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro

Please let me know the results.

Best regards, Yulia Grigorieva

gandarain commented 4 years ago

Thanks for your answer, I have seen the link you sent. But I dont know where I will put the command from this link. https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro

Any idea, where I should put that command? Thanks.

YuliaGrigorieva commented 4 years ago

You should have proguard-rules.pro file in your project located in <your_project>/android/app folder.

You need to put everything from these files and a snippet that I have provided in my previous comment to this file.

gandarain commented 4 years ago

Your solution is working, my application will not force close again, but now I get a new error from get conversation. When debug mode, everything is working fine, you can see this image.

But when relase mode and enableSeparateBuildPerCPUArchitecture and enableProguardInReleaseBuilds equal to true, I get an error in get conversation. This is my code, for get conversation,

async getConversation(conversation_id) {
    try {
      let messaging = Voximplant.Messaging.Messenger.getInstance()
      let conversation = await messaging.getConversation(conversation_id)
      this.setState({ conversation })
      console.log('Response from get conversation voximplant ', conversation)
    } catch (e) {
      console.log('Error from get conversation voximplant ', e)
      Alert.alert('Error', `Error get conversation voximplant ${JSON.stringify(e)}`)
    }
  }

The error code is 10002, description error is Response Timeout.

Any idea, how to fix this error?

YuliaGrigorieva commented 4 years ago

Hi @gandarain !

Is it 100% reproducible issue?

I need the SDK logs with getConversation response to understand what causes this issue.

Best regards, Yulia Grigorieva

gandarain commented 4 years ago

Hi, thanks for reply this issue. DId you mean this log?

YuliaGrigorieva commented 4 years ago

No, I mean adb logcat logs (from Android Studio for example) with VOXSDK tag

gandarain commented 4 years ago

Did you mean this log?

2020-08-02 20:56:47.233 31305-31358/? I/VOXSDK: Signaling: SEND: {"name":"__ping","params":[]}
2020-08-02 20:56:47.431 31305-31358/? I/VOXSDK: Signaling: onMessage: {"name" : "__pong" , "params" : []}
2020-08-02 20:56:57.434 31305-31358/? I/VOXSDK: Signaling: SEND: {"name":"__ping","params":[]}
2020-08-02 20:56:57.630 31305-31358/? I/VOXSDK: Signaling: onMessage: {"name" : "__pong" , "params" : []}
2020-08-02 20:57:07.632 31305-31358/? I/VOXSDK: Signaling: SEND: {"name":"__ping","params":[]}
2020-08-02 20:57:07.831 31305-31358/? I/VOXSDK: Signaling: onMessage: {"name" : "__pong" , "params" : []}
2020-08-02 20:57:08.333 31305-1290/? W/VOXSDK: Invoke completion handler onError with code: 10002 for action: CREATE_CONVERSATION
2020-08-02 20:57:17.834 31305-31358/? I/VOXSDK: Signaling: SEND: {"name":"__ping","params":[]}
2020-08-02 20:57:18.171 31305-31358/? I/VOXSDK: Signaling: onMessage: {"name" : "__pong" , "params" : []}
2020-08-02 20:57:28.173 31305-31358/? I/VOXSDK: Signaling: SEND: {"name":"__ping","params":[]}
2020-08-02 20:57:28.380 31305-31358/? I/VOXSDK: Signaling: onMessage: {"name" : "__pong" , "params" : []}
2020-08-02 20:57:38.382 31305-31358/? I/VOXSDK: Signaling: SEND: {"name":"__ping","params":[]}
2020-08-02 20:57:38.595 31305-31358/? I/VOXSDK: Signaling: onMessage: {"name" : "__pong" , "params" : []}
2020-08-02 20:57:48.598 31305-31358/? I/VOXSDK: Signaling: SEND: {"name":"__ping","params":[]}
2020-08-02 20:57:48.801 31305-31358/? I/VOXSDK: Signaling: onMessage: {"name" : "__pong" , "params" : []}
2020-08-02 20:57:58.802 31305-31358/? I/VOXSDK: Signaling: SEND: {"name":"__ping","params":[]}
2020-08-02 20:57:59.010 31305-31358/? I/VOXSDK: Signaling: onMessage: {"name" : "__pong" , "params" : []}

@YuliaGrigorieva

YuliaGrigorieva commented 4 years ago

Hello @gandarain ,

Sorry for the delayed response.

Yes, I need these logs. However, could you please capture them starting a messaging API call, i.e. "getConversation" or any other you received an error.

Best regards, Yulia Grigorieva