UNEXPECTED TOP-LEVEL EXCEPTION

edited November 2013 in Android Mode

Hi. I'm developing with Arduino and Processing seems to be interestingly similar IDE to create control to it by using Android. So I downloaded and installed both "adt-bundle-windows-x86_64-20131030" and "processing-2.1-windows64" and set all needed environment variables in my win7-64. When I try to compile an empty sketch, it compiles and installs it into the Android tablet and starts, obviously showing nothing. But no errors.

When I try the same with very simple example code (rectangles), I will get an error "Error from inside the Android tools". The console output can be found below. It shows "null returned" in the end and refers to ant\build.xml. Before those lines there is a "[dx] UNEXPECTED TOP-LEVEL EXCEPTION: [dx] java.nio.BufferOverflowException".

What would you propose I should check to get rid of this? (BTW, the error is the same if I use emulator or device). Thanks for help!!

-set-mode-check:

-set-debug-files:

-check-env:
Android SDK Tools Revision 22.3.0
Installed at C:\Users\Petri\Documents\adt-bundle-windows-x86_64-20131030\sdk

-setup:
     [echo] Project Name: sketch_131117a
Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
Using latest Build Tools: 19.0.0
     [echo] Resolving Build Target for sketch_131117a...
Project Target:   Android 2.3.3
API level:        10
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin
    [mkdir] Created dir: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin\res
    [mkdir] Created dir: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin\rsObj
    [mkdir] Created dir: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin\rsLibs
    [mkdir] Created dir: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\gen
    [mkdir] Created dir: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin\classes
    [mkdir] Created dir: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin\dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for sketch_131117a...
Library dependencies:
No Libraries

------------------
API<=15: Adding annotations.jar to the classpath.
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 3 source files to C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin\classes

-post-compile:

-obfuscate:

-dex:
input: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin\classes
input: C:\Users\Petri\Documents\adt-bundle-windows-x86_64-20131030\sdk\tools\support\annotations.jar
input: C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\libs\processing-core.jar
Pre-Dexing C:\Users\Petri\Documents\adt-bundle-windows-x86_64-20131030\sdk\tools\support\annotations.jar -> annotations-9a1e8c6e311de6e69a34176d0845a001.jar
Pre-Dexing C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\libs\processing-core.jar -> processing-core-f735f1a6e885759798009044d6ce4701.jar
Converting compiled files and external libraries into C:\Users\Petri\AppData\Local\Temp\android892194187442561034sketch\bin\classes.dex...
       [dx] 
       [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
       [dx] java.nio.BufferOverflowException
       [dx]     at java.nio.Buffer.nextPutIndex(Unknown Source)
       [dx]     at java.nio.HeapByteBuffer.putShort(Unknown Source)
       [dx]     at com.android.dex.Dex$Section.writeShort(Dex.java:818)
       [dx]     at com.android.dex.Dex$Section.writeTypeList(Dex.java:870)
       [dx]     at com.android.dx.merge.DexMerger$3.write(DexMerger.java:437)
       [dx]     at com.android.dx.merge.DexMerger$3.write(DexMerger.java:423)
       [dx]     at com.android.dx.merge.DexMerger$IdMerger.mergeUnsorted(DexMerger.java:317)
       [dx]     at com.android.dx.merge.DexMerger.mergeTypeLists(DexMerger.java:423)
       [dx]     at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:163)
       [dx]     at com.android.dx.merge.DexMerger.merge(DexMerger.java:187)
       [dx]     at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
       [dx]     at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
       [dx]     at com.android.dx.command.dexer.Main.run(Main.java:230)
       [dx]     at com.android.dx.command.dexer.Main.main(Main.java:199)
       [dx]     at com.android.dx.command.Main.main(Main.java:103)

BUILD FAILED
C:\Users\Petri\Documents\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:892: The following error occurred while executing this line:
C:\Users\Petri\Documents\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:894: The following error occurred while executing this line:
C:\Users\Petri\Documents\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:906: The following error occurred while executing this line:
C:\Users\Petri\Documents\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:284: null returned: 2

Total time: 20 seconds

Answers

  • edited November 2013

    Just to add more details: if I remove some lines from the code, it goes well. This compiles and starts the emulator:

    void setup() {
      size(480,800);
      noStroke();
    
    }
    
    void draw() {
    
    }
    

    But adding any of those four lines in bold below, causes java.nio.BufferOverflowException:

    void setup() {
      size(480,800);
      noStroke();
      **fill(255);**
      **rectMode(CENTER);**   
    }
    
    void draw() {
    **background(#FF9900);**
      **rect(width/2, height/2, 150, 150);**
    }
    

    Any ideas? Is it some kind of library reference break? Can this buffer be adjusted somehow? Thanks!

  • Answer ✓

    See this post on StackOverflow, looks like the same issue.

  • Thanks calsign. The reason is unclear in all posts, but the solution seems to be to downgrade build tools to version 18 instead of 19. That helped me too.

  • The same post now says you can install the latest version of Android SDK Build-tools. I have just installed 19.0.1 and that fixed the error .

Sign In or Register to comment.