I have literally created a brand new Android Project on the latest Android Studio. The first thing I did was to add the `Realm' library to the project by adding the following to the gradle file:
compile 'io.realm:realm-android:0.80.3'
If I try to compile, I get the following error:
Note: C:\....\MainActivity.java uses or overrides a deprecated API.
Origin 2:
C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\io.realm\realm-android\0.80.3\7979d05ba7b919c53766bf98e31aaf0e9feb0590\realm-android-0.80.3.jar Error:duplicate files during packaging of APK
C:...\app\build\outputs\apk\app-debug-unaligned.apk Path in archive:
META-INF/services/javax.annotation.processing.Processor Origin 1:
C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\6.1.0\63735f48b82bcd24cdd33821342428252eb1ca5a\butterknife-6.1.0.jar
You can ignore those files in your build.gradle: android {
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor' } Error:Execution failed for task ':app:packageDebug'.
Duplicate files copied in APK META-INF/services/javax.annotation.processing.Processor File 1:
C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\6.1.0\63735f48b82bcd24cdd33821342428252eb1ca5a\butterknife-6.1.0.jar
File 2:
C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\io.realm\realm-android\0.80.3\7979d05ba7b919c53766bf98e31aaf0e9feb0590\realm-android-0.80.3.jar }
Any ideas?
It looks like you are also using Butterknife? Have you tried adding the below to your build.gradle:
android {
...
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
Adding this to the android plugin in build.gradle tends to fix these sorts of problems:
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/*.kotlin_module'
}
}
Adding these on build.gradle as Specified in ButterKnife I/O page.
android{
....
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
lintOptions {
disable 'InvalidPackage'
}
Related
I get this error when I run the application when I connect with firebase
First, try to add this line in build.gradle file: exclude 'META-INF/DEPENDENCIES', then Run 'app'
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}
If error continue occur: 'META-INF/INDEX.LIST', keep adding exclude 'META-INF/INDEX.LIST':
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/INDEX.LIST'
}
}
I have a multi-module Android application and when I build the release APK, I get this dex error:
java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/XX/package-info;
I do of course have a package-info file in all my modules and they all have the same name.
Why does dex even care about package-info files, and how can I configure it to ignore them?
Note: I do NOT want to enable multi-dex
The solution is to exclude the package-info files from the jar files.
Example code to use in build.gradle files
for java-modules:
jar {
exclude('com/**/package-info.*')
}
for android-modules:
android {
sourceSets.main.java.filter.exclude 'com/**/package-info.*'
}
Works with:
Android Studio 3.0 Canary 5
Gradle 4.1-milestone-1
Android gradle plugin: 3.0.0-alpha5
Note: you can of course only then exclude the package-info files if they don't contribute to your build!
e.g. when you use immutables style-configuration in your package-info file then you cannot exclude the files from the build, because then the names of the generated files may change!
Try with using packagingOptions inside android tag in build.gradle for app module.
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
More: Packaging
I have developed a chatting application using signalR for android in eclipse by including 2 library projects. I want to port the application to Android Studio.
How and where do I include the jar files in Android studio. I have followed this link Steps to get SignalR working in Android Studio. But I'm getting following error
Error:Execution failed for task ':app:packageDebug'.
Duplicate files copied in APK doc/allclasses-noframe.html
File 1: C:\AndroidStudioProjects\VConnectMD\app\libs\signalr-client-sdk-android.jar
File 2: C:\AndroidStudioProjects\VConnectMD\app\libs\signalr-client-sdk.jar
I have also added following
packagingOptions {
pickFirst 'META-INF/license.txt'
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'
}
Can somebody help me with the setup?
Thanks
Thats almost means that you added the same library twice,
Try to download signalr-client-sdk-android.jar from the following link:
https://drive.google.com/open?id=0B8POMankZlWcNGZ1Zm9td3pDNVk
put it in your main app module build.gradle file
compile files('libs/signalr-client-sdk-android.jar')
and sync your gradle files.
I added the latest Joda Time jar into my libs folder and added the library. when trying to run I get the following error:
Error:Execution failed for task ':Selfies:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE.txt
File 1: C:\Users\Dominic\Desktop\selfieapp\Selfies\Selfies\libs\commons-io-2.4.jar
File 2: C:\Users\Dominic\Desktop\selfieapp\Selfies\Selfies\libs\joda-time-2.8.1.jar
Not too sure what this means and how to fix it. Any help would be great!
Update yout build.gradle like this:
android {
...
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
you can exclude this file with packagingOptions in your build.gradle - but you should also have a look into joda-time-android or even better https://github.com/JakeWharton/ThreeTenABP
I'm getting a duplicate files error when attempting to build with Gradle.
Error:Execution failed for task ':pauwowandroid:packageDebug'.
> Duplicate files copied in APK LICENSE
File 1: /Users/jasonrobinson/.gradle/caches/modules-2/files-2.1/org.sonatype.sisu.inject/cglib/2.2.1-v20090111/7ce5e983fd0e6c78346f4c9cbfa39d83049dda2/cglib-2.2.1-v20090111.jar
File 2: /Users/jasonrobinson/.gradle/caches/modules-2/files-2.1/org.sonatype.sisu.inject/cglib/2.2.1-v20090111/7ce5e983fd0e6c78346f4c9cbfa39d83049dda2/cglib-2.2.1-v20090111.jar
This is different from other similar errors in that it's complaining the duplicate is in the same file. These are my exclusions:
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}
I still get this error. It's with one particular dependency: Mockito. If I remove that dependency, the error goes away.
Try to add the following exclude:
exclude 'LICENSE.txt'
This should fix it.