This question already has answers here:
Android Studio 0.4 Duplicate files copied in APK META-INF/LICENSE.txt
(13 answers)
Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"
(20 answers)
Closed 6 years ago.
im trying to run this test in Android Studio using selendroid:
public class test_three {
SelendroidLauncher selendroidServer;
WebDriver driver;
public void startServer(){
SelendroidConfiguration config = new SelendroidConfiguration();
selendroidServer = new SelendroidLauncher(config);
selendroidServer.launchSelendroid();
}
#Before
public void beginTest() throws Exception {
DesiredCapabilities capa = DesiredCapabilities.android();
capa.setCapability(SelendroidCapabilities.EMULATOR, true);
driver = new SelendroidDriver(capa);
}
#Test
public void mainTest(){
driver.get("http://m.ebay.de");
WebElement element = driver.findElement(By.id("kw"));
element.sendKeys("Nexus 5");
element.submit();
}
#After
public void testEnd(){
if(driver != null){
driver.quit();
}
}
}
I have added the needed libraries (selendroid-client-0.17.0.jar and selendroid-standalone-0.17.0-with-dependencies.jar) before running and I have started the server thru the cmd. However, I get this error everytime I run it:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK README.md
File1: C:\Users\Training\AndroidStudioProjects\Sample_Three\app\libs\selendroid-client-0.17.0.jar
File2: C:\Users\Training\AndroidStudioProjects\Sample_Three\app\libs\selendroid-standalone-0.17.0-with-dependencies.jar
I have not really found any suggestions online on how to fix it. I hope you guys can help out. Thanks!
EDIT: Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.training.sample_three"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile files('libs/selendroid-client-0.17.0.jar')
compile files('libs/selendroid-standalone-0.17.0-with-dependencies.jar')
}
Just add this to your build.gradle file
packagingOptions {
exclude 'META-INF/README'}
packagingOptions {
exclude 'README'}
Try with above two options.
Please do some research before posting any question here. You can easily get answers for such questions on google.
Write below lines in your app level gradle file
android {
packagingOptions {
exclude 'META-INF/README'
}
}
Found here Android Gradle Duplicate files copied in APK META-INF/license.txt
Related
I am trying to implement Applozic chat in my existing android app. I am already using MQTT for server communication in other classes and its working fine. But after downloading the Applozic library through build.gradle I am getting an error while compiling the application. Applozic also seems to be using the same MQTT technology. The error says:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zznp.class
:app:transformClassesWithJarMergingForDebug FAILED
The build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xxxxx.xxxx.xxx"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
/*allprojects {
repositories {
jcenter()
maven {
url "https://repo.eclipse.org/content/repositories/paho-releases/"
}
maven { url "https://jitpack.io" }
}
}*/
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
//testCompile 'junit:junit:4.12'
compile 'com.applozic.communication.uiwidget:mobicomkitui:4.62'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.android.volley:volley:1.0.+'
compile 'com.vlonjatg.android:app-tour:1.0'
compile 'com.mukesh:permissions:1.0.2'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
/*compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}"
compile(project(':org.eclipse.paho.android.service')) {
transitive = true
}*/
}
task publishAPK(type: Copy) {
from file("${project.buildDir}/outputs/apk/" + rootProject.ext.sampleArchivesBaseName + "-debug.apk");
into '/shared/technology/paho/Android/' + rootProject.ext.sampleVersion + '/debug/';
}
configurations.compile.exclude module: 'org.eclipse.paho.client.mqttv3'
task debug << {
configurations.compile.each { println it}
}
I do not understand why the error shows up. Which library is causing the conflict? What do I need to modify in order to remove the issue?
The error is due to this compile 'com.google.android.gms:play-services:7.8.0'
lib as it is shown in the
error duplicate entry: com/google/android/gms/internal/zznp.class
:app:transformClassesWithJarMergingForDebug FAILED
try to remove this and sync the project .hope it work
Applozic android sdk is using Google play services v9.0.2 can you check by changing to v9.0.2
compile 'com.google.android.gms:play-services:9.0.2'
and if it exceeds 65k check this link
How to enable multidexing with the new Android Multidex support library
I am getting this error when I build my android app on my Machine, it runs perfectly on my old latptop/android enviroment , I get this error. Please let me know, if you need me to show more codes.
Old laptop is running one Android 1.2.2
Gradle 2.2.1 ??
my machine runs on 2.1.1
Gradle 2.10.0
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.io.FileNotFoundException: C:\Users\Ahmad\AndroidStudioProjects\AMHAPP\app\build\intermediates\libs3\httpcore-4.3.jar
(The system cannot find the path specified)
OR
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.io.FileNotFoundException: C:\Users\Ahmad\AndroidStudioProjects\TestApp.gradle\2.2.1\taskArtifacts\lib\jcifs-1.3.18.jar (The system cannot find the path specified)
Note: the following for the build paths of android studio
Example:
old machine :
compile files('C:/Users/Administrator/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
new machine:
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "AMH.Code.testapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android.packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/jcifs-1.3.18.jar')
compile files('build/libs2/commons-io-2.4.jar')
compile files('build/intermediates/libs3/httpcore-4.3.jar')
compile files('libs/httpmime-4.0.1.jar')
compile files('libs/apache-mime4j.jar')
compile files('libs/commons-io-2.4.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/libs2/apache-commons-net.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
compile files('libs/core-2.2.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/libs2/zbar.jar')
compile files('libs/commons-net-3.3.jar')
compile files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
}
apply plugin: 'announce'
Try add this to your build.gradle
android {
useLibrary 'org.apache.http.legacy'
}
Either download jar for httpcore from here : http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore/4.3.2
and add to your lib package and right click and add it as library
or
add gradle dependency in your gradle dependencies{} tag by adding :
compile 'org.apache.httpcomponents:httpcore:4.4.4'
and sync project.
hi im new in android development, i am trying to build my apk but i got this erorr. and i update my gradle and i got duplicate copy. how can i fix this error?
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okhttp/okhttp/pom.properties
File1: C:\Users\Toshiba\.gradle\caches\modules-2\files-2.1\com.squareup.okhttp\okhttp\2.0.0\4c8d1536dba3812cc1592090dc20c47a4ed3c35e\okhttp-2.0.0.jar
File2: C:\Users\Toshiba\.gradle\caches\modules-2\files-2.1\com.crashlytics.android\crashlytics\1.1.13\e821eafa1bf489a26bdb71f95078c26785b37a1\crashlytics-1.1.13.jar
and here's my build.gradle is this the error comes?
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.mymonas.ngobrol"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "0.9.0.68"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'], exclude: 'android-support-v4.jar')
compile project('libs:floatlabel')
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:support-v13:21.0.0'
compile 'com.squareup.retrofit:retrofit:1.7.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.1'
compile 'com.google.android.gms:play-services:6.1.11'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.makeramen:roundedimageview:1.3.0'
compile 'com.andreabaccega:android-form-edittext:1.1.0#aar'
compile 'com.crashlytics.android:crashlytics:1.+'
}
I had the same or at least a very similar problem today with our React Native app. The problem was only on my Mac though. The only plausible explanation we could think of was that I updated a bunch of Android Studio tools and then gradle couldn't build properly with our dependencies. Anyways after excluding the pom.properties and pom.xml from okhttp I kept getting the same error but it turns out that I just had to exclude even more files. This is my complete packagingOptions in build.gradle:
packagingOptions {
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
}
to solve your problem please add this to your build gradle
packagingOptions {
exclude 'META-INF/pom.properties' /*OR*/ 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties
}
It seems like okhttp and crashlytics don't work together in newer gradle versions (2.10 in my case). I fixed this by updating the crashlytics to a newer version (which is now called Fabric).
packagingOptions
{
exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties
exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.xml'
}
Please check for correct path "com.squareup.okhttp/okhttp/pom.properties" in your errorlog.
I'm trying to upload a library to jCenter following this tutorial:
http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
The problem comes when I do ./gradlew install . When is generating the javadoc, I get a lot of errors like this one:
/src/main/java/communicationManager/datareceiver/DeviceShimmer.java:7: error: package com.shimmerresearch.android does not exist
import com.shimmerresearch.android.Shimmer;
Basically, I have inside my Android Studio module a few jar's libraries that I need to use, and it doesn't find them when is creating the javadoc. I've tried adding the following to my module build.gradle, but no luck:
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
exclude '**/BuildConfig.java'
exclude '**/R.java'
failOnError = false
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
This is how my project build.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.exampleapp"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'libs/commons-math-2.2.jar'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile project(':mymodule')
}
And this is how my module build.gradle looks like:
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'maven'
bintrayName = 'name'
publishedGroupId = 'com.name'
libraryName = 'name'
artifact = 'name'
libraryDescription = 'description'
siteUrl = 'https://github.com/...'
gitUrl = 'https://github.com/...'
libraryVersion = '2.0.1'
developerId = '...'
developerName = '...'
developerEmail = '...'
licenseName = 'GPL-3.0'
licenseUrl = 'http://www.gnu.org/licenses/gpl-3.0.en.html'
allLicenses = ["GPL-3.0"]
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 18
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'libs/commons-math-2.2.jar'
}
}
dependencies {
compile 'com.google.guava:guava:12.0'
compile 'com.jjoe64:graphview:3.1.3'
compile files('libs/ShimmerAndroidIntstrumentDriver_v2.6.jar')
compile files('libs/ShimmerDriver_v2.6.jar')
compile files('libs/wekaSTRIPPED.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
exclude '**/BuildConfig.java'
exclude '**/R.java'
failOnError = false
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
Any help would be really appreciated!
I had the same issue. The issue I had was having two or more java jdk versions on my machine or having an outdated java jdk while having the latest jre.
Removing all the jdks and having the most up to date jdk and jre fixed my issue.
I want to read xls and xlsx files.
I use this line to access my workbook.
myWorkBook = WorkbookFactory.create(file);
My build gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.application"
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/poi-3.7.jar')
compile files('libs/poi-ooxml-3.9.jar')
compile project(':aFileChooser')
}
I cannot compile my project as I get the following error:
Error:(210, 41) error: cannot access NPOIFSFileSystem
class file for org.apache.poi.poifs.filesystem.NPOIFSFileSystem not found
Error:Execution failed for task ':app:compileDebugJava'.
Compilation failed; see the compiler error output for details.
Any ideas what could be wrong?
Your problem is almost certainly these lines:
compile files('libs/poi-3.7.jar')
compile files('libs/poi-ooxml-3.9.jar')
Specifically, two issues. Firstly, you must use matching versions of the Apache POI jars. It is not supported to use a mixture of old and new jars at the same time, they must all be from the same release. Secondly, both your jars are old ones, which due to their age miss some features.
Switch those to both be from POI 3.10.1 (or newer, eg 3.11 beta 2 as of writing), and you should then have the classes you need