We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everybody, I'm just trying to develope my first app for Android. Everything went well with installing the SDK, Android Mode and whatever is needed for it and I was able to launch some code on my smartphone as well as on the emulator. The problem now is that processing produces unreasonable (but not random) errors while launching most of the code I try.
For example the following code works perfect:
void setup() {
}
void draw() {
}
But as soon as I'm inserting background in either void setup or void draw it does not work anymore:
void setup() {
background(255);
}
void draw() {
}
When I'm running an android example (basics/arrays/array) it works, too:
size(200, 200);
float[] coswave = new float[width];
for (int i = 0; i < width; i++) {
float amount = map(i, 0, width, 0, PI);
coswave[i] = abs(cos(amount));
}
for (int i = 0; i < width; i++) {
stroke(coswave[i]*255);
line(i, 0, i, height/3);
}
for (int i = 0; i < width; i++) {
stroke(coswave[i]*255 / 4);
line(i, height/3, i, height/3*2);
}
for (int i = 0; i < width; i++) {
stroke(255 - coswave[i]*255);
line(i, height/3*2, i, height);
}
If I'm deleting the last three for-loops, again it does not work anymore:
size(200, 200);
float[] coswave = new float[width];
for (int i = 0; i < width; i++) {
float amount = map(i, 0, width, 0, PI);
coswave[i] = abs(cos(amount));
}
I could add some more examples, but I think you have an idea about what the problem is. I could not figure out any similarities of the sketches that can not be built.
Here is what processing prints to the console in case there is an error:
-set-mode-check:
-set-debug-files:
-check-env: Android SDK Tools Revision 22.6.3 Installed at C:...\adt-bundle-windows-x86_64-20131030\sdk
-setup: [echo] Project Name: MyApp 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 MyApp... Project Target: Android 2.3.3 API level: 10 [echo] ---------- [echo] Creating output directories if needed... [mkdir] Created dir: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\bin [mkdir] Created dir: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\bin\res [mkdir] Created dir: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\bin\rsObj [mkdir] Created dir: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\bin\rsLibs [mkdir] Created dir: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\gen [mkdir] Created dir: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\bin\classes [mkdir] Created dir: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\bin\dexedLibs [echo] ---------- [echo] Resolving Dependencies for MyApp... 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...\AppData\Local\Temp\android2300145285763385032sketch\bin\classes
-post-compile:
-obfuscate:
-dex: input: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\bin\classes input: C:\Users...\adt-bundle-windows-x86_64-20131030\sdk\tools\support\annotations.jar input: C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\libs\processing-core.jar Pre-Dexing C:\Users...\adt-bundle-windows-x86_64-20131030\sdk\tools\support\annotations.jar -> annotations-dca3254a5a73dfa993a3758a8ce31074.jar Pre-Dexing C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\libs\processing-core.jar -> processing-core-9d3ed85be292f6e506e8029a6af47fb0.jar Converting compiled files and external libraries into C:\Users...\AppData\Local\Temp\android2300145285763385032sketch\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...\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:892: The following error occurred while executing this line:
C:\Users...\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:894: The following error occurred while executing this line:
C:\Users...\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:906: The following error occurred while executing this line:
C:\Users...\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:284: null returned: 2
Total time: 9 seconds
Any help would be greatly appreciated :)
Answers
I was able to answer the question myself meanwhile, couldn't find any information about my problem yesterday with the search on this site, but now I was directly sent to this thread by the google search:
forum.processing.org/two/discussion/982/error-from-inside-the-android-tools/p1
It worked for me to delete Android SDK Build-Tools 19 and installing Build-Tools 18.1.