问题备忘

未修复问题更新为已修复

1,

java.lang.IllegalArgumentException: bad parameter
	at org.apache.http.client.utils.URLEncodedUtils.parse(URLEncodedUtils.java:139)
	at org.apache.http.client.utils.URLEncodedUtils.parse(URLEncodedUtils.java:76)
	at android.webkit.AccessibilityInjector.getAxsUrlParameterValue(AccessibilityInjector.java:404)
	at android.webkit.AccessibilityInjector.shouldInjectJavaScript(AccessibilityInjector.java:323)
	at android.webkit.AccessibilityInjector.onPageFinished(AccessibilityInjector.java:282)
	at android.webkit.WebViewClassic.onPageFinished(WebViewClassic.java:4837)
	at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:406)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:155)
	at android.app.ActivityThread.main(ActivityThread.java:5511)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
	at dalvik.system.NativeStart.main(Native Method)
修复方式:
4.1系统加载的网页若可能出现异常则占时关闭Js,规避Crash
 /**
     * fix 4.1系统加载网页时出现IllegalArgumentException
     */
    public static void disableJsIfUrlEncodedFailed(IWebView webView, String url){
        if(Build.VERSION.SDK_INT != 16) {return;}
        try {
            URLEncodedUtils.parse(new URI(url), null);
            webView.getSettings().setJavaScriptEnabled(true);
        } catch (URISyntaxException ignored) {
        } catch (IllegalArgumentException e) {
            webView.getSettings().setJavaScriptEnabled(false);
        }
    }


2,

java.lang.NullPointerException
	at android.webkit.AccessibilityInjector$TextToSpeechWrapper$1.onInit(AccessibilityInjector.java:753)
	at android.speech.tts.TextToSpeech.dispatchOnInit(TextToSpeech.java:640)
	at android.speech.tts.TextToSpeech.initTts(TextToSpeech.java:619)
	at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:553)
	at android.webkit.AccessibilityInjector$TextToSpeechWrapper.<init>(AccessibilityInjector.java:676)
	at android.webkit.AccessibilityInjector.addTtsApis(AccessibilityInjector.java:480)
	at android.webkit.AccessibilityInjector.addAccessibilityApisIfNecessary(AccessibilityInjector.java:168)
	at android.webkit.AccessibilityInjector.onPageStarted(AccessibilityInjector.java:340)
	at android.webkit.WebViewClassic.onPageStarted(WebViewClassic.java:4480)
	at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:366)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loop(Looper.java:194)
	at android.app.ActivityThread.main(ActivityThread.java:5407)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:525)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
	at dalvik.system.NativeStart.main(Native Method)
修复方案:
问题主要集中在4.2.1和4.2.2 ,对此针对性处理:
    /**
     * 关闭辅助功能,针对4.2.1和4.2.2 崩溃问题
     * java.lang.NullPointerException
     * at android.webkit.AccessibilityInjector$TextToSpeechWrapper$1.onInit(AccessibilityInjector.java:753)
     * ... ...
     * at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:321)
     */
    private void disableAccessibility() {
        if (Build.VERSION.SDK_INT == 17/*4.2 (Build.VERSION_CODES.JELLY_BEAN_MR1)*/) {
            Context context;
            if ((context = getContext()) != null) {
                try {
                    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
                    if (!am.isEnabled()) {
                        return;
                    }
                    Method set = am.getClass().getDeclaredMethod("setState", int.class);
                    set.setAccessible(true);
                    set.invoke(am, 0);/**{@link AccessibilityManager#STATE_FLAG_ACCESSIBILITY_ENABLED}*/
                } catch (Exception e) {
                }
            }
        }
    }


 
 

你可能感兴趣的:(问题备忘)