WestRidgeSystems / jmisb

jMISB is an open source Java library implementing various MISB standards.
MIT License
40 stars 13 forks source link

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

Open mlparadiso540 opened 2 years ago

mlparadiso540 commented 2 years ago

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):

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 commented 2 years ago

I don't believe we support Android on 1.11.0 (see https://github.com/WestRidgeSystems/jmisb/issues/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 commented 2 years ago

Looks like a similar issue to https://github.com/bytedeco/javacv/issues/1514

Does that work for you?

mlparadiso540 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 1 year ago

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