Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:56:24+00:00 2026-06-07T10:56:24+00:00

Following the WebView documentation , I want to inject a public java function to

  • 0

Following the WebView documentation, I want to inject a public java function to webView and call it using JavasSript, when that function is in form of

public String myfunc(){ 
//....
}

It works,
but when using throws keyword it will cause a fatal error.

This is my complete code:

package com.arad.test1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.widget.Toast;

import com.arad.test1.model.test;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Test1Activity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.test);
        final WebView myWebView = (WebView) findViewById(R.id.webView1);
        myWebView.getSettings().setJavaScriptEnabled(true);
        myWebView.getSettings().setPluginState(PluginState.ON);
        myWebView.addJavascriptInterface(this, "appConnector");
        try {
            myWebView.loadDataWithBaseURL(
                    "file:///android_asset/",
                    convertStreamToString(getAssets().open(
                            "templates/test.html")), "text/html", "utf-8", "");
        } catch (IOException e) {
            Log.e("Test1", e.getMessage());
        }
    }

    public String load() {
        return generateJsonFromClass();
    }

    private String generateJsonFromClass() {
        try {
            ObjectMapper mapper = new ObjectMapper();
            test t = new test();
            String result = mapper.writeValueAsString(t);
            return result;
        } catch (JsonGenerationException e) {
            Log.e("Test1", e.getMessage());
            return "JsonGenerationException";
        } catch (JsonMappingException e) {
            Log.e("Test1", e.getMessage());
            return "JsonMappingException";
        } catch (IOException e) {
            Log.e("Test1", e.getMessage());
            return "IOException";
        }
    }

    private static String convertStreamToString(InputStream is) {

        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();

        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }
}

This is the DDMS Log:

07-10 10:02:42.183: E/dalvikvm(20521): Could not find class 'com.fasterxml.jackson.databind.ObjectMapper', referenced from method com.arad.test1.Test1Activity.generateJsonFromClass 
07-10 10:02:42.183: W/dalvikvm(20521): VFY: unable to resolve new-instance 28 (Lcom/fasterxml/jackson/databind/ObjectMapper;) in Lcom/arad/test1/Test1Activity; 
07-10 10:02:42.183: D/dalvikvm(20521): VFY: replacing opcode 0x22 at 0x0000 
07-10 10:02:42.183: W/dalvikvm(20521): VFY: unable to resolve exception class 26 (Lcom/fasterxml/jackson/core/JsonGenerationException;) 
07-10 10:02:42.183: W/dalvikvm(20521): VFY: unable to find exception handler at addr 0xf 
07-10 10:02:42.183: W/dalvikvm(20521): VFY: rejected Lcom/arad/test1/Test1Activity;.generateJsonFromClass ()Ljava/lang/String; 
07-10 10:02:42.183: W/dalvikvm(20521): VFY: rejecting opcode 0x0d at 0x000f 
07-10 10:02:42.183: W/dalvikvm(20521): VFY: rejected Lcom/arad/test1/Test1Activity;.generateJsonFromClass ()Ljava/lang/String; 
07-10 10:02:42.212: W/dalvikvm(20521): Verifier rejected class Lcom/arad/test1/Test1Activity; 
07-10 10:02:42.212: W/dalvikvm(20521): Class init failed in newInstance call (Lcom/arad/test1/Test1Activity;) 
07-10 10:02:42.223: D/AndroidRuntime(20521): Shutting down VM 
07-10 10:02:42.223: W/dalvikvm(20521): threadid=1: thread exiting with uncaught exception (group=0x409c01f8) 
07-10 10:02:42.322: E/AndroidRuntime(20521): FATAL EXCEPTION: main 
07-10 10:02:42.322: E/AndroidRuntime(20521): java.lang.VerifyError: com/arad/test1/Test1Activity 
07-10 10:02:42.322: E/AndroidRuntime(20521): at java.lang.Class.newInstanceImpl(Native Method) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at java.lang.Class.newInstance(Class.java:1319) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at android.app.Instrumentation.newActivity(Instrumentation.java:1023) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at android.app.ActivityThread.access$600(ActivityThread.java:123) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at android.os.Handler.dispatchMessage(Handler.java:99) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at android.os.Looper.loop(Looper.java:137) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at android.app.ActivityThread.main(ActivityThread.java:4424) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at java.lang.reflect.Method.invokeNative(Native Method) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at java.lang.reflect.Method.invoke(Method.java:511) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
07-10 10:02:42.322: E/AndroidRuntime(20521): at dalvik.system.NativeStart.main(Native Method) 
07-10 10:02:42.352: I/dalvikvm(20521): threadid=3: reacting to signal 3 
07-10 10:02:42.432: I/dalvikvm(20521): Wrote stack traces to '/data/anr/traces.txt' 
07-10 10:02:42.632: I/dalvikvm(20521): threadid=3: reacting to signal 3 
07-10 10:02:42.652: I/dalvikvm(20521): Wrote stack traces to '/data/anr/traces.txt' 
07-10 10:02:43.122: I/dalvikvm(20521): threadid=3: reacting to signal 3 
07-10 10:02:43.213: I/dalvikvm(20521): Wrote stack traces to '/data/anr/traces.txt' 

How to fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:56:26+00:00Added an answer on June 7, 2026 at 10:56 am

    change your library folder name to libs from lib

    Android: What is the folder name of the jar files (LIB or LIBS)?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a web view, in my webview i want to inject the following
I have following code: public class reader extends Activity { WebView mWebView; String mFilename;
Following is my html content which i want to show in the webview using
The following view crashes the iPhone If I comment out the using (webView =
My java Fx webview throws JS exception for following code. Can anyone explain me
I am giving the following method call to my webview client embedded in my
I am trying to create a WebView dynamically using the following code: mWebView =
trouble loading html file from plist to webView using following code in FAQDetailViewController.m: -
I am using the following code to render my webview in android - webview.loadDataWithBaseURL(null,
I am using the following link inside a WebView to show a pdf file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.