1. Are you ready for the Galaxy S20? Here is everything we know so far!

Embedding CordovaWebview v5.4.1 into Android?

Discussion in 'Android Development' started by neonwarge04, Jan 17, 2016.

  1. neonwarge04

    neonwarge04 Lurker
    Thread Starter

    The documentation on the official site was so bad it gave me cancer.
    I am embedding cordova webviews just trying to see if the webview is showing up but unfortunately I am getting and an Inflation exception indicating that the org.apache.cordova.CordovaWebView is not a View.

    Also this is the onCreate code provided from the docs:
    Code (Java):
    1. public class CordovaViewTestActivity extends Activity implements CordovaInterface {
    2.     CordovaWebView cwv;
    3.     /* Called when the activity is first created. */
    4.     @Override
    5.     public void onCreate(Bundle savedInstanceState) {
    6.         super.onCreate(savedInstanceState);
    7.         setContentView(R.layout.main);
    8.         cwv = (CordovaWebView) findViewById(R.id.tutorialView);
    9.         Config.init(this);
    10.         cwv.loadUrl(Config.getStartUrl());
    11.     }
    12.  
    The code above doesn't seem to work anymore. I just checked the file and the file seems to look like its been changed to an Interface. Also the line Config.init(this) is deprecated so maybe this is causing the problem? And guess what, its not stated in the documentation on what is proper way of initiating your web views. NONE. Apache Cordova is such a horrible framework to work with.

    Here is my stack trace when I try to run it as is:

    Code (Text):
    1. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime: FATAL EXCEPTION: main
    2. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.neonwarge.android.sample.webviews/com.neonwarge.android.sample.webviews.MainActivity}: android.view.InflateException: Binary XML file line #13: Class is not a View org.apache.cordova.CordovaWebView
    3. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
    4. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
    5. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:127)
    6. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
    7. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
    8. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137)
    9. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:4441)
    10. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
    11. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511)
    12. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    13. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    14. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
    15. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:  Caused by: android.view.InflateException: Binary XML file line #13: Class is not a View org.apache.cordova.CordovaWebView
    16. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:597)
    17. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
    18. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
    19. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    20. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    21. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    22. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
    23. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
    24. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at com.neonwarge.android.sample.webviews.MainActivity.onCreate(MainActivity.java:26)
    25. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:4465)
    26. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    27. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
    28. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
    29. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:127)
    30. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
    31. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
    32. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137)
    33. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:4441)
    34. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
    35. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511)
    36. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    37. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    38. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
    39. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:  Caused by: java.lang.ClassCastException: org.apache.cordova.CordovaWebView cannot be cast to android.view.View
    40. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at java.lang.Class.asSubclass(Class.java:1380)
    41. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:552)
    42. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
    43. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
    44. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    45. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    46. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    47. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
    48. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
    49. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at com.neonwarge.android.sample.webviews.MainActivity.onCreate(MainActivity.java:26)
    50. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:4465)
    51. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    52. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
    53. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
    54. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:127)
    55. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
    56. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
    57. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137)
    58. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:4441)
    59. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
    60. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511)
    61. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    62. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    63. 01-17 17:22:44.758 4787-4787/? E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
    64.  
    This is frustrating, I never thought dealing with Cordova can be this hard. Imagine, their documentation is faulty and outdated.

    Anyone here successfully tried to embed cordova on their apps? Please let me know. I will appreciate any help. And please don't suggest the hacks on StackOverflow, I am not going to use it. Its a mess and hard to maintain, doesn't worth my time and risk.

    Thank you!
     



    1. Download the Forums for Android™ app!


      Download

       
  2. @neonwarge04 I am working on Apache Cordova team at Microsoft. Our team is interested in understanding your experiences with embedded Cordova web views. Would you be able to fill in this quick contact info survey http://www.instant.ly/s/WGx9L so that we can get in touch with you?
     
    Deleted User likes this.
  3. scary alien

    scary alien not really so scary
    VIP Member

    Welcome to our AndroidForums, @Bohdan Petrivskyy :).

    Is there anything you might share with us / our members here? (not that I know anything about Apache Cordova like @neonwarge04 clearly does :p, but I'm sure others might :)).

    Cheers!
     
Loading...

Share This Page

Loading...