Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

android - Cordova "hello world" app won't display

I am new to Apache Cordova and I can't get the Cordova "hello world" application to display on Android. I'm talking about the default application obtained from the "cordova create" command from the CLI.

I read the documentation and installed everything as required (Node.js, npm, Cordova 5.0.0, I already had an Android SDK so i just needed to update the PATH).

Cordova tells me the build is a success.

It then says the application is launched, but the only thing that changes on device/emulator screen is that a menu is opened (like on the following picture): http://i.stack.imgur.com/F7bI2.jpg

I tried on an emulator and on a real device, results are the same.

I checked the API version and it seems to be high enough (4.0.3). I'm under Windows 7, with an Oracle JDK. I thought maybe a plugin was missing and installed cordova-plugin-device, but it did change nothing.

Is this a bug or do I miss something? Is there some mean to get an error report (nothing unusual appears with the "cordova run android" command)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I finally got it figured.

Problem seemed to be that the apk was not properly installed. The application was in fact able to run when i installed it with the following command (as recommanded by jojo in cordova run android executes fine. But Android 4.1.2 doesn't start the app): adb install <path_to_apk>

So I checked Cordova code to see what happens when apk is installed, and manually launched the command Cordova is using:

adb -s ' + resolvedTarget.target + ' install -r -d "' + apk_path + '"

It returns: "Error: unknown option -d"!

If you simply delete the "-d" option, applications run normally with cordova run android. On Cordova 5.0.0 you will find this commande at line 101 of file platformsandroidcordovalibdevice.js (and at line 311 of platformsandroidcordovalibemulator.js for cordova emulate android).

I don't know what this "-d" option is meant too... Is this a Cordova bug?

EDIT

As joris says in comment :

The -d is supposed to come directly after adb (as in --device) instead of after install. So you can just move it there instead of removing it.

Plus, here is the opened issue on apache cordova issue tracker


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...