2012-04-18 116 views
2

这是我在这个非常有用的网站上的第一篇文章!无法在Netbeans上编译Android hello world

经过30分钟的谷歌搜索和发现非常有用的自动搜索功能,当你输入你的问题的名字,我想是时候我终于做了一个帐户,并问!

好吧,这是我第一次得到我的手脏,我看到一个错误直打在我的脸上,在形式:

我明白了一些编码概念,但是我仍然是非常新的,我想知道是什么导致这种情况发生在这个网站的有帮助的人,谢谢!

clean: 
Deleting directory C:\Users\User\Documents\NetBeansProjects\AndroidApplication1\bin 
Deleting directory C:\Users\User\Documents\NetBeansProjects\AndroidApplication1\gen 
Creating output directories if needed... 
Created dir: C:\Users\User\Documents\NetBeansProjects\AndroidApplication1\bin 
Created dir: C:\Users\User\Documents\NetBeansProjects\AndroidApplication1\bin\res 
Gathering info for AndroidApplication1... 
Android SDK Tools Revision 19 
Project Target: Google APIs 
Vendor: Google Inc. 
Platform Version: 2.3.3 
API level: 10 
------------------ 
Resolving library dependencies: 
No library dependencies. 

------------------ 
API<=15: Adding annotations.jar to the classpath. 

------------------ 
WARNING: No minSdkVersion value set. Application will install on all Android versions. 
Created dir: C:\Users\User\Documents\NetBeansProjects\AndroidApplication1\gen 
Created dir: C:\Users\User\Documents\NetBeansProjects\AndroidApplication1\bin\classes 
---------- 
Handling aidl files... 
No AIDL files to compile. 
---------- 
Handling RenderScript files... 
No RenderScript files to compile. 
---------- 
Handling Resources... 
Generating resource IDs... 
---------- 
Handling BuildConfig class... 
Generating BuildConfig class. 
Compiling 3 source files to C:\Users\User\Documents\NetBeansProjects\AndroidApplication1\bin\classes 
Converting compiled files and external libraries into C:\Users\User\Documents\NetBeansProjects\AndroidApplication1\bin\classes.dex... 
Error: Could not create the Java Virtual Machine. 
Error: A fatal exception has occurred. Program will exit. 
Error occurred during initialization of VM 
Could not reserve enough space for object heap 
C:\Program Files\Android\android-sdk\tools\ant\build.xml:818: The following error occurred while executing this line: 
C:\Program Files\Android\android-sdk\tools\ant\build.xml:820: The following error occurred while executing this line: 
C:\Program Files\Android\android-sdk\tools\ant\build.xml:832: The following error occurred while executing this line: 
C:\Program Files\Android\android-sdk\tools\ant\build.xml:278: null returned: 1 
BUILD FAILED (total time: 3 seconds) 

在哪里上发生的错误行:

C:\ Program Files文件\的Android \ Android的SDK \工具\蚂蚁\ build.xml文件

<!-- Converts this project's .class files into .dex files --> 
    <target name="-dex" depends="-compile, -post-compile, -obfuscate"> 
818  <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping..."> 
      <!-- only convert to dalvik bytecode is *not* a library --> 
820   <do-only-if-not-library elseText="Library project: do not convert bytecode..." > 
       <!-- special case for instrumented builds: need to use no-locals and need 
        to pass in the emma jar. --> 
       <if condition="${build.is.instrumented}"> 
        <then> 
         <dex-helper nolocals="true"> 
          <external-libs> 
           <fileset file="${emma.dir}/emma_device.jar" /> 
          </external-libs> 
         </dex-helper> 
        </then> 
        <else> 
832      <dex-helper /> 
        </else> 
       </if> 
      </do-only-if-not-library> 
     </do-only-if-manifest-hasCode> 
    </target> 

<!-- Configurable macro, which allows to pass as parameters output directory, 
     output dex filename and external libraries to dex (optional) --> 
    <macrodef name="dex-helper"> 
     <element name="external-libs" optional="yes" /> 
     <attribute name="nolocals" default="false" /> 
     <sequential> 
      <!-- sets the primary input for dex. If a pre-dex task sets it to 
       something else this has no effect --> 
      <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" /> 

      <!-- set the secondary dx input: the project (and library) jar files 
       If a pre-dex task sets it to something else this has no effect --> 
      <if> 
       <condition> 
        <isreference refid="out.dex.jar.input.ref" /> 
       </condition> 
       <else> 
        <path id="out.dex.jar.input.ref"> 
         <path refid="project.libraries.jars" /> 
        </path> 
       </else> 
      </if> 

      <dex executable="${dx}" 
        output="${intermediate.dex.file}" 
        nolocals="@{nolocals}" 
278     verbose="${verbose}"> 
       <path path="${out.dex.input.absolute.dir}"/> 
       <path refid="out.dex.jar.input.ref" /> 
       <external-libs /> 
      </dex> 
     </sequential> 
    </macrodef> 

回答

1

听起来像一个记忆问题?

Error occurred during initialization of VM
Could not reserve enough space for object heap

(EMPH矿)

+0

感谢您的快速响应!我正在运行Windows 7,并且在任务管理器中表示大约使用了12%的CPU,并且使用了1.18GB/2GB的RAM,编译简单的hello世界真的需要那么多的内存吗? – Hobbyist 2012-04-18 10:10:14

+0

我不太确定正常构建的东西是什么,因为我使用默认的Eclipse/SDK组合,但这就是它的样子。这是开始Java虚拟机这是问题顺便说一句,你也可以看到这里:'错误:无法创建Java虚拟机。“ – Nanne 2012-04-18 10:13:27

+0

如果是这样的话,是否有限制脚本只使用一定量的内存? – Hobbyist 2012-04-18 10:42:32

1

嗯,我有完全相同的错误,当我试图运行样品VS-的Android(https://code.google.com/p/vs-android/)应用。

经过大量的mu I后,我实际上并不知道是什么原因造成的,但我肯定找到了解决办法。

显然由于某种原因,JVM无法初始化,因为它觉得系统中没有足够的内存。解决方法是将JVM设置为初始化512MB的堆大小而不是1024MB的默认大小。为了做到这一点,做到以下几点:

Go to Start->Control Panel->System->Advanced->Environment Variables->System Variables->New: 

Variable name: _JAVA_OPTIONS <br> 
Variable value: -Xmx512M 

这解决了这个错误对我来说,虽然我仍然有问题,部署到我的设备,但是这是一个不同的问题,至少它编译并创建了一个APK - 我可以只复制到设备上并运行它。