jmisb icon indicating copy to clipboard operation
jmisb copied to clipboard

Duplicate package files causing build to fail in Android Studio

Open mlparadiso540 opened this issue 3 years ago • 8 comments

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

mlparadiso540 avatar Jan 20 '22 02:01 mlparadiso540

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 avatar Jan 20 '22 02:01 bradh

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

Does that work for you?

bradh avatar Jan 20 '22 04:01 bradh

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.

mlparadiso540 avatar Jan 20 '22 17:01 mlparadiso540

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.

bradh avatar Jan 20 '22 19:01 bradh

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

mlparadiso540 avatar Jan 20 '22 22:01 mlparadiso540

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.

bradh avatar Jan 20 '22 22:01 bradh

@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.

wlfgang avatar Jan 21 '22 14:01 wlfgang

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

saudet avatar Mar 24 '23 11:03 saudet