Can't build android app with processing

Hello, I'm trying to get Processing 3.3.6 to work with Android Mode 4.0. With the Android SDK 3.0.1, target API level 26/min. If someone could help me get it to work I'd be very happy, but just as well would be if someone knows of a working (preferably recent) combination of Processing, Android Mode and Android SDK that I could work with.

When building I get this error: _"Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. java.lang.IllegalStateException: buildToolsVersion is not specified. ... FAILURE: Build failed with an exception.

  • Where: Build file 'C:\Users\Fredrik\AppData\Local\Temp\android971185864472813018sketch\app\build.gradle' line: 5

  • What went wrong: A problem occurred evaluating project ':app'.

    Invalid revision: android-7.0 ...

BUILD FAILED in 10s org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.0-bin.zip'. ... Caused by: org.gradle.internal.exceptions.LocationAwareException: Build file 'C:\Users\Fredrik\AppData\Local\Temp\android971185864472813018sketch\app\build.gradle' line: 5 A problem occurred evaluating project ':app'. ... Caused by: java.lang.NumberFormatException: Invalid revision: android-7.0 ..."_

What I tried to do: Reading the forums - Found a suggestion to fill in something under "package name" in the manifest file, did so. Changing the gradle file - At this point I noticed that Processing generates a new gradle file every time I try to build, so I have no way of changing the gradle file for use with Processing. Exporting the project to Android Studio - Here I could edit the gradle file, but it gave me some warnings that "this support library should not use a different version than the compiledSDKVersion (26)..." but renaming it didn't help. I also tried a) removing the "buildToolsVersion" since I read it was deprecated, and then changing it to "26.0.2" when I got complaints that there was no buildtool present. There were also some warnings about there being dependencies based on different builds, such as ...vector drawable and what else can be found in the "libs" folder where the processing-core.jar file is located.

This way I got as far as: _"FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex"_

Which I tried to fix with adding: defaultConfig{ ... multiDexEnabled true ...}

dependencies { implementation 'com.android.support:multidex:1.0.2' ...}

This finally gave me the error where I decided it was time to ask for help: "Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

java.io.IOException: Can't write [C:\Users...\Processing\Sketches\MySketch\android\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users....gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.2.aar\d3fd61d402d7b6cb2538ad98c0c186e4\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v7/graphics/drawable/DrawerArrowDrawable.class]))"

At this point I'm not sure what to do and any help would be appreciated!

Answers

  • edited December 2017

    @knorkelberg===

    • working version (probably other, but i use this): p5 3.3, android mode 258 (just before 4.0)

    • you cannot modify the manifest with P5; i have explained (in this forum) that p5 generates it (from a template) and your modifs are useless (which is absolutely stupid in a lot of cases...but....); even uses permissions are automatically added, as package name (that is why it is not precised in the manifest before compiling)

    • all your errors seem a problem of versions but it is impossible to help you without knowing exactly what you are doing;

      in a standard android way: a) you compile with the last version; b) you have a minTarget (now i think it is 17 for P5 but it could be 11 or what you want with AS or Eclipse) c) your version of appcompat must be updated according to your buildTools.

    • Anyway: dont update your SDK with the P5 tools; download and install the SDK yourself

  • Thanks for the suggestion, I'll give that combination a try.

    all your errors seem a problem of versions but it is impossible to help you without knowing exactly what you are doing; In P5 I wasn't doing anything, just trying to build the "Getting started" sample code, which gave me those errors.

    I already had the Android SDK installed so I just pointed to the install location, I could access my device but not build the code.

    Ultimately I'm looking for a (smooher than AS /w Java) way to use OpenCV with Android, so I guess there might be even more compatibility issues ahead of me.

    Thanks again, I'll get back to accept the answer if I can get p5 3.3, android mode 258 to work. PS: Have you tried working with Processing in AS just by importing it? I read that was an option as well but I haven't had the time to test it yet

  • edited December 2017 Answer ✓

    @knorkelberg===

    yes i have tried to use AS with exported apk from P5; it s not so easy but it works: yet, in this case what is the interest to use P5,except that it is a very good graphics library.....

    looking to your answer i think that you have sdk build tools for 7.0 and perhaps that P5 android mode was written (hard coded) for 6...

  • Well as I mentioned the only reason I want to use Processing right now is because I'm desperately looking for a better implementation of OpenCV for Android than the "official" version. I know an "art guy" teacher at school swears by Processing and that it has a focus on graphics and sound so I thought it would be worth a try.

    looking to your answer i think that you have sdk build tools for 7.0 and perhaps that P5 android mode was written (hard coded) for 6... That could be the case, if so I guess I'll try downgrading the SDK for the duration of our project.

    Going to try the NDK way to get OpenCV working with Android first as an alternative, but hopefully I can explore the Processing solution tonight. Thanks a lot for your help and suggestions!

  • Answer ✓

    That could be the case, if so I guess I'll try downgrading the SDK for the duration of our project.

    Using a previous Android Mode version might also require to use a strict SDK version. This is related to the ant tools, which were removed in recent Android SDK releases but it is used by previous Android Mode. This post discuss it:https://forum.processing.org/two/discussion/comment/97531/#Comment_97531 (Check post on March 30 by Digl)

    I hope this helps,

    Kf

  • Thanks a lot guys, I think I can handle it from here on!

Sign In or Register to comment.