There are an error on addJavascriptInterface method about WebViewClassic - android

The class WebViewClassic throws a NullPointerException when it invokes addJavascriptInterface method on Android 4.3. I don't find the NullPointerException from the system source of android 4.3. addJavascriptInterface method
I think it should be a system bug. Help me please. thanks.
java.lang.NullPointerException
at android.webkit.WebViewClassic.addJavascriptInterface(WebViewClassic.java:4314)
at android.webkit.WebView.addJavascriptInterface(WebView.java:1533)
at com.browser.webview_checkmode.BrowserWebViewFactory$1.run(BrowserWebViewFactory.java:71)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5166)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)

Related

How to handle Crash with setHasTransientState() on android 4.0.3?

I am seeing this crash on android 4.0.3 version. All above versions are working fine. How to solve this crash ?
java.lang.NoSuchMethodError: android.view.View.setHasTransientState
at com.techmash.playo.fragments.AddFavAreaFragment$AreaAdapter$ViewHolder.onClick(AddFavAreaFragment.java:338)
at android.view.View.performClick(View.java:3524)
at android.view.View$PerformClick.run(View.java:14194)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4476)
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:816)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:583)
at dalvik.system.NativeStart.main(Native Method)
This method available in SDK starting API level 16. You can use ViewCompat from support library for previous versions.
ViewCompat.setHasTransientState(view, true);

Android UIAutomation Instrumentation NoSuchMethod Exception

Any idea why I get this exceptions. Its supposed to be very straight forward and simple. It compiles without any errors or warnings. At run time it throws exception.
Instrumentation im = new Instrumentation();
UiAutomation myVar = im.getUiAutomation();
myVar.injectInputEvent(evntDown,false);
Here's the exception.
01-26 11:59:17.344 17742-17742/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoSuchMethodError: android.app.Instrumentation.getUiAutomation
at com.infostretch.automateme.MainActivity$1.onClick(MainActivity.java:51)
at android.view.View.performClick(View.java:4202)
at android.view.View$PerformClick.run(View.java:17340)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
UIAutomation was included in API 18. NoSuchMethod Exception occurs when you try to access/use a class/method that is not supported on OS/API version you are currently running the app on.

Errors related to Android NDK

Running this in my android device gives me these errors.
Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lffvideolivewallpaper/frankandrobot/com/NativeCalls;
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40ed42a0)
FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at ffvideolivewallpaper.frankandrobot.com.VideoLiveWallpaper.onSharedPreferenceChanged(VideoLiveWallpaper.java:144)
at ffvideolivewallpaper.frankandrobot.com.VideoLiveWallpaper.onCreate(VideoLiveWallpaper.java:78)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2404)
at android.app.ActivityThread.access$1600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load avcore: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at ffvideolivewallpaper.frankandrobot.com.NativeCalls.(NativeCalls.java:42)
... 13 more
I think these errors are related to Android NDK. Can anyone guide me on this, keeping in mind that I have no prior knowledge of Android NDK and how it works.
This may happen if we install the app on a device where the previous version was already installed we always get this kind of error:
Just look at this similar problem : https://groups.google.com/d/topic/android-ndk/YmKly4zEMQ0/discussion
I found the reason why I was getting this error, because I did not build the native libraries. I used ndk-build and the errors got resolved.

Android - crash occurs but the stack trace does not say where it happened

I have a null pointer exception somewhere, but I am not sure where. All I have is this error:
java.lang.NullPointerException
at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:330)
at android.widget.AdapterView.checkFocus(AdapterView.java:700)
at android.widget.AdapterView$AdapterDataSetObserver.onInvalidated(AdapterView.java:823)
at android.widget.AbsListView$AdapterDataSetObserver.onInvalidated(AbsListView.java:5738)
at android.database.DataSetObservable.notifyInvalidated(DataSetObservable.java:47)
at android.widget.BaseAdapter.notifyDataSetInvalidated(BaseAdapter.java:59)
at android.widget.ArrayAdapter$ArrayFilter.publishResults(ArrayAdapter.java:513)
at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4697)
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:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)
Would anyone have any ideas for how to debug this? I have not been able to reproduce it. It just sometimes happens and shows up in my crash logs.
Thanks!
Here's the code for ArrayAdapter: https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/ArrayAdapter.java.
Assuming this is the right version, an NPE on line 330 would be caused if the adapter's dataset (i.e. the backing list or array) is null.
Hope that helps.

Null pointer exception on doing webview.loadUrl()

I've been getting this error in my developer portal. I'm not sure why. Stack trace tracks back into some internal function call inside WebView object.
java.lang.NullPointerException
at android.webkit.WebView.loadUrlImpl(WebView.java:3008)
at android.webkit.WebView.loadUrlImpl(WebView.java:3047)
at android.webkit.WebView.loadUrl(WebView.java:3040)
at com.myapp.android.PreviewActivity.notifyJS(PreviewActivity.java:175)
at com.myapp.android.PreviewActivity.access$14(PreviewActivity.java:174)
at com.myapp.android.PreviewActivity$ActionBarItemClickListener.onClick(PreviewActivity.java:901)
at android.view.View.performClick(View.java:3644)
at android.view.View$PerformClick.run(View.java:14313)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4517)
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:993)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
at dalvik.system.NativeStart.main(Native Method)
In my code at com.myapp.android.PreviewActivity.notifyJS(PreviewActivity.java:175), there is this line
webView.loadUrl("javascript:MyApp.onClick('" + action + "');");
I'm actually invoking a javascript call from my java code. Has anyone faced this issue before?
I found the answer myself. If webView.destroy() has already been called then calling webView.loadUrl() will cause this exception.
It seems that your webview is null. Did you call findView before?

Categories

Resources