【问题标题】:phonegap simple example does not work in android emulatorphonegap 简单示例在 android 模拟器中不起作用
【发布时间】:2013-09-06 00:18:56
【问题描述】:

我按照基本 Phonegap 教程(Eclipse、Android SDK、ADT Phonegap)中的所有步骤,创建了一个 index.html 页面(来自 phonegap 站点的代码)和 assets/www 文件夹中的 cordova-2.2.0.jscordova-2.2.0.jar ,当我运行它时,它在控制台屏幕上显示了这条消息:

[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!

但该应用程序不起作用,我没有找到我的应用程序 lancher 图标!你能帮帮我吗!

编辑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;
    }

}

【问题讨论】:

  • “不起作用”是什么意思?有没有黑屏之类的?应用坏了?请说明。
  • 没有黑屏,也没有应用中断!模拟器启动了,什么也没发生
  • 您可以发布您的活动吗? (我猜你只有一个,对吧?)
  • 是的,我只有一个。看看 myMainActicity.java 我在我的问题中添加了它!

标签: android cordova


【解决方案1】:

我知道您的index.html 已放在assets 文件夹中,但请尝试将 super.loadUrl 行更改为:

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

按照本教程PhoneGap Documentation - Getting Started with Android

【讨论】:

    【解决方案2】:

    您必须继续尝试,直到您的控制台显示“正在安装”,其中一种可能是运行一个模拟器,然后如果没有任何反应,请保持打开状态并使用第二个模拟器开始另一次运行,有时这可以解决问题。总体而言,adt 模拟器很烂,我的建议是买一部便宜的安卓手机。

    【讨论】:

      【解决方案3】:
      1. 您查看的是正确的 AVD - 吗?

      2. 你能检查一下项目是否有任何问题。检查“问题”视图

        窗口->显示视图->问题或窗口->显示视图->其他->问题

      3. 尝试修复android属性:右键项目->Android工具->修复项目属性

      通过清理项目意味着选择 脚步: 1.选择菜单项目->清理 2.构建项目:项目->构建

      【讨论】:

      • 我做到了。当我在模拟器上启动应用程序时,仍然有这条红色消息:[2013-09-05 16:34:27 - phonegape-test] 找不到启动器活动! [2013-09-05 16:34:27 - phonegape-test] 启动只会同步设备上的应用包!
      【解决方案4】:

      有时应用程序图标不会显示在模拟器中。您可以尝试以下选项之一:

      1. 打开模拟器,尝试在同一个模拟器中再次启动应用程序。

      2. 清理所有项目,并尝试擦除模拟器中的所有数据(选项应该在 AVD 管理器中),然后构建您需要测试的唯一项目。应用程序图标应该在模拟器中。

      3. 模拟器配置低。没有高端模拟器配置。我的读取为 500 MB RAM 和 64 VM 堆。内部存储应该是 200。在英特尔处理器上运行它以获得最新的 Android 版本,而不是 ARM 处理器。如果您尚未在 Bios 中启用虚拟化,您将在控制台中收到 Hex 错误。但是,不要为此烦恼。如果您仍然觉得需要了解,可以查看之前已回答的问题。

      如果可行,请告诉我。我遇到了问题,上述解决方案之一肯定可以解决它!

      谢谢!

      【讨论】:

      • 感谢回复,第一种解决方法不行。第二次我关闭了所有其他项目,但它不起作用!我不明白“清理所有项目”是什么意思
      • 在 Eclipse 中取消选中 Project 菜单中的 Build Automatically 选项。然后选择,项目-> 清理项目,在出现的窗口中,只选择要清理的项目并构建选定的项目。但是,在此之后或之前,请注意擦除模拟器中的所有用户数据,或者最好启动一个新的设备模拟器,然后尝试在该模拟器中执行您的项目。
      • @nomade 添加了第三个选项...您也可以检查一下吗...?
      • 还有一件事,您遵循哪个教程来创建 index.html..?那里有两个教程,一个通过 phonegap 站点中提到的命令行,另一个通过 adobe 站点。如果您遵循了命令行过程并且除了修改 index.html 之外没有进行任何操作,您不必担心。如果你确实按照adobe网站的方法,它太长了,可能会导致一些问题..
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多