Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate package files causing build to fail in Android Studio #378

Open
mlparadiso540 opened this issue Jan 20, 2022 · 8 comments
Open

Comments

@mlparadiso540
Copy link

mlparadiso540 commented Jan 20, 2022

Describe the bug
I am trying to build an Android app to receive video metadata. I add the following to build.gradle dependencies:

implementation 'org.jmisb:jmisb-api:1.11.0'

When I try to build, I get the following error:

Execution failed for task ':app:mergeDebugJavaResource'.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path 'META-INF/native-image/android-arm64/jnijavacpp/jni-config.json' from inputs:
- [user]\.gradle\caches\transforms-3\6090afca4d54369218032ba5cd231f8c\transformed\jetified-ffmpeg-4.3.1-1.5.4-android-arm64.jar
- [user]\.gradle\caches\transforms-3\9895330486c16f3032aaa3744aa45d5e\transformed\jetified-javacpp-1.5.4-android-arm64.jar

In the Android Studio package explorer, I go to /META-INF/native-image/android-arm64/jnijavacpp/
There are duplicates of the following two files:

jni-config.json
reflect-config.json

To Reproduce
Steps to reproduce the behavior:

  1. Create new empty activity in Android Studio
  2. Add dependencies { implementation 'org.jmisb:jmisb-api:1.11.0' }
  3. Sync grade files
  4. Build project

Expected behavior
Adding jmisb dependency should not prevent app from building

Screenshots
n/a

Configuration (please complete the following information):

  • OS: Windows
  • IDE: Android Studio
  • JDK: 16.0.1
  • jMISB version: 1.11.0

Additional Context
Project is currently an empty activity, no code has been added yet. It builds fine when I remove the jmisb dependency from build.gradle

@bradh
Copy link
Collaborator

bradh commented Jan 20, 2022

I don't believe we support Android on 1.11.0 (see #253). Some of the work to split out dependencies that don't exist on Android (like BufferedImage) is on the 2.x branch.

However this looks like a different issue, possibly a transitive dependency on javacpp. I'm not very familiar with Android. Realistically, we're looking for help on this. Can you look at the dependency tree and try excluding javacpp to see if that makes a difference?

@bradh
Copy link
Collaborator

bradh commented Jan 20, 2022

Looks like a similar issue to bytedeco/javacv#1514

Does that work for you?

@mlparadiso540
Copy link
Author

I managed to get it to build by following the advice from the other linked issues. However, it crashes on startup due to not being able to find the BufferedImage class.

I also tried excluding javacpp and ffmpeg individually, but it wouldn't build due to missing dependencies caused by their removal.

@bradh
Copy link
Collaborator

bradh commented Jan 20, 2022

OK - looks like we're back to #253.

If you have a chance, try the 2.x branch. That would at least give you KLV decoding, then you could work out the replacement for the BufferedImage and anything else in AWT.

@mlparadiso540
Copy link
Author

Per the readme for version 2.x, I tried adding

implementation 'org.jmisb:jmisb-api:2.0.0'
but Android Studio says it doesn't exist

I cloned the repository and switched to the 2.x branch, so I can try manually adding the files too

@bradh
Copy link
Collaborator

bradh commented Jan 20, 2022

Yes, 2.x is in development, not released yet. Getting Android working is one of the goals for the 2.0.0 release.

Any assistance (especially pull requests for code or documentation) would be much appreciated. If you have a public example repo, we could link to that too.

@wlfgang
Copy link
Contributor

wlfgang commented Jan 21, 2022

@mlparadiso540 - on the 2.x branch you would need to specify the dependency version as 2.0.0-SNAPSHOT, and you would need to first build jmisb locally, since it's not yet available on Maven Central. You'd probably also need to add mavenLocal() to your list of repositories, so Gradle would find the built artifacts. I will try and update the readme on the branch to clarify.

And as @bradh mentioned, we would really appreciate any help you can provide on Android support.

@saudet
Copy link

saudet commented Mar 24, 2023

Please try to use a javacppExtract task as shown here:
https://github.com/bytedeco/gradle-javacpp#the-platform-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants