当前位置: 首页 > 知识库问答 >
问题:

Phonegap运行Android给出错误

夏谦
2023-03-14

我正在尝试运行基本的hello-world应用程序。我完全沮丧,找不到解决这个问题的办法。怎么了?我已经尝试了这些解决方案,但仍然没有运气。请帮助我:'(


    C:\apps>phonegap create app3
    [phonegap] create called with the options C:\apps\app3 com.phonegap.helloworld HelloWorld
    [phonegap] Customizing default config.xml file
    [phonegap] created project at C:\apps\app3

    C:\apps>cd app3

    C:\apps\app3>phonegap local run android
    [phonegap] adding the Android platform...
    Creating Cordova project for the Android platform:
            Path: platforms\android
            Package: com.phonegap.helloworld
            Name: HelloWorld
            Android target: android-19
    Copying template files...
    Running: android update project --subprojects --path "platforms\android" --target android-19 --library "CordovaLib"
    Resolved location of library project to: C:\apps\app3\platforms\android\CordovaLib
    Updated and renamed default.properties to project.properties
    Updated local.properties
    No project name specified, using Activity name 'HelloWorld'.
    If you wish to change it, edit the first line of build.xml.
    Added file C:\apps\app3\platforms\android\build.xml
    Added file C:\apps\app3\platforms\android\proguard-project.txt
    Updated project.properties
    Updated local.properties
    No project name specified, using project folder name 'CordovaLib'.
    If you wish to change it, edit the first line of build.xml.
    Added file C:\apps\app3\platforms\android\CordovaLib\build.xml
    Added file C:\apps\app3\platforms\android\CordovaLib\proguard-project.txt

    Project successfully created.
    cp: no such file or directory: C:\apps\app3\icon.png

    cp: no such file or directory: C:\apps\app3\res\icon\ios\icon-72.png

    [phonegap] compiling Android...
    cp: no such file or directory: C:\apps\app3\icon.png

    cp: no such file or directory: C:\apps\app3\res\icon\ios\icon-72.png

    Buildfile: C:\apps\app3\platforms\android\build.xml
      [taskdef] Could not load definitions from resource emma_ant.properties. It could not be found.

    -set-mode-check:

    -set-debug-files:

    -check-env:
     [checkenv] Android SDK Tools Revision 23.0.0
     [checkenv] Installed at F:\Android\SDK-for-kepler\sdk

    -setup:
         [echo] Project Name: HelloWorld
      [gettype] Project Type: Application

    -set-debug-mode:

    -debug-obfuscation-check:

    -pre-build:

    -build-setup:
    [getbuildtools] Using latest Build Tools: 19.1.0
         [echo] Resolving Build Target for HelloWorld...
    [gettarget] Project Target:   Android 4.4.2
    [gettarget] API level:        19
         [echo] ----------
         [echo] Creating output directories if needed...
        [mkdir] Created dir: C:\apps\app3\platforms\android\ant-build
        [mkdir] Created dir: C:\apps\app3\platforms\android\ant-build\res
        [mkdir] Created dir: C:\apps\app3\platforms\android\ant-build\rsObj
        [mkdir] Created dir: C:\apps\app3\platforms\android\ant-build\rsLibs
        [mkdir] Created dir: C:\apps\app3\platforms\android\ant-gen
        [mkdir] Created dir: C:\apps\app3\platforms\android\ant-build\classes
        [mkdir] Created dir: C:\apps\app3\platforms\android\ant-build\dexedLibs
         [echo] ----------
         [echo] Resolving Dependencies for HelloWorld...
    [dependency] Library dependencies:
    [dependency]
    [dependency] ------------------
    [dependency] Ordered libraries:
    [dependency]
    [dependency] ------------------
         [echo] ----------
         [echo] Building Libraries with 'debug'...
      [taskdef] Could not load definitions from resource emma_ant.properties. It could not be found.

    nodeps:

    -set-mode-check:

    -set-debug-files:

    -check-env:
     [checkenv] Android SDK Tools Revision 23.0.0
     [checkenv] Installed at F:\Android\SDK-for-kepler\sdk

    -setup:
         [echo] Project Name: CordovaLib
      [gettype] Project Type: Android Library

    -set-debug-mode:

    -debug-obfuscation-check:

    -pre-build:

    -build-setup:
    [getbuildtools] Using latest Build Tools: 19.1.0
         [echo] Resolving Build Target for CordovaLib...
    [gettarget] Project Target:   Android 4.4.2
    [gettarget] API level:        19
         [echo] ----------
         [echo] Creating output directories if needed...
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\res
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\libs
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\ant-build
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\ant-build\res
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\ant-build\rsObj
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\ant-build\rsLibs
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\ant-gen
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\ant-build\classes
        [mkdir] Created dir: C:\apps\app3\platforms\android\CordovaLib\ant-build\dexedLibs
         [echo] ----------
         [echo] Resolving Dependencies for CordovaLib...
    [dependency] Library dependencies:
    [dependency] No Libraries
    [dependency]
    [dependency] ------------------

    -code-gen:
    [mergemanifest] Merging AndroidManifest files into one.
    [mergemanifest] Manifest merger disabled. Using project manifest only.
         [echo] Handling aidl files...
         [aidl] No AIDL files to compile.
         [echo] ----------
         [echo] Handling RenderScript files...
         [echo] ----------
         [echo] Handling Resources...
         [aapt] Generating resource IDs...
         [echo] ----------
         [echo] Handling BuildConfig class...
    [buildconfig] Generating BuildConfig class.

    -pre-compile:

    -compile:
        [javac] Compiling 90 source files to C:\apps\app3\platforms\android\CordovaLib\ant-build\classes
        [javac] Note: Some input files use or override a deprecated API.
        [javac] Note: Recompile with -Xlint:deprecation for details.
         [echo] Creating library output jar file...
          [jar] Building jar: C:\apps\app3\platforms\android\CordovaLib\ant-build\classes.jar

    -post-compile:

    -obfuscate:

    -dex:
         [echo] Library project: do not convert bytecode...

    -crunch:
       [crunch] Crunching PNG Files in source dir: C:\apps\app3\platforms\android\CordovaLib\res
       [crunch] To destination dir: C:\apps\app3\platforms\android\CordovaLib\ant-build\res
       [crunch] Crunched 0 PNG files to update cache

    -package-resources:
         [echo] Library project: do not package resources...

    -package:
         [echo] Library project: do not package apk...

    -post-package:

    -do-debug:
         [echo] Library project: do not create apk...
    [propertyfile] Creating new property file: C:\apps\app3\platforms\android\CordovaLib\ant-build\build.prop
    [propertyfile] Updating property file: C:\apps\app3\platforms\android\CordovaLib\ant-build\build.prop
    [propertyfile] Updating property file: C:\apps\app3\platforms\android\CordovaLib\ant-build\build.prop
    [propertyfile] Updating property file: C:\apps\app3\platforms\android\CordovaLib\ant-build\build.prop

    -post-build:

    debug:

    -code-gen:
    [mergemanifest] Merging AndroidManifest files into one.
    [mergemanifest] Manifest merger disabled. Using project manifest only.
         [echo] Handling aidl files...
         [aidl] No AIDL files to compile.
         [echo] ----------
         [echo] Handling RenderScript files...
         [echo] ----------
         [echo] Handling Resources...
         [aapt] Generating resource IDs...
         [echo] ----------
         [echo] Handling BuildConfig class...
    [buildconfig] Generating BuildConfig class.

    -pre-compile:
         [echo] Set jars path to: C:\apps\app3\platforms\android\CordovaLib\ant-build\classes.jar

    -compile:
        [javac] Compiling 3 source files to C:\apps\app3\platforms\android\ant-build\classes

    -post-compile:

    -obfuscate:

    -dex:
          [dex] input: C:\apps\app3\platforms\android\ant-build\classes
          [dex] input: C:\apps\app3\platforms\android\CordovaLib\ant-build\classes.jar
          [dex] Pre-Dexing C:\apps\app3\platforms\android\CordovaLib\ant-build\classes.jar -> classes-b6d5849ba546b3720c0e46effd6702fc.jar
           [dx] Error occurred during initialization of VM
           [dx] Could not reserve enough space for object heap
           [dx] Could not create the Java virtual machine.

    BUILD FAILED
    F:\Android\SDK-for-kepler\sdk\tools\ant\build.xml:892: The following error occurred while executing this line:
    F:\Android\SDK-for-kepler\sdk\tools\ant\build.xml:894: The following error occurred while executing this line:
    F:\Android\SDK-for-kepler\sdk\tools\ant\build.xml:906: The following error occurred while executing this line:
    F:\Android\SDK-for-kepler\sdk\tools\ant\build.xml:283: null returned: 1

    Total time: 4 seconds
    Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\apps\app3\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
    { [Error: C:\apps\app3\platforms\android\cordova\build.bat: Command failed with exit code 2] code: 2 }
       [error] C:\apps\app3\platforms\android\cordova\build.bat: Command failed with exit code 2

共有3个答案

胡劲
2023-03-14

您的 logcat 输出清楚地表明,由于 sdk 工具问题,应用程序构建失败。在环境变量中添加 sdk 工具的路径,就像这样 yourpath\sdk\platform-tools\;'您的路径'\sdk\tools\。确保以这种方式添加路径转到高级设置-

毛胜
2023-03-14

看了你的日志后,似乎是java堆内存问题..查看此问题以获得更多帮助..它建议使用64位JDK。

此链接也可能对您有所帮助。

爱博达
2023-03-14

这对我很管用

转到开始-

变量名:_JAVA_OPTIONS

变量值:-Xmx512M

取自此链接

 类似资料:
  • 'tools.jar'不在Android Studio类路径中。请确保JAVA_HOME指向JDK而不是JRE 这里有人能帮我吗?

  • 当我尝试在Netbeans中运行Tomcat时,我得到: 部署错误:Tomcat启动失败,/users/dropbox/apache-tomcat-8.0.23/bin/catalina.sh和相关脚本可执行。 catalina.sh位于该文件位置。我不知道如何检查它是否可执行。我之前在工作,然后它停止工作,但我不确定什么时候或我改变了什么。

  • 当我启动Android Studio时,我遇到此错误: 当我单击“重试”时,会出现相同的错误:

  • 我正在执行命令“cordova build”(完成以上设置后,举例说明了此链接Phonegap的命令行界面)。 但note.js返回以下错误: 从“android”平台的默认值生成config.xml 准备android项目 通过命令“cmd”/C C:\net\phoneGap\hello\platforms\android\cordova\BUILD 错误:生成android项目时出错。执行“

  • 单击此处查看错误图像 我有这个错误,当我运行反应本机run-android在我的设备上,我怎么能修复它? 我运行这个: react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --