2012-04-18 115 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 - 我可以只複製到設備上並運行它。