简体   繁体   English

无法将Cordova插件添加到我的PhoneGap项目中

[英]Can't add a Cordova plugin to my PhoneGap project

I'm new to Phonegap (using CLI to start the project and manage it, and desktop to serve, both running on Windows8), 我是Phonegap的新手(使用CLI启动项目并对其进行管理,并使用桌面进行服务,两者均在Windows8上运行),

This is what I've done so far: 到目前为止,这是我所做的:

phonegap plugin add cordovarduino

Fetching plugin "cordovarduino" via npm

Plugin "fr.drangies.cordova.serial" already installed on android. Making it top-
level.

Plugin "fr.drangies.cordova.serial" already installed on browser.

On the project; 在项目上;

serialMonitor: function(){
        app.debug("Initializing Serial Monitor");
        try {
            //cordova.require("serial.js");
            serial.requestPermission({
                    driver: 'FtdiSerialDriver' // or any other
                },
                function success(){app.debug("Granted access");},
                function error()  {app.debug("Denied access");}
            );

        }catch(err) {
            app.debug("Error: "+ err.message);          
        }


    }

In platform/android/res/xml/config.xml: 在platform / android / res / xml / config.xml中:

<feature name="Serial">
    <param name="android-package" value="fr.drangies.cordova.serial.Serial" />
</feature>

But in platform/browser/res/xml/config.xml, there wasn't added, so I added it manually, as 但是在platform / browser / res / xml / config.xml中,没有添加,所以我手动添加了

<param name="android-package" value="fr.drangies.cordova.serial.Serial" />

and then replaced as 然后替换为

<param name="browser-package" value="fr.drangies.cordova.serial.Serial" />

Also included cordova.js and called serialMonitor() on ondeviceready event. 还包括cordova.js,并在ondeviceready事件上调用了serialMonitor()。

But I'm still getting : 但是我仍然得到:

serial is not defined

Maybe is not a bug!, any help please? 也许不是错误!,有什么帮助吗?

Alright, after struggling against PhoneGap CLI with issues related to Build Tools version, and some other stuff, I've managed to build and deploy on Android the .apk, once there, and ONLY WHEN OTG CABLE WAS PLUGGED AND ARDUINO DETECTED BY ANDROID (info for cordovarduino users), permissions where asked and eureka! 好吧,在与PhoneGap CLI进行了有关构建工具版本等问题的斗争之后,我设法在Android上构建并部署了.apk,并且只有在插入OTG电缆并由ANDROID检测到ARDUINO的情况下( info for cordovarduino用户),权限询问和eureka! "Granted access" was prompt, therefore serial object was found. 提示“授予访问权限”,因此找到了串行对象。

Conclussion: 结论:

Yes, some plugins are ment ONLY to work (became callable) on some platforms , and PhoneGap Developer App is, correct me if I'm wrong, a browser platform. 是的, 某些插件仅在某些平台上有效(可以调用) ,而PhoneGap Developer App是,如果我错了,请纠正我的浏览器平台。

So running the compiled apk directly on that platform will allow some plugins to be callable in runtime, otherwise not. 因此,直接在该平台上运行已编译的apk将允许某些插件在运行时可调用,否则无法调用。

Sorry if this was obvious to many people, but it was my first day on PhoneGap. 抱歉,这对于许多人来说都是显而易见的,但这是我在PhoneGap上的第一天。

Live long and prosper. 健康长寿·繁荣昌盛。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM