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

  • SEARCH
  • Home
  • 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 8786757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:43:11+00:00 2026-06-13T21:43:11+00:00

Im trying to implement a Phonegap CordovaWebView into my Fragment, but it doesn’t work.

  • 0

Im trying to implement a Phonegap CordovaWebView into my Fragment, but it doesn’t work.

My Layout looks like the following (cordovawebview.xml):

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">

<org.apache.cordova.CordovaWebView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id = "@+id/mainView"/>

</FrameLayout>

In My Fragment’s onCreateView() I try to inflate the layout:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.cordovawebview, container); // <--- the error occurs here!
    // CordovaWebView webView = (CordovaWebView)v.findViewById(R.id.mainView);

    return v;
}

Maybe someone has some hints how to fix it. I always get that error:

10-25 15:52:02.839: ERROR/AndroidRuntime(2878): FATAL EXCEPTION: main
    android.view.InflateException: Binary XML file line #21: Error inflating class org.apache.cordova.CordovaWebView
    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    at com.advantageframework.tabs.fragments.SampleFragmentA.onCreateView(SampleFragmentA.java:81)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    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:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
    ... 19 more
    Caused by: java.lang.NullPointerException
    at org.apache.cordova.CordovaWebView.loadConfiguration(CordovaWebView.java:643)
    at org.apache.cordova.CordovaWebView.<init>(CordovaWebView.java:131)
    ... 22 more
  • 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-13T21:43:12+00:00Added an answer on June 13, 2026 at 9:43 pm

    I found the answer. If you look in your logcat you see, that it tries to cast the Context to CordovaInterface. The context is the Activity. There it fails. You probably made the Fragment be CordovaInterface. That is what I did. You will have to make the Activity a CordovaInterface and from the Activity forward the events (onMessage, …) to the Fragment.

    Here is my activity (with some stuff removed to make it simpler). I have something very close to this that works pretty well. You will still experience some smaller problems afterwards, but those are easy to solve.

    public class MyCordovaActivity extends SherlockFragmentActivity implements
            CordovaInterface {
        private final ExecutorService mThreadPool = Executors.newCachedThreadPool();
        private CordovaPlugin mActivityResultCallback;
    
        private CordovaFragment mFragment;
    
        @Override
        protected void onCreate(final Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.nbu_web_activity);
            mFragment = new CordovaFragment();
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.fragment, mFragment)
                    .commit();
    
            // TODO this value you could pass to the activity with a intent extra
            // or allow to do this through a seperate function, ...
            String url = "http://....";
            mFragment.loadUrl(url);
        }
    
        @Override
        protected void onNewIntent(final Intent intent) {
            super.onNewIntent(intent);
            NBUGapFragment fragment = getCordovaFragment();
            if (fragment != null && fragment.appView != null) {
                fragment.appView.onNewIntent(intent);
            }
        }
    
        @Override
        public void onBackPressed() {
            NBUGapFragment fragment = getCordovaFragment();
            if (fragment == null || !fragment.onBackPressed()) {
                super.onBackPressed();
            }
        }
    
        @Override
        public void cancelLoadUrl() {
            getCordovaFragment().cancelLoadUrl();
        }
    
        @Override
        public Activity getActivity() {
            return this;
        }
    
        @Override
        public Context getContext() {
            return this;
        }
    
        @Override
        public ExecutorService getThreadPool() {
            return mThreadPool;
        }
    
        @Override
        public Object onMessage(final String id, final Object data) {
            return getCordovaFragment().onMessage(id, data);
        }
    
        @Override
        public void setActivityResultCallback(final CordovaPlugin plugin) {
            mActivityResultCallback = plugin;
        }
    
        @Override
        public void startActivityForResult(final CordovaPlugin plugin, final Intent intent,
                final int requestCode) {
            mActivityResultCallback = plugin;
            startActivityForResult(intent, requestCode);
        }
    
        @Override
        protected void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
            if (mActivityResultCallback != null) {
                mActivityResultCallback.onActivityResult(requestCode, resultCode, intent);
            } else {
                super.onActivityResult(requestCode, resultCode, intent);
            }
        }
    
        private CordovaFragment getCordovaFragment() {
            // the CordovaFragment is the one implementing CordovaInterface
            return mFragment;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement an autocomplete based on this It looks like it's very straight
trying to implement the following but its not working <script> function loadmap(lat,lng) { //alert(lat,lang);
Trying to implement the new FP 10.1 Global error handler into my projects but
I am trying implement a most recent widget into my tumblr post. So far,
Trying to implement AVAudioplayer and get some metering data of the played music, but
While trying to implement a scene where item sizes do not change but distances
I am trying to implement a Codeigniter based app on Android via phonegap, all
I'm new to phoneGap, and i'm trying to implement a webview in android with
Trying to implement the following structure from c to use NSArray in objective-c: In
I've been trying to setup gwt-phonegap in my project, but keep getting timeout, saying

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.