Android Volley Proguard抛出java.lang.RuntimeException:Stub [英] Android volley proguard throws java.lang.RuntimeException: Stub

查看:241
本文介绍了Android Volley Proguard抛出java.lang.RuntimeException:Stub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Volley网络库,当我将其保留在调试+释放模式下时,它可以很好地工作,直到我添加了 Twilio客户端SDK .现在,它在调试模式下可以正常工作,但在发布模式下会抛出此错误

I'm using Android Volley network library which when kept in debugging + release modes works perfectly fine, until I added Twilio client SDK. Now it works fine when in debugging mode but when in release mode throws this error

 E/Volley: [105358] NetworkDispatcher.run: Unhandled exception java.lang.RuntimeException: Stub!
                                   java.lang.RuntimeException: Stub!
                                       at org.apache.a.h.<init>(SourceFile:6)
                                       at com.android.volley.toolbox.HurlStack.performRequest(SourceFile:109)
                                       at com.android.volley.toolbox.BasicNetwork.performRequest(SourceFile:97)
                                       at com.android.volley.NetworkDispatcher.run(SourceFile:114)

从Android Volley字符串reqiest的error界面获取的日志

The log taken from the error interface of the Android volley string reqiest

01-10 16:42:27.330 522-522/? D/LOGINACTIVITY: java.lang.RuntimeException: Stub!-java.lang.RuntimeException: Stub!-java.lang.RuntimeException: Stub!

寻找相同的内容并得到了一些答复,要求他们将JUint保留在依赖项列表的顶部.错误仍然存​​在.任何帮助将不胜感激. TIA

Have looked for the same and got some response where they are asking to keep the JUint in top of the dependency list. Still the error persists. Any sort of help will be appreciated. TIA

更新1:

已添加代码库

StringRequest strReq = new StringRequest(Request.Method.POST,
                    AppConfig.URL_LOGIN, new Response.Listener<String>() {

                @Override
                public void onResponse(String response) {

                    ....

                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d("LOGINACTIVITY", error.getLocalizedMessage() + "-" + error.getMessage() + "-" + error.getCause());

                }
            }) {

                @Override
                protected Map<String, String> getParams() {
                    // Posting parameters to login url
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("email", email);
                    params.put("password", password);
                    return params;
                }

            };

            // Adding request to request queue
            strReq.setShouldCache(false);
            strReq.setRetryPolicy(new DefaultRetryPolicy(AppConfig.DEFAULT_RETRY_TIME, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
            AppController.getInstance().addToRequestQueue(strReq, tag_string_req);

更新2:

添加了用例

  1. 应用程序启动并要求用户允许诸如位置,短信读取,..
  2. 之类的权限.
  3. 一旦用户同意这些权限集,就可以输入电子邮件ID和密码.
  4. 电子邮件ID和密码是通过getParam()传递的参数.
  5. 当通过凌空StringRequest请求以下内容时,最终将转到"OnErrorResponse",错误消息为"java.lang.RuntimeException:Stub!"
  1. App starts and requests user to allow the permissions like location, sms read, ..
  2. Once the user agrees to those set of permissions, the user is allowed to enter the email-id & password.
  3. Email-id & password are the parameters passed via the getParam().
  4. When the following is requested through volley StringRequest it ends up going to "OnErrorResponse", where the error message is "java.lang.RuntimeException: Stub!"

更新3:

添加了Proguard规则

Proguard rules added

 # Twilio Client
 -keep class com.twilio.** { *; }
 # Apache HttpClient
-dontwarn org.apache.http.**
-keepattributes InnerClasses
-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient

-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient

-keepattributes EnclosingMethod

推荐答案

我正在发布我的解决方案,以防万一有人觉得某天有用.

I'm posting my solution in case if someone finds it useful someday.

在Android SDK 23中使用Proguard和 com.apache.http.legacy 库时,会发生这种情况.

This happens when using Proguard and the com.apache.http.legacy library in Android SDK 23.

事实上,所有方法都被存根以引发带有消息"Stub!"的异常.当您打电话给他们时.多么可爱.

As a matter of fact, all the methods are stubbed out to throw an exception with the message "Stub!" when you call them. How cute.

真实的android.jar实现可在模拟器或真实的Android设备上运行.

The real android.jar implementations live on the emulator, or your real Android device.

因此,更改proguard规则可以解决以下问题,似乎twilio正在使用旧的http库或不确定的东西.

So changing the proguard rules solved the following, seems like twilio is using old http library or something not sure.

所以,这是我当前的解决方案

So, here's my current solution

   # Twilio Client
 -keep class com.twilio.** { *; }

-keep class org.webrtc.** { *; }
-keep class com.twilio.video.** { *; }
-keepattributes InnerClasses

-keep class org.apache.http.** { *; }
-keep class org.apache.commons.codec.** { *; }
-keep class org.apache.commons.logging.** { *; }
-keep class android.net.compatibility.** { *; }
-keep class android.net.http.** { *; }
-keep class com.android.internal.http.multipart.** { *; }
-dontwarn org.apache.http.**
-dontwarn android.webkit.**

-keepattributes EnclosingMethod

来源链接到SO答案

这篇关于Android Volley Proguard抛出java.lang.RuntimeException:Stub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆