2

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

经过 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>
4

2 回答 2

1

听起来像是内存问题?

VM 初始化期间发生错误
无法为对象堆保留足够的空间

(我的)

于 2012-04-18T10:07:03.300 回答
1

好吧,当我尝试运行示例 vs-android ( https://code.google.com/p/vs-android/ ) 应用程序时,我遇到了完全相同的错误。

经过大量的捣乱后,我实际上并不知道是什么原因造成的,但我确实找到了解决方法。

显然由于某种原因,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 - 我可以将其复制到设备上并运行它。

于 2013-09-15T10:22:54.557 回答