# Build failed with DuplicateRelativeFileException

**URL:** <https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537>\
**Category:** Processing for Android\
**Created:** [December 21, 2023, 4:54pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537 "2023-12-21T16:54:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bertin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bertin/32/391_2.png) [@bertin](https://discourse.processing.org/u/bertin)\
**Post date:** [December 21, 2023, 4:54pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/1 "2023-12-21T16:54:54Z")

</div>

Hi

I’m trying to build a project in Processing 4 for Android.  
I have several external libraries imported in the “code” folder.

![Immagine 2023-12-21 175010](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/c/3ca1cb23d140428a4238c798bd3fe37a2b091d84.jpeg)

When I’m trying to “run on device” I get the following error:

```auto
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.

Any help?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [December 21, 2023, 5:32pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/2 "2023-12-21T17:32:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bertin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bertin/32/391_2.png) [@bertin](https://discourse.processing.org/u/bertin)\
**Post date:** [December 21, 2023, 6:49pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/3 "2023-12-21T18:49:45Z")

</div>

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…

```auto
----------
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

```

Can you help me out?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [December 21, 2023, 7:04pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/4 "2023-12-21T19:04:36Z")

</div>

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?

```auto
void setup() {
  fullScreen();
  background(209);
  fill(0, 255, 0);
  rect(200,200,400,400);
}

void draw() {  
}

```

---

<div class="post-metadata">

**Author:** ![bertin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bertin/32/391_2.png) [@bertin](https://discourse.processing.org/u/bertin)\
**Post date:** [December 21, 2023, 7:08pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/5 "2023-12-21T19:08:53Z")

</div>

Yes, it installs successfully the app on my phone.

---

<div class="post-metadata">

**Author:** ![bertin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bertin/32/391_2.png) [@bertin](https://discourse.processing.org/u/bertin)\
**Post date:** [December 21, 2023, 7:24pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/6 "2023-12-21T19:24:39Z")

</div>

It looks like that if I comment out this piece of code my app is building

```auto
  circles.add(new Circle(mouseX, mouseY));
  for (Circle c : circles) {
    c.show();
    c.scaleDown();
  }
  circles.removeIf(c -> c.disappear());

```

Do you have any idea why? It seems that it doesn’t like the “removeIf” functional method…

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [December 22, 2023, 3:00am UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/7 "2023-12-22T03:00:45Z")

</div>

Code appears to be referring to a Circles class and` removeIf()` might be one of the methods.

---

<div class="post-metadata">

**Author:** ![bertin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bertin/32/391_2.png) [@bertin](https://discourse.processing.org/u/bertin)\
**Post date:** [December 22, 2023, 9:21am UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/8 "2023-12-22T09:21:15Z")

</div>

No, removeIf is a method of java.util.List, I don’t know with which version was introduced but it seems that Android does not like it.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 22, 2023, 12:16pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/9 "2023-12-22T12:16:41Z")

</div>

> [@bertin](#):
>
> `The type java.lang.invoke.LambdaMetafactory cannot be resolved.`

> [@bertin](#):
>
> It seems that it doesn’t like the “removeIf” functional method…

Maybe somehow it doesn’t like the `->` lambda thin arrow operator syntax from: `c -> c.disappear()`

This is the link for method **removeIf()**:

> **[Collection (Java SE 17 & JDK 17)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html#removeIf(java.util.function.Predicate))**
>
> declaration: module: java.base, package: java.util, interface: Collection

Method [**removeIf()**](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html#removeIf(java.util.function.Predicate)) requires invoking method **test()** from an instance of interface Predicate:

> **[Predicate (Java SE 17 & JDK 17)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/function/Predicate.html#test(T))**
>
> declaration: module: java.base, package: java.util.function, 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:

```java
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);
}

```

---

<div class="post-metadata">

**Author:** ![bertin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bertin/32/391_2.png) [@bertin](https://discourse.processing.org/u/bertin)\
**Post date:** [December 22, 2023, 12:46pm UTC](https://discourse.processing.org/t/build-failed-with-duplicaterelativefileexception/43537/10 "2023-12-22T12:46:31Z")

</div>

Thanks a lot, it’s working this way.

I managed to run the original app even tho I wasn’t able to solve the dependencies problem.

I wanted to read some files from a S3 bucket using the AWS sdk, turns out that you can simply use their rest api with a lot less effort 😃
