Gradle build failed - Apache HttpEntity - android

I get this error when I try to run my application:
Information:Gradle tasks [:app:assembleDebug]
Warning:Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72200Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug
Error:duplicate files during packaging of APK /Users/.../app/build/outputs/apk/app-debug-unaligned.apk
Path in archive: META-INF/NOTICE
Origin 1: /Users/.../.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient-android/4.3.5/82edcaec6c7b4599eaeaaf11167ceea41db42f33/httpclient-android-4.3.5.jar
Origin 2: /Users/.../.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.5/1dd0d38df9c6d21e893f2e52403f1cd99e91cd81/httpmime-4.3.5.jar
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'META-INF/NOTICE'
}
}
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/NOTICE
File 1: /Users/.../.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient-android/4.3.5/82edcaec6c7b4599eaeaaf11167ceea41db42f33/httpclient-android-4.3.5.jar
File 2: /Users/.../.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient-android/4.3.5/82edcaec6c7b4599eaeaaf11167ceea41db42f33/httpclient-android-4.3.5.jar
Information:BUILD FAILED
Information:Total time: 2.754 secs
Information:2 errors
Information:2 warnings
Information:See complete output in console
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "..."
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
compile (group: 'org.apache.httpcomponents' , name: 'httpmime' , version: '4.3.5') {
exclude module: 'org.apache.httpcomponents:httpclient'
}
}
I simply want to import the following libraries:
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
so I can run the following code:
String sendProfileData = getResources().getString(R.string.URL);
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(sendProfileData);
MultipartEntity mpEntity = new MultipartEntity();
try {
mpEntity.addPart("first_name", new StringBody("Jay"));
mpEntity.addPart("last_name", new StringBody("Shmidt"));
...
}
...
What exactly is wrong here - Do I actually need to delete or replace jar files? Why isn't gradle taking care of this?
Any advice would be really helpful. Thanks in advance!

Update: I got the answer from this post
Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"
android {
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'
}
}

Thats not problem in Android Studio only your system require internet connection
Just extends class MultipartEntity
Than press Alt+Enter
Than click find jar on web
Select httpmime-4.0-alpha4.jar
Than right click on project structure
Click open module setting
In dependencies tab click on + icon on right side
Than click on file dependency select http:mime file added
Finally build project

Related

Unable to merge dex with androidTestImplementation

I get an unable to merge dex exception when i try to run my android test together with uiAutomation.
androidTestImplementation ('com.google.android:android-test:4.1.1.4')
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebugAndroidTest'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
However, if I change from androidTestImplementation to testCompile everything is working fine. I would be happy if someone could explain me the different behaviour between androidTestImplementation and testCompile. Secondly, how I can add this dependecy with androidTestImplementation.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.1'
}
android {
compileSdkVersion 27
buildToolsVersion '26.0.2'
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
generatedDensities = []
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
debug {
debuggable true
shrinkResources false
versionNameSuffix "-debug"
minifyEnabled false
// minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
// testProguardFiles file ('test-proguard-rules.pro')
}
release {
debuggable true
minifyEnabled true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
}
staging {
// Specifies a sorted list of fallback build types that the
// plugin should try to use when a dependency does not include a
// "staging" build type. You may specify as many fallbacks as you
// like, and the plugin selects the first build type that's
// available in the dependency.
matchingFallbacks = ['debug', 'qa', 'release']
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
def playVersion = '11.6.2'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.support:appcompat-v7:27.0.2'
compile 'com.roomorama:caldroid:3.0.1'
compile 'com.google.android.gms:play-services-location:' + playVersion
compile 'com.google.android.gms:play-services-ads:' + playVersion
compile 'com.google.android.gms:play-services-analytics:' + playVersion
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.gson:gson:2.5'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'com.android.support:design:27.0.2'
compile 'joda-time:joda-time:2.9.3'
compile 'org.joda:joda-convert:1.8.1'
compile group: 'com.github.chrisbanes.photoview', name: 'library', version: '1.2.4'
compile 'com.android.support:multidex:1.0.2'
compile 'com.amazonaws:aws-android-sdk-core:2.4.2'
compile 'com.amazonaws:aws-android-sdk-s3:2.4.2'
compile 'com.amazonaws:aws-android-sdk-ddb:2.4.2'
compile 'com.google.android.gms:play-services-auth:' + playVersion
// https://mvnrepository.com/artifact/org.simpleframework/simple-xml
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}
compile group: 'commons-codec', name: 'commons-codec', version: '1.3'
compile project(':volley')
compile project(':SimpleDTGHub')
implementation "android.arch.lifecycle:runtime:1.0.3"
implementation "android.arch.lifecycle:extensions:1.0.0"
androidTestImplementation 'com.android.support:support-annotations:27.0.2'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation('org.robolectric:robolectric:2.4') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
androidTestImplementation('com.google.android:android-test:4.1.1.4') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'junit', module: 'junit'
}
androidTestImplementation "com.android.support.test:runner:1.0.1"
androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.1"
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.1'
}
android {
packagingOptions {
exclude '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/inputList.txt'
exclude 'META-INF/inputList'
exclude 'META-INF/jersey-module-version'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
Full gradle Output:
Executing tasks: [:MyApp:assembleDebug, :MyApp:assembleDebugAndroidTest]
Configuration 'compile' in project ':MyApp' is deprecated. Use 'implementation' instead.
Configuration 'compile' in project ':SimpleDTGHub' is deprecated. Use 'implementation' instead.
Configuration 'testCompile' in project ':volley' is deprecated. Use 'testImplementation' instead.
:MyApp:preBuild UP-TO-DATE
:SimpleDTGHub:preBuild UP-TO-DATE
:SimpleDTGHub:preDebugBuild UP-TO-DATE
:SimpleDTGHub:checkDebugManifest UP-TO-DATE
:SimpleDTGHub:processDebugManifest UP-TO-DATE
:volley:preBuild UP-TO-DATE
:volley:preDebugBuild UP-TO-DATE
:volley:checkDebugManifest UP-TO-DATE
:volley:processDebugManifest UP-TO-DATE
:MyApp:preDebugBuild UP-TO-DATE
:SimpleDTGHub:compileDebugAidl UP-TO-DATE
:volley:compileDebugAidl UP-TO-DATE
:MyApp:compileDebugAidl UP-TO-DATE
:SimpleDTGHub:packageDebugRenderscript NO-SOURCE
:volley:packageDebugRenderscript NO-SOURCE
:MyApp:compileDebugRenderscript UP-TO-DATE
:MyApp:checkDebugManifest UP-TO-DATE
:MyApp:generateDebugBuildConfig UP-TO-DATE
:MyApp:generateDebugResValues UP-TO-DATE
:MyApp:generateDebugResources UP-TO-DATE
:SimpleDTGHub:compileDebugRenderscript UP-TO-DATE
:SimpleDTGHub:generateDebugResValues UP-TO-DATE
:SimpleDTGHub:generateDebugResources UP-TO-DATE
:SimpleDTGHub:packageDebugResources UP-TO-DATE
:volley:compileDebugRenderscript UP-TO-DATE
:volley:generateDebugResValues UP-TO-DATE
:volley:generateDebugResources UP-TO-DATE
:volley:packageDebugResources UP-TO-DATE
:MyApp:mergeDebugResources UP-TO-DATE
:MyApp:createDebugCompatibleScreenManifests UP-TO-DATE
:MyApp:processDebugManifest UP-TO-DATE
:MyApp:splitsDiscoveryTaskDebug UP-TO-DATE
:SimpleDTGHub:platformAttrExtractor UP-TO-DATE
:SimpleDTGHub:processDebugResources UP-TO-DATE
:volley:platformAttrExtractor UP-TO-DATE
:volley:processDebugResources UP-TO-DATE
:MyApp:processDebugResources UP-TO-DATE
:SimpleDTGHub:generateDebugBuildConfig UP-TO-DATE
:SimpleDTGHub:compileDebugKotlin UP-TO-DATE
:SimpleDTGHub:prepareLintJar UP-TO-DATE
:SimpleDTGHub:generateDebugSources UP-TO-DATE
:SimpleDTGHub:javaPreCompileDebug UP-TO-DATE
:SimpleDTGHub:compileDebugJavaWithJavac UP-TO-DATE
:SimpleDTGHub:processDebugJavaRes NO-SOURCE
:SimpleDTGHub:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:volley:generateDebugBuildConfig UP-TO-DATE
:volley:prepareLintJar UP-TO-DATE
:volley:generateDebugSources UP-TO-DATE
:volley:javaPreCompileDebug UP-TO-DATE
:volley:compileDebugJavaWithJavac UP-TO-DATE
:volley:processDebugJavaRes NO-SOURCE
:volley:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:MyApp:compileDebugKotlin
:MyApp:prepareLintJar UP-TO-DATE
:MyApp:generateDebugSources UP-TO-DATE
:MyApp:javaPreCompileDebug
:MyApp:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:MyApp:compileDebugNdk NO-SOURCE
:MyApp:compileDebugSources
:MyApp:mergeDebugShaders UP-TO-DATE
:MyApp:compileDebugShaders UP-TO-DATE
:MyApp:generateDebugAssets UP-TO-DATE
:SimpleDTGHub:mergeDebugShaders UP-TO-DATE
:SimpleDTGHub:compileDebugShaders UP-TO-DATE
:SimpleDTGHub:generateDebugAssets UP-TO-DATE
:SimpleDTGHub:mergeDebugAssets UP-TO-DATE
:volley:mergeDebugShaders UP-TO-DATE
:volley:compileDebugShaders UP-TO-DATE
:volley:generateDebugAssets UP-TO-DATE
:volley:mergeDebugAssets UP-TO-DATE
:MyApp:mergeDebugAssets UP-TO-DATE
:MyApp:transformClassesWithStackFramesFixerForDebug UP-TO-DATE
:MyApp:transformClassesWithDesugarForDebug UP-TO-DATE
:MyApp:transformClassesWithDexBuilderForDebug UP-TO-DATE
:MyApp:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE
:MyApp:transformDexArchiveWithDexMergerForDebug UP-TO-DATE
:MyApp:mergeDebugJniLibFolders UP-TO-DATE
:SimpleDTGHub:compileDebugNdk NO-SOURCE
:SimpleDTGHub:mergeDebugJniLibFolders UP-TO-DATE
:SimpleDTGHub:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:SimpleDTGHub:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
:volley:compileDebugNdk NO-SOURCE
:volley:mergeDebugJniLibFolders UP-TO-DATE
:volley:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:volley:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
:MyApp:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:MyApp:processDebugJavaRes NO-SOURCE
:MyApp:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:MyApp:validateSigningDebug
:MyApp:packageDebug UP-TO-DATE
:MyApp:assembleDebug
:MyApp:bundleAppClassesDebug UP-TO-DATE
:MyApp:preDebugAndroidTestBuild
:MyApp:compileDebugAndroidTestAidl UP-TO-DATE
:MyApp:processDebugAndroidTestManifest UP-TO-DATE
:MyApp:compileDebugAndroidTestRenderscript UP-TO-DATE
:MyApp:generateDebugAndroidTestBuildConfig UP-TO-DATE
:MyApp:generateDebugAndroidTestResValues UP-TO-DATE
:MyApp:generateDebugAndroidTestResources UP-TO-DATE
:MyApp:mergeDebugAndroidTestResources UP-TO-DATE
:MyApp:splitsDiscoveryTaskDebugAndroidTest UP-TO-DATE
:MyApp:processDebugAndroidTestResources UP-TO-DATE
:MyApp:compileDebugAndroidTestKotlin
:MyApp:generateDebugAndroidTestSources UP-TO-DATE
:MyApp:javaPreCompileDebugAndroidTest
:MyApp:compileDebugAndroidTestJavaWithJavac
:MyApp:compileDebugAndroidTestNdk NO-SOURCE
:MyApp:compileDebugAndroidTestSources
:MyApp:mergeDebugAndroidTestShaders UP-TO-DATE
:MyApp:compileDebugAndroidTestShaders UP-TO-DATE
:MyApp:generateDebugAndroidTestAssets UP-TO-DATE
:MyApp:mergeDebugAndroidTestAssets UP-TO-DATE
:MyApp:transformClassesWithStackFramesFixerForDebugAndroidTest UP-TO-DATE
:MyApp:transformClassesWithDesugarForDebugAndroidTest UP-TO-DATE
:MyApp:transformClassesWithDexBuilderForDebugAndroidTest UP-TO-DATE
:MyApp:transformDexArchiveWithExternalLibsDexMergerForDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':MyApp:transformDexArchiveWithExternalLibsDexMergerForDebugAndroidTest'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
87 actionable tasks: 9 executed, 78 up-to-date
The root cause was an conflict of the XmlPullParserException class. This class is part of the xxp3 dependency and part of org.simpleframework.simplexml.
+--- com.google.android:android-test:4.1.1.4
| +--- com.google.android:android:4.1.1.4
| | +--- commons-logging:commons-logging:1.1.1
| | +--- org.apache.httpcomponents:httpclient:4.0.1
| | | +--- org.apache.httpcomponents:httpcore:4.0.1
| | | +--- commons-logging:commons-logging:1.1.1
| | | \--- commons-codec:commons-codec:1.3
| | +--- org.khronos:opengl-api:gl1.1-android-2.1_r1
| | +--- xerces:xmlParserAPIs:2.6.2
| | +--- xpp3:xpp3:1.1.4c
To solve this issue I had to exclude the dependecy from com.google.android:android-test.
androidTestImplementation('com.google.android:android-test:4.1.1.4'){
exclude group: 'xpp3'
}

Android Gradle Duplicate files copied in APK META-INF

I try to add spring in my android application but the application doesn't run.
i really don't know why my run failed. could you help me to fix this problem and thanks
This is my app/build.gradle config:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.nizar.abdelhedi.accesscontrol"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "string", "host_name", "access-control-web/rest/roles/attendance"
}
}
configurations {
all*.exclude module: 'httpclient'
all*.exclude module: 'commons-logging'
}
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.github.vajro:MaterialDesignLibrary:1.6'
compile 'com.github.blackfizz:eazegraph:1.2.2#aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.lecho:hellocharts-library:1.5.8#aar'
compile 'org.springframework:spring-context:4.2.7.RELEASE'
}
}
and this is my error messages
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2340Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE
:app:prepareComGithubBlackfizzEazegraph122Library UP-TO-DATE
:app:prepareComGithubLechoHellochartsLibrary158Library UP-TO-DATE
:app:prepareComGithubVajroMaterialDesignLibrary16Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:buildInfoDebugLoader
:app:transformClassesWithExtractJarsForDebug UP-TO-DATE
:app:transformClassesWithInstantRunVerifierForDebug UP-TO-DATE
:app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug FAILED
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/spring.schemas
File1: C:\Users\abdelhedi\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\4.2.7.RELEASE\289f2906943827d37de89240dbac8fe4b315a838\spring-context-4.2.7.RELEASE.jar
File2: C:\Users\abdelhedi\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\4.2.7.RELEASE\bd65f97ba61fd3dcc0b74765d3fa388aeb388aa7\spring-aop-4.2.7.RELEASE.jar
File3: C:\Users\abdelhedi\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\4.2.7.RELEASE\ae0501728c0ee072e25cb5e11b63b883c0786b4b\spring-beans-4.2.7.RELEASE.jar
Information:BUILD FAILED
Information:Total time: 2.634 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
add another to your packagingOptions
exclude 'META-INF/spring.schemas'
EDIT: keeeeep adding to it! looks like you've got a boatload of duplicates
Whenever you see Exception: Duplicate files copied in APK BLAH/blah.blah
add another exclude 'BLAH/blah.blah'

Error:Execution failed for task ':app:dexDebug' inished with non-zero exit value 2 in android studio

I have faced a unknown type of error.
here my build.grable:-
apply plugin: 'com.android.application'
repositories {
maven { url "https://jitpack.io" }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "shoppingmazza.android.catalyst.com.shoppingmazza"
minSdkVersion 16
targetSdkVersion 23
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 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile files('libs/fluent-hc-4.5.jar')
compile files('libs/httpclient-4.5.jar')
compile files('libs/httpclient-cache-4.5.jar')
compile files('libs/httpclient-win-4.5.jar')
compile files('libs/httpcore-4.4.1.jar')
compile files('libs/httpmime-4.5.jar')
compile files('libs/jna-4.1.0.jar')
compile files('libs/jna-platform-4.1.0.jar')
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile files('libs/commons-net-3.0.1.jar')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1#aar'
}
and here my logcat:-
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2310Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72310Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42310Library UP-TO-DATE
:app:prepareComDaimajiaSliderLibrary115Library UP-TO-DATE
:app:prepareComGithubJakeWhartonViewPagerIndicator241Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 2
I am new in android developing.Anyone can help me solved my problem. I near my to complete project. Please help me. Thanks in advance!
Add this inside your android block:
dexOptions {
preDexLibraries = false
}
Your project methods is over 65k. You should implement Multidex
if your project has more than 65K method , you have to enable multiDex option in gradle ,, to make sure if the problem caused by multiDex ,, just run your app on a lolipop device if it running fine , then the problem is MultiDex ,
lolipop doesn't use Dalvik thats why it will running fine
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
You are adding twice the support-library v4.
It happens because you are using
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1#aar'
You are getting this library from the jitpack.
This library adds the support library as a jar and not as a gradle dependency.
It means that the pom file doesn't have a dependency and you can't exclude the jar file with gradle because the jar is inside the aar file (without a pom how can gradle know that these files should be excluded?).
You can check the files in the jitpack repo:
pom file
aar file
You can try to use the same library from other repo, for example:
`fr.avianey.com.viewpagerindicator:library:2.4.1`
You can check this issue on github.

Android, Gradle : RetroLambda not working

I am working on an Android application and I came up with RetroLambda tool, with which I can use Lambda expressions in Android app(So much win!!).
Unfortunately it is not working. I am posting my Gradle files for app and overall. Kindly let me know what I am doing wrong. Thanks a lot.
Build.gradle (Module : app)
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.6.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.0'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
compile ('org.springframework.android:spring-android-auth:1.0.1.RELEASE'){
exclude group :'org.springframework', module: 'commons-logging'
exclude group :'org.springframework', module: 'spring-core'
exclude group :'org.springframework', module: 'spring-web'
}
compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'commons-codec:commons-codec:1.9'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'io.reactivex:rxandroid:1.0.1'
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.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'
}
}
Build.gradle (Module : projectName)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'me.tatarka.retrolambda'
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'me.tatarka:gradle-retrolambda:3.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
Error log :
Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE
:app:prepareIoReactivexRxandroid101Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJava
Note: /home/akshay/AndroidStudioProjects/app/app/src/main/java/myapp/com/app/Service/RestaurantServiceImpl.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug
:app:dexDebug
AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536","position":{},"original":"com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)","position":{},"original":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)","position":{},"original":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","position":{},"original":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","position":{},"original":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:106)"}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.888 secs
I am right now running in Emulator. I hope that is not the problem. Thanks a lot.
You can check my project. I'm using retrolambda. But to build the project you need to define java8 path on your system.
https://github.com/JenyaKirmiza/GithubClient
You may apply the plugin in your app's build.gradle (instead of the root project). The other thing you should check, is your dependencies has java 8 written classes or not. If so, be aware that the plugin only works on your current project (classes), and have nothing to do with classes inside dependencies. If you want to retrolambda those dependencies, you may unpack them somewhere and apply the plugin on.

Android studio: Gradle build finished with error

I have been using Android Studio and I am getting this error when trying to build.I can't able to proceed.
This is the error in Android Studio:
Executing tasks: [:libraries:facebook:generateDebugSources, :library:generateDebugSources, :volley:generateDebugSources]
Configuration on demand is an incubating feature.
WARNING [Project: :volley] "testPackageName" is deprecated (and will soon stop working); change to "testApplicationId" instead
:libraries:facebook:preBuild
:libraries:facebook:preDebugBuild
:libraries:facebook:checkDebugManifest
:libraries:facebook:prepareDebugDependencies
:libraries:facebook:compileDebugAidl UP-TO-DATE
:libraries:facebook:compileDebugRenderscript UP-TO-DATE
:libraries:facebook:generateDebugBuildConfig UP-TO-DATE
:libraries:facebook:generateDebugAssets UP-TO-DATE
:libraries:facebook:mergeDebugAssets UP-TO-DATE
:libraries:facebook:generateDebugResValues UP-TO-DATE
:libraries:facebook:generateDebugResources UP-TO-DATE
:libraries:facebook:packageDebugResources UP-TO-DATE
:libraries:facebook:processDebugManifest UP-TO-DATE
:libraries:facebook:processDebugResources UP-TO-DATE
:libraries:facebook:generateDebugSources UP-TO-DATE
:library:preBuild
:library:preDebugBuild
:library:checkDebugManifest
:library:prepareDebugDependencies
:library:compileDebugAidl UP-TO-DATE
:library:compileDebugRenderscript UP-TO-DATE
:library:generateDebugBuildConfig UP-TO-DATE
:library:generateDebugAssets UP-TO-DATE
:library:mergeDebugAssets UP-TO-DATE
:library:generateDebugResValues UP-TO-DATE
:library:generateDebugResources UP-TO-DATE
:library:packageDebugResources UP-TO-DATE
:library:processDebugManifest UP-TO-DATE
:library:processDebugResources UP-TO-DATE
:library:generateDebugSources UP-TO-DATE
:volley:preBuild
:volley:preDebugBuild
:volley:checkDebugManifest
:volley:prepareDebugDependencies
:volley:compileDebugAidl UP-TO-DATE
:volley:compileDebugRenderscript UP-TO-DATE
:volley:generateDebugBuildConfig UP-TO-DATE
:volley:generateDebugAssets UP-TO-DATE
:volley:mergeDebugAssets UP-TO-DATE
:volley:generateDebugResValues UP-TO-DATE
:volley:generateDebugResources UP-TO-DATE
:volley:packageDebugResources UP-TO-DATE
:volley:processDebugManifest UP-TO-DATE
:volley:processDebugResources UP-TO-DATE
:volley:generateDebugSources UP-TO-DATE
BUILD FAILED
Total time: 2 mins 7.494 secs
This is my app gradle :
build.gradle :
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
signingConfigs {
release {
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
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'
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.android.gms:play-services:5.0.77'
compile 'com.android.support:appcompat-v7:+'
compile 'com.makeramen:roundedimageview:1.2.4'
compile 'com.nineoldandroids:library:2.4.0+'
compile project(':libraries:facebook')
compile project(':library')
compile project(':stripe')
compile project(':volley')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/activation.jar')
compile files('libs/mail.jar')
compile files('libs/iprint.jar')
}
This Question is old but it may be useful for new programmers of Android Studio ,
So this error in my case solved by cleaning project from Build Menu.
I'm not sure if you post all error's text, in my case in the end will be very useful information to fix this trouble. Maybe in your case trouble is the same.
So, in my case was trouble with dependecies.
In my app module in build.grale I used other dependencies for support.v4
In your case: compile 'com.android.support:support-v4:19.1.0'
Facebook SDK used jar, so, support.v4 was added as jar.
To fix this, just remove jar, and add to your Facebook build.gradle file the same line to import support library as on your main app module.
Hope, this will help you.
I faced same issue today
This is a bug in dex merger when the dex files that are being merged have more than 65536 methods (or strings). We can fix this by adding
dexOptions {
jumboMode = true
}
In the gradle file. Don’t forget to add this all sub projects too else it may not work.
I faced this problem in ubuntu 16.04 and came up with a simple solution:
Type sudo nautilus in terminal.
Now go to the root directory and recursively change permissions to Read and Write and Create and Delete files. You will be able to do that by the option Change permissions for enclosed files.

Categories

Resources