Phonegap Android: Unknown chromium error: -6

匿名 (未验证) 提交于 2019-12-03 08:46:08

问题:

I'm creating a Phonegap Android app and I'm having trouble when adding a plugin to it. Cordova version is 2.2.0. I'm not using jQM or Sencha Touch. I test the app on Android 4.0.

The plugin I refer to is Android Phonegap plugin. This is my index.html file:

<!DOCTYPE html> <html>   <head>     ...   </head>   <body>     <div class="wrapper">       ...     </div>      <script type="text/javascript" src="vendor/cordova-2.2.0.js"></script>     <script type="text/javascript" src="assets/application.js"></script>     <script type="text/javascript" src="js/index.js"></script>     <script type="text/javascript" src="js/datePickerPlugin.js"></script>   </body> </html> 

This is my main Java file:

import android.app.Activity; import android.os.Bundle; import org.apache.cordova.*;  public class looker extends DroidGap     {         @Override         public void onCreate(Bundle savedInstanceState)             {                 super.onCreate(savedInstanceState);                 super.setIntegerProperty("splashscreen", R.drawable.splash);                 super.loadUrl("file:///android_asset/www/index.html", 7000);             }     } 

So in order to understand if the problem is within the plugin, I minimized this file in assets/application.js where all my minimized scripts I use are. I removed the script tag for the plugin from index.html and the plugin was working just fine! So it's got something to do with the URL's maybe?

What have I tried so far?

I was researching a lot and tried several solutions to other similar problems.

  1. Made sure I have 3 /'s for the loadUrl in my main class:

    public void onCreate(Bundle savedInstanceState)     {       super.onCreate(savedInstanceState);       super.setIntegerProperty("splashscreen", R.drawable.splash);       super.loadUrl("file:///android_asset/www/index.html", 7000);     } 

    Had that from the very beginning, didn't make any difference.

  2. Tried calling super.init() before super.loadUrl(). Didn't work as well.

  3. Tried this:

    public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     super.init();     super.setIntegerProperty("loadUrlTimeoutValue", 6000);     super.loadUrl("file:///android_asset/www/index.html"); } 

    Still not fixing the problem.

  4. Checked if the file is loaded in the app, by adding an alert();. It loads.

That's in general. Will be glad to provide you with additional info if needed in order to resolve this issue. Thanks in advance!

回答1:

I followed the guide and was able to get the plugin working just fine.

However, I was able to replicate the "Unknown chromium error: -6" when I had this in my config.xml:

<plugin name="DatePickerPlugin1" value="com.phonegap.plugin.DatePickerPlugin"/>

Make sure that the "name" attribute in the XML is DatePickerPlugin, since that is the name that the JavaScript code uses for the plugin: https://github.com/phonegap/phonegap-plugins/blob/master/Android/DatePicker/datePickerPlugin.js#L33

There may be other ways to generate the same error though. If this doesn't help, can you post or link to your HTML file that actually calls out to this plugin, as well as your config.xml? (Make sure you are using a res/xml/config.xml and not res/xml/plugins.xml which has been deprecated here: http://cordova.apache.org/docs/en/2.0.0/guide_upgrading_android_index.md.html#Upgrading%20Cordova%20Android



回答2:

I get the same error: Unknown Chromium error -6"
and my mistake was wrong partials path.

I had to specify relative paths for the partials.

When you use ng-include or the module ngRoute,
instead of this:

ng-include="'/partials/file.html'"

put this one:

ng-include="'partials/file.html'"

If you look I removed the first slash in the path.

This approach solved my chromium error.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!