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 file error while using jUnit in Android apps #929

Closed
mustafa01ali opened this issue Jun 10, 2014 · 10 comments
Closed

Duplicate file error while using jUnit in Android apps #929

mustafa01ali opened this issue Jun 10, 2014 · 10 comments
Milestone

Comments

@mustafa01ali
Copy link

While using jUnit in Android applications, if any other referenced library has a file named "LICENSE.txt", the APK generation fails with the following error -

Error generating final archive: Found duplicate file for APK: LICENSE.txt

A simple renaming of LICENSE.txt to LICENSE-junit.txt would make the lives of a ton of Android developers easier :)

@kcooney
Copy link
Member

kcooney commented Jun 10, 2014

I thought Android used their own fork of JUnit...

Have you tried asking on the Android forums? Many Android projects use JUnit, so I would be surprised if there wasn't a simple workaround.

@mustafa01ali
Copy link
Author

Most Android developers prefer to write pure junit tests so we go with the standard version of junit. Based on my research, here are workarounds that people generally go with -

  1. Remove junit (http://stackoverflow.com/questions/23568882/error-generating-final-archive-found-duplicate-file-for-apk-license-txt)
  2. Move the license files under \META-INF (fge/jackson-coreutils@046c100)
  3. Rename the file

@csoroiu
Copy link

csoroiu commented Jun 20, 2014

Android internally comes with junit3 support.
I am using junit4 + hamcrest with the help of https://github.com/esmasui/AndroidJUnit4 library which basically facilitates running junit4 tests on Android.
For the moment I deleted the License file from junit jar as I see is the one from hamcrest jar (#627) and use a local version of junit (not the one from maven.org).

@kcooney
Copy link
Member

kcooney commented Jun 20, 2014

I don't have any objections to renaming the license file. @dsaff do you have any thoughts?

@Tibor17
Copy link
Contributor

Tibor17 commented Jun 23, 2014

The name of license file is usual in Maven build process.
It's really unusual to have junit in runtime app.
You can still unzip the junit.jar and remove the license file manually or in ANT/Maven.

@csoroiu
Copy link

csoroiu commented Jun 23, 2014

I am using jUnit for unit tests not runtime :). The thing is that in order to run unit tests on android devices (or emulators), it has to package an "apk" file with all the needed libraries (application libraries + junit/hamcrest/mockito etc).

Agreeing that license file is a usual part of the build process, in case of jUnit as #627 states, the licence packed under junit-4.11 is the wrong file.
Adding the correct file and renaming(or moving to META-INF folder) should fix this issue.

Thanks

@Tibor17
Copy link
Contributor

Tibor17 commented Jun 23, 2014

As an example we have several build files in company. This means one in development, next in production, because we don't want to deliver in customer more than necessary. In such case manually modified test framework in build file is okay because it's just only for the internal use.
It sounds like #627 is different issue. The Maven build should already work fine with our license file.

@dsaff
Copy link
Member

dsaff commented Jun 24, 2014

I agree that we should rename to LICENSE-junit.txt

mustafa01ali pushed a commit to mustafa01ali/junit that referenced this issue Jun 24, 2014
…e file errors

while using in Android apps.
kcooney added a commit that referenced this issue Jun 24, 2014
Fixed issue #929 - Renamed license file to prevent duplicate file errors in Android when creating an apk
@kcooney
Copy link
Member

kcooney commented Jun 24, 2014

Fixed by @mustafa01ali

@kcooney kcooney closed this as completed Jun 24, 2014
@stefanbirkner stefanbirkner added this to the 4.12 milestone Jun 24, 2014
johofer pushed a commit to johofer/junit that referenced this issue Jul 1, 2014
…e file errors

while using in Android apps.
johofer pushed a commit to johofer/junit that referenced this issue Jul 1, 2014
…e file errors

while using in Android apps.
@vlsi
Copy link

vlsi commented Jun 20, 2019

It is really sad JUnit uses non-standard LICENSE name.

I think LICENSE should be included in META-INF/ folder, so standard resource transformers can understand how to deal with licenses.

See https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ApacheLicenseResourceTransformer

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

No branches or pull requests

7 participants