diff --git a/tests/CoreTests/android/core/HeapTest.java b/tests/CoreTests/android/core/HeapTest.java
index 98cb28a..400d041 100644
--- a/tests/CoreTests/android/core/HeapTest.java
+++ b/tests/CoreTests/android/core/HeapTest.java
@@ -46,73 +46,6 @@
         return new WeakReference<Object>(new Object());
     }
 
-    /**
-     * Allocates the specified number of bytes. This is done in a separate method
-     * to ensure that the Object's address isn't sitting in a stale local register.
-     */
-    private void allocateMemory(int size) {
-        byte[] b = new byte[size];
-    }
-
-    @MediumTest
-    public void testMinimumHeapSize() throws Exception {
-        VMRuntime r = VMRuntime.getRuntime();
-        final boolean RUN_FLAKY = false;
-
-        long origSize = r.getMinimumHeapSize();
-        if (RUN_FLAKY) {
-            /* Check that the default value is zero.  This will break if anyone
-             * in this process sets the minimum heap size to a positive value
-             * before calling this test.
-             */
-            assertTrue(origSize == 0);
-        }
-
-        long size = 4 * 1024 * 1024;
-        long oldSize = r.setMinimumHeapSize(size);
-        assertTrue(oldSize == origSize);
-
-        long newSize = r.getMinimumHeapSize();
-        /* This will fail if the maximum heap size (-Xmx) is smaller than 4MB.
-         */
-        assertTrue(newSize == size);
-
-        /* Make sure that getting the size doesn't change anything.
-         */
-        newSize = r.getMinimumHeapSize();
-        assertTrue(newSize == size);
-
-        /* This test is flaky; if the heap is already large and fragmented,
-         * it can fail.  It can also fail if another thread causes a GC
-         * at the wrong time.
-         */
-        if (RUN_FLAKY) {
-            /* Increase the minimum size, allocate a big object, and make sure that
-             * a GC didn't happen.
-             */
-            WeakReference ref = newRef();
-            assertNotNull(ref.get());
-
-            r.setMinimumHeapSize(8 * 1024 * 1024);
-            allocateMemory(4 * 1024 * 1024);
-
-            /* If a GC happened, this reference will be null.
-             */
-            assertNotNull(ref.get());
-        }
-
-        /* Restore the original setting.
-         */
-        r.setMinimumHeapSize(origSize);
-        newSize = r.getMinimumHeapSize();
-        assertTrue(newSize == origSize);
-
-        /* Clean up any large stuff we've allocated,
-         * and re-establish the normal utilization ratio.
-         */
-        Runtime.getRuntime().gc();
-    }
-
     private static void makeRefs(Object objects[], SoftReference<Object> refs[]) {
         for (int i = 0; i < objects.length; i++) {
             objects[i] = (Object) new byte[8 * 1024];
