I’m trying to build a project in Processing 4 for Android.
I have several external libraries imported in the “code” folder.
When I’m trying to “run on device” I get the following error:
Caused by: com.android.builder.merge.DuplicateRelativeFileException: 2 files found with path 'META-INF/DEPENDENCIES' from inputs:
- <...>\.gradle\caches\transforms-3\2100baa4ac202129e0bd3470a03a9a7f\transformed\jetified-httpclient-4.5.14.jar
- <...>\.gradle\caches\transforms-3\e0eeb34acea5e11adc1c9c4721bb34e8\transformed\jetified-httpcore-4.4.16.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
Program in Java mode works fine.
As my understanding there is some conflict between those 2 jar files when it tries to build the android project.
Browsing on google the solution seems to edit some build.gradle file that I do not have in my sketch folder.
Have you tried building it in Android Studio? That should give you access to the gradle file. Supposedly Processing now uses the gradle build system, but I do not know where to access the file. Perhaps someone else knows.
Thanks for your answer.
I tried to get rid of all the dependencies and building a simple android project, but it’s still failing, I can’t understand what’s going on…
----------
1. ERROR in <...>\AppData\Local\Temp\android2230805254397342470sketch\app\src\main\java\processing\test\plf2\PLF2.java (at line 1)
package processing.test.plf2;
^
The type java.lang.invoke.LambdaMetafactory cannot be resolved. It is indirectly referenced from required .class files
----------
1 problem (1 error)
> Task :app:desugarDebugFileDependencies
FAILURE: Build failed with an exception.
* Where:
Build file '<...>\AppData\Local\Temp\android2230805254397342470sketch\app\build.gradle' line: 86
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Process 'command 'C:\Program Files\processing-4.3\java\bin\java.exe'' finished with non-zero exit value -1
You should be able to run a simple demo. It looks like you have a Windows OS. Don’t give up; we will do our best to help you. We can start with something simple and then try to get your project to run. For example, can you run the following code on an Android device?
Maybe somehow it doesn’t like the -> lambda thin arrow operator syntax from: c -> c.disappear()
This is the link for method removeIf():
Method removeIf() requires invoking method test() from an instance of interface Predicate:
Given we still don’t have access to your full code, I’ve made a minimal workaround example for what you’d posted so far:
import java.util.List;
import java.util.function.Predicate;
class Circle {
int x, y;
Circle(final int mx, final int my) {
x = mx;
y = my;
}
void show() {}
void scaleDown() {}
boolean disappear() {
return random(2) < 1;
}
}
static final Predicate<Circle> FOR_REMOVAL = new Predicate<Circle>() {
@Override boolean test(final Circle c) {
return c.disappear();
}
};
final List<Circle> circles = new ArrayList<Circle>();
void draw() {
circles.add(new Circle(mouseX, mouseY));
for (final Circle c : circles) {
c.show();
c.scaleDown();
}
//circles.removeIf(c -> c.disappear());
circles.removeIf(FOR_REMOVAL);
}