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.
Related
I tried building my app but it wouldn't build and show this error.
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'kotlin/internal/internal.kotlin_builtins' from inputs:
- C:\Users\user\.gradle\caches\transforms-3\1203ed0043761220f2e7b9faa528e635\transformed\jetified-kotlin-compiler-embeddable-1.5.31.jar
- C:\Users\user\.gradle\caches\transforms-3\a14ecf8d638c881bd231708fc869e941\transformed\jetified-kotlin-stdlib-1.6.0.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
I tried
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/ASL2.0'
exclude 'internal.kotlin_builtins'
but this doesn't work, I have also tried to Invalidate caches and Restart but to no avail.
I am still learning how to code in android studio so I apologize in advance for my lack of knowledge.
The correct path should be:
exclude 'kotlin/internal/internal.kotlin_builtins'
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 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
In my android application i have multiple third party libraries in libs folder
ex -: httpcore-4.2.4.jar , httpmime-4.2.5.jar,twitter4j-core-4.0.1.jar
these libraries are not duplicated and i'm pretty sure with that , but when i create the proguard release i get this error
(Duplicate zip entry [twitter4j-core-4.0.1.jar:META-INF/MANIFEST.MF])
.... (This error occurs for all of the library(libs)
I refereed this link to overcome with issue , i tried every option of it , but no luck with that ,
Proguard warnings "can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry)"
Is there any way to specify filters on the input jar
Your libraries are not duplicated, but some info files inside of several libraries are.
The best solution is to include in your build.gradle. inside the "android" section something like this:
android{
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LGPL2.1'
}
}
By the error message that you included here I will guess that adding this exclude will solve your problem:
exclude "META-INF/MANIFEST.MF"
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.