android - 无法在 Netbeans 上编译 Android hello world

标签 android netbeans

这是我在这个非常有用的网站上发表的第一篇文章!

经过 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\tools\ant\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>

最佳答案

听起来像是内存问题?

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

(emph我的)

关于android - 无法在 Netbeans 上编译 Android hello world,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10207124/

相关文章:

android - RegisterForContextMenu ImageView?

java - 如何在 Android 中通过 Java 调整文本大小

Java 泛型异常

java - 无法安装 NetBeans,安装程序锁定文件存在

netbeans - 如何在 OS X 上的 JDK7+ 上启用子像素提示

android - 如何重用可绘制对象

android - 如何在 Flutter 中禁用发布版本中的所有日志 [debugPrint()]?

mysql - Tomcat Netbeans 数据源无效 : "java. sql.SQLException:找不到适合 jdbc 的驱动程序

android - 如何阻止相同的广播(来自 PendingIntent)排队?

java - 此代码无法检查 NoResultException