简体   繁体   English

phonegap简单示例在android模拟器中不起作用

[英]phonegap simple example does not work in android emulator

I followed all the steps in the basic Phonegap tutorial (Eclipse, Android SDK, ADT Phonegap), I created an index.html page (code from phonegap site) and cordova-2.2.0.js in the assets/www folder and cordova-2.2.0.jar , when i ran it it showed this message on the consol screen : 我按照基本的Phonegap教程(Eclipse,Android SDK,ADT Phonegap)中的所有步骤,创建了一个index.html页面(来自phonegap站点的代码)和assets/www文件夹中的cordova-2.2.0.jscordova-2.2.0.jar ,当我运行它时,它在consol屏幕上显示此消息:

[2013-09-05 12:44:14 - phonegape-test] ------------------------------
[2013-09-05 12:44:14 - phonegape-test] Android Launch!
[2013-09-05 12:44:14 - phonegape-test] adb is running normally.
[2013-09-05 12:44:14 - phonegape-test] No Launcher activity found!
[2013-09-05 12:44:14 - phonegape-test] The launch will only sync the application package on the device!
[2013-09-05 12:44:14 - phonegape-test] Performing sync
[2013-09-05 12:44:14 - phonegape-test] Automatic Target Mode: launching new emulator with compatible AVD 'STest'
[2013-09-05 12:44:14 - phonegape-test] Launching a new emulator with Virtual Device 'STest'
[2013-09-05 12:44:27 - phonegape-test] New emulator found: emulator-5554
[2013-09-05 12:44:27 - phonegape-test] Waiting for HOME ('android.process.acore') to be launched...
[2013-09-05 12:46:25 - phonegape-test] HOME is up on device 'emulator-5554'
[2013-09-05 12:46:25 - phonegape-test] Uploading phonegape-test.apk onto device 'emulator-5554'
[2013-09-05 12:46:26 - phonegape-test] Installing phonegape-test.apk...
[2013-09-05 12:47:35 - phonegape-test] Success!
[2013-09-05 12:47:35 - phonegape-test] \phonegape-test\bin\phonegape-test.apk installed on device
[2013-09-05 12:47:35 - phonegape-test] Done!

but the application dose not work and i did not found my application lancher icon ! 但应用程序不起作用,我没有找到我的应用程序lancher图标! can u help me please ! 能帮帮我吗!

EDIT : MainActivity.java : 编辑MainActivity.java

package com.example.phonegape;

import android.os.Bundle;
import android.view.Menu;
import org.apache.cordova.*;
//import com.phonegap.DroidGap;

public class MainActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.init();
        super.loadUrl("file:///assets/www/index.html");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

I know your index.html is placed in the assets folder, but try to change the super.loadUrl line to: 我知道你的index.html放在assets文件夹中,但是尝试将super.loadUrl行更改为:

super.loadUrl("file:///android_asset/www/index.html");

As per this tutorial PhoneGap Documentation - Getting Started with Android 根据本教程, PhoneGap文档 - Android入门

you have to keep trying until your console says "installing", one might work is that run one emulator and then if nothing happens, leave that on and start another run with a second emulator, sometimes that does the trick. 你必须继续尝试,直到你的控制台说“安装”,一个可能工作的是运行一个模拟器然后如果没有任何反应,保持开启并开始另一个运行与第二个模拟器,有时这样做。 adt emulator sucks in general though, get a cheap android phone my advice. 虽然adt模拟器很糟糕,但是得到一个便宜的Android手机我的建议。

Sometimes the app icon doesn't show up in the Emulator. 有时,应用程序图标不会显示在模拟器中。 You can try one of the options below: 您可以尝试以下选项之一:

  1. Have the Emulator open, try launching the application again in the same emulator. 打开仿真器,尝试在同一仿真器中再次启动应用程序。

  2. Clean all the projects, and try to wipe all the data in the emulators (option should be there in AVD manager) and then Build the only project which you will require to test. 清理所有项目,并尝试擦除模拟器中的所有数据(选项应该在AVD管理器中),然后构建您需要测试的唯一项目。 The application icon should be there DEFINITELY in the emulator. 应用程序图标应该在模拟器中绝对存在。

  3. Have Emulator configurations low. 让仿真器配置较低。 Don't have high end Emulator Configurations. 没有高端仿真器配置。 Mine read as 500 MB RAM and 64 VM Heap. 我读作500 MB RAM和64 VM堆。 Internal Storage should be 200. Run it on Intel Processor for recent Android versions rather than ARM processors. 内部存储应该是200.在英特尔处理器上运行它,用于最新的Android版本而不是ARM处理器。 You will get Hex error in Console, if you haven't enabled Virtualization in Bios. 如果尚未在Bios中启用虚拟化,则会在控制台中出现Hex错误。 But, don't bother about that. 但是,不要为此烦恼。 You can check previously answered questions reg this, if you still feel you need to know. 如果您仍然觉得需要知道,可以查看之前已回答的问题。

Let me know, if this works. 让我知道这个是否奏效。 I had faced issues and one among the above solutions definitely resolves it! 我遇到过问题,上述解决方案中的一个肯定会解决它!

Thanks! 谢谢!

  1. Are you looking at the correct AVD - ? 你在看正确的AVD吗?

  2. Can you check if there is any problems with the project. 你能检查项目是否有任何问题。 Check the "Problems" view 检查“问题”视图

    Window -> Show View -> Problems or Window -> Show View -> Others-> Problems 窗口 - >显示视图 - >问题或窗口 - >显示视图 - >其他 - >问题

  3. Try to fix the android properties : Right click project -> Android tools -> Fix project properties 尝试修复android属性:右键单击项目 - > Android工具 - >修复项目属性

By cleaning project it means select
Steps:
    1. Select the menu Project->Clean
    2. Build Project: Project -> Build

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

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