简体   繁体   English

升级到phonegap 3.3.0

[英]Upgrade to phonegap 3.3.0

I Am upgrading my phonegap project(s) from phonegap 2.9.0 to the latest one, phonegap 3.3.0. 我正在将我的phonegap项目从phonegap 2.9.0升级到最新的一个,phonegap 3.3.0。 Because it has a lot of big improvements. 因为它有很多很大的改进。

It's about an android project, but soon to be ios as well 这是关于一个Android项目,但很快也将成为ios

However, I Am struggling with it a few days, and still no working code. 但是,我几天都在苦苦挣扎,仍然没有工作代码。

I have done this: 我这样做了:

Installed phonegap and creted a new project like the the manual: http://phonegap.com/install/ 安装了phonegap并创建了一个像手册一样的新项目: http ://phonegap.com/install/

After this I slowly inserted my old code into the www folder and installed the plugins on the new 3.0 way. 在此之后,我慢慢地将我的旧代码插入到www文件夹中,并以新的3.0方式安装插件。

But whatever I do... I get this annoying: 但无论我做什么......我觉得这很烦人:

Error initializing Cordova: Class not found 初始化Cordova时出错:找不到类

Because I used to run it in eclipse and use this debugging console (And did not find out how tot get the debuging from the cli to work... some more investigation to do there), I tried to get it working in eclipse. 因为我曾经在eclipse中运行它并且使用这个调试控制台(并且没有找到如何从cli工作到底工作......还有更多的调查要做),我试图让它在eclipse中工作。

But there, it does not have the cordova jar, and I can't find it anywhere. 但在那里,它没有cordova jar,我无法在任何地方找到它。 I used to add the cordova-2.9.0.jar to the build path, but there is no cordova-3.3.0.jar. 我曾经将cordova-2.9.0.jar添加到构建路径,但是没有cordova-3.3.0.jar。 I saw an answer abouyt creating it yourselve: but this was later remarked as not the proper way (ans since in no phonegap documentation this is mentioned... i cannot imagine that's the way) 我看到了一个答案abouyt创造了你的十二个:但后来被评论为不正确的方式(因为在没有电话档文件中提到这个......我无法想象那是这样的)

In eclipse, this is causing the error: import org.apache.cordova.*; 在eclipse中,这会导致错误:import org.apache.cordova。*;

So like I said... no cordova jar... hwo do you resolve this? 就像我说的那样......没有科多瓦罐......你解决这个问题吗?

So a few questions all at once... 所以一下子就有几个问题......

  1. To get better debugging: how do i get this working in eclipse 为了获得更好的调试:我如何在eclipse中使用它
  2. Why do I get this error... class not found (probably related with the missing jar) 为什么我会收到此错误...找不到类(可能与丢失的jar有关)

None of the related questions gave a solution for me... 没有任何相关问题为我提供了解决方案......

Edit I was just going add, the steps in more detail, like I floowed this step: http://docs.phonegap.com/en/3.3.0/guide_cli_index.md.html#The%20Command-Line%20Interface 编辑我刚刚添加,更详细的步骤,就像我开始这一步: http ://docs.phonegap.com/en/3.3.0/guide_cli_index.md.html#The%20Command-Line%20Interface

but than I noticed... this command: 但比我注意到......这个命令:

sudo npm install -g cordova sudo npm install -g cordova

which I thought I had done, but I had done: 我以为我做过,但我做过:

sudo npm install -g phonegap sudo npm install -g phonegap

But this does not make any difference. 但这没有任何区别。

Running it with: ` 运行它:`

phonegap run android -V --device phonegap运行android -V --device

`Gives: `得到:

[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[phonegap] Generating config.xml from defaults for platform "android"
[phonegap] Compiling app on platform "android" via command "/Path to my app/platforms/android/cordova/build" 
[phonegap] Platform "android" compiled successfully.
[phonegap] successfully compiled Android app
[phonegap] installing app onto device
[phonegap] Generating config.xml from defaults for platform "android"
[phonegap] Running app on platform "android" via command "/Path to my app/platforms/android/cordova/run" --device
[phonegap] Platform "android" ran successfully

but still gives the error as before. 但仍然像以前一样给出错误。 And in eclipse still need to add the cordova jar, which is nowhere to be found.. 在日食中仍然需要添加Cordova jar,这是无处可寻的..

Edit 2 编辑2

I created a new project, just to see what happened when adding this to eclipse.. and it seemed to work. 我创建了一个新项目,只是为了看看将这个添加到eclipse时发生了什么......它似乎有效。 So I removed the project from ecplise... and added it (floowing the phonegap docs for thsi: new android project; Add from existing code). 所以我从ecplise中删除了这个项目...并添加了它(为thsi提供了phonegap文档:新的android项目;从现有代码中添加)。 And now it creates a new jar named - cordova-lib.jar in the folder platforms/CordovaLib/bin 现在它在文件夹platforms / CordovaLib / bin中创建了一个名为 - cordova-lib.jar的新jar

and this seems to work for eclipse... still the same error in the cli run command. 这似乎适用于eclipse ...在cli run命令中仍然存在相同的错误。 But now I can try to run it from eclipse and find out more... (I will post it as soon as I find out what is the error) 但是现在我可以尝试从eclipse运行它并找到更多...(我会在发现错误时立即发布)

Edit 3 编辑3

running it in eclipse shows the error (weird that this is not shown in the -V mode of phonegap): 在eclipse中运行它会显示错误(奇怪的是,这没有显示在-g模式的phonegap中):

01-05 09:04:16.557: D/CordovaLog(698): file:///android_asset/www/phonegap.js: Line 1544 : Could not find cordova.js script tag. Plugin loading may fail.
01-05 09:04:16.567: I/Web Console(698): Could not find cordova.js script tag. Plugin loading may fail. at file:///android_asset/www/phonegap.js:1544

But why isn't this js file there.... 但是为什么这个js文件不存在....

EDIT 16-jan-2014 编辑16-jan-2014

This is becoming a popular question too look at. 这也成为一个受欢迎的问题。 So I am not the only one struggling with phonegap 3.x And here is another yet unsolved question: https://stackoverflow.com/questions/20953653/config-xml-phonegap-3-3-0-ignores-name-and-description 所以我不是唯一一个与phonegap 3.x斗争的人。这是另一个尚未解决的问题: https ://stackoverflow.com/questions/20953653/config-xml-phonegap-3-3-0-ignores-name-and -描述

EDIT 21-jan-2014 Important note (see a lot of questions about this): the config.xml in the blueprint www folderis not the same as described in the phonegap docs. EDIT 21-jan-2014重要提示(请参阅很多关于此的问题):蓝图www文件夹中的config.xml与phonegap文档中描述的不同。 It has another schema, and is the blueprint for both the config.xml per platform, as a lot of other things and files (androoid manifest xml files, icons etc.). 它有另一个模式,并且是每个平台的config.xml的蓝图,作为许多其他的东西和文件(androoid清单xml文件,图标等)。 Unfortunately I have not found a proper description (besides the schema) of this config.xml file (only a good descrition of the platform dependent targets config.xml file) in the phonegap docs yet. 不幸的是,我还没有在phonegap文档中找到这个config.xml文件的正确描述(除了模式之外)(只是平台相关目标config.xml文件的一个很好的描述)。 And it is very confusing they choose the same name for a very different file... 他们为一个非常不同的文件选择相同的名称是非常令人困惑的...

EDIT 12-feb-2014 This might be helpfull... since I still cannot find a proper description of this so called blueprint config.xml on the phonegap pages: https://github.com/phonegap/phonegap-start/blob/master/www/config.xml 编辑12-feb-2014这可能会有所帮助...因为我仍然无法在手机页面上找到这个所谓的蓝图config.xml的正确描述: https//github.com/phonegap/phonegap-start/blob/主/ WWW / config.xml中

Edit 5 may 2014 编辑2014年5月5日

Due to all problems in phonegap, the benefits of the principle behind phonegap has gone for me. 由于phonegap的所有问题,phonegap背后原理的好处已经消失了。 (I still believe in potential phonegap can be the solution... but for now it's to premature). (我仍然相信潜在的手机差距可能是解决方案......但现在还为时过早)。 So I Am sorry i have to leave the phonegap path. 所以我很抱歉我必须离开phonegap路径。 I let this answer open for the ones still searching for answers... but do not expect any answers or the 'acceptance of the right answer' from me. 我让那些仍然在寻找答案的人给出了这个答案......但是不要指望我得到任何答案或“接受正确答案”。

Because it kept complaining about the classes not being found, I suspected this was about the plugin classes. 因为它一直在抱怨没有找到这些类,我怀疑这是关于插件类的。 So I removed them all and reisntalled them, now it's working. 所以我将它们全部删除并重新安排它们,现在它正在工作。

Remove all plugins and reinstall them 删除所有插件并重新安装

phonegap plugin list

[phonegap] org.apache.cordova.camera
[phonegap] org.apache.cordova.console 
[phonegap] org.apache.cordova.device
[phonegap] org.apache.cordova.device-motion
[phonegap] org.apache.cordova.device-orientation
[phonegap] org.apache.cordova.dialogs 
[phonegap] org.apache.cordova.file 
[phonegap] org.apache.cordova.file-transfer 
[phonegap] org.apache.cordova.geolocation 
[phonegap] org.apache.cordova.inappbrowser    
[phonegap] org.apache.cordova.media 
[phonegap] org.apache.cordova.media-capture
[phonegap] org.apache.cordova.network-information
[phonegap] org.apache.cordova.splashscreen

phonegap plugin help

for all installs I did this (I couldnot find a * to deinstall them all at once) 对于所有安装,我做了这个(我找不到一个*来立即卸载它们)

phonegap plugin remove org.apache.cordova.device

and after that I reinstalled them, so for all plugins: 然后我重新安装它们,所以对于所有插件:

phonegap plugin add org.apache.cordova.device

This did the trick for me.... 这对我有用了....

Edit 编辑

By the way, a few days later I found out that in case you run things in eclipse. 顺便说一句,几天后我发现,如果你在日食中运行东西。 You should add 2 projects. 你应该添加2个项目。 One of the complete project (as a general project, not android). 一个完整的项目(作为一般项目,而不是android)。 There you can edit the code in the blue print WWW folder. 在那里,您可以编辑蓝图WWW文件夹中的代码。 And after editing, you run the cli (command line interface) command: 'cordova build' and than you can run it from the second project (you add the platforms/android folder as a android project, using add from existing code). 在编辑之后,你运行cli(命令行界面)命令:'cordova build',然后你可以从第二个项目运行它(你将平台/ android文件夹添加为android项目,使用现有代码添加)。

By the way, after having resolved this issue... I tried whether a complete new checkout for my phonegap project works in a complete new and fresh folder. 顺便说一下,在解决了这个问题之后...我试着为我的phonegap项目完成一个全新的结账工作是否在一个全新的新文件夹中工作。

And therfore I used a little bash file that did this: (to run after the git clone command in the folder you just cloned): 因此我使用了一个执行此操作的小bash文件:(在刚刚克隆的文件夹中运行git clone命令后):

  • unistall all plugins... (I copied the output of list and add phonegap plugin remove) unistall所有插件...(我复制了列表的输出并添加了phonegap插件删除)
  • install all plugins ... 安装所有插件......
  • phonegap run android phonegap运行android

and frustrated got the same message again.... 和沮丧再次得到相同的消息....

than I found a blog of one of the phonegap hero's: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ 我找到了一个关于一个手机英雄的博客: http ://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/

And one remark especially: he created a hook for installing the plugins... but the hook is: 特别要说一句:他创建了一个用于安装插件的钩子......但钩子是:

after_platform_add` after_platform_add`

which means my order was wrong.... after the checkout, no platform is added, this is done in: 这意味着我的订单错了....结帐后,没有添加任何平台,这是在:

phonegap run android after 

So installing the plugins before the platform is added... seems not to work! 所以在添加平台之前安装插件......似乎不起作用!

I inserted a command to build (which also adds the platform) before installing the plugin in my bash file, and now it works. 在我的bash文件中安装插件之前,我插入了一个构建命令(也添加了平台),现在它可以工作了。

but even better: use the hook suggested by Holly Schinsky in the link above... this works for all platforms, and not just on ubuntu (my bash file). 但更好的是:在上面的链接中使用Holly Schinsky建议的钩子......这适用于所有平台,而不仅仅适用于ubuntu(我的bash文件)。

Well this page seems to explain it (I could only get to this answer by eclipse, the commandline interface (CLI) did never give me any warnings. 那么这个页面似乎解释了它(我只能通过eclipse得到这个答案,命令行界面(CLI)从来没有给我任何警告。

this error: 这个错误:

Could not find cordova.js script tag. Plugin loading may fail

lead me to: 引导我:

https://github.com/phonegap/phonegap-cli/issues/134 https://github.com/phonegap/phonegap-cli/issues/134

and now it seems you have to change the code generated by phonegap create!! 现在看来你必须改变phonegap创建的代码!!

<!-- <script type="text/javascript" src="phonegap.js"></script> -->
<script type="text/javascript" src="cordova.js"></script>

However... this does not help me, still the same error. 但是......这对我没有帮助,仍然是同样的错误。

So I changed it back in to: 所以我把它改回来:

<script type="text/javascript" src="phonegap.js"></script>

I leave this answer, because for others this seemed to have worked (?) 我留下这个答案,因为对于其他人来说这似乎有用(?)

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

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