Android APP cant build because of httpcore - java

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.

Related

Getting duplicate entry error after adding branch.io to my android project

Everything was working fine, but after adding this to my android project error building apk started.Here is the error and dependency
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/crashlytics/android/answers/shim/R.class
compile('io.branch.sdk.android:library:2.6.0#aar') {
transitive = true;
exclude module: 'answers-shim'
}
tried excluding it also but error persists.
Here is my full gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://dl.bintray.com/hani-momanii/maven"}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 19
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
resConfigs "en_US", "hi_IN"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.digits.sdk.android:digits:2.0.6#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}
compile('io.fabric.sdk.android:fabric:1.3.10#aar') {
transitive = true;
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:gridlayout-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-annotations:25.3.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-places:10.2.1'
compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.+'
compile 'com.amazonaws:aws-android-sdk-ddb:2.2.+'
compile 'com.amazonaws:aws-android-sdk-lambda:2.2.+'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.google.firebase:firebase-storage:10.2.1'
compile 'com.google.firebase:firebase-appindexing:10.2.1'
compile 'com.github.clans:fab:1.6.4'
compile 'com.amazonaws:aws-android-sdk-cognito:2.3.9'
compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile('io.branch.sdk.android:library:2.6.0#aar') {
transitive = true;
exclude module: 'answers-shim'
}
}
apply plugin: 'com.google.gms.google-services'
If i add the exclude statement to branch and digits then while entering the app it crashes,if added exclude to crashlytics the error persists.But without adding branch everything works perfect no error during apk build too.
I was struggling with this all day today as well. What ended up fixing it for me was rolling back branch to 2.5.9. There obviously seems to be something wrong with the new 2.6.0 release.
Another note for branch I don't have the transitive aar include so it's just
compile ('io.branch.sdk.android:library:2.5.9') {
exclude module: 'answers-shim';
}
Fixed the the issue when removed transitive = true from the dependency
compile('io.branch.sdk.android:library:2.6.0#aar') {
exclude module: 'answers-shim'
}
For those who want to use the latest version of branch.io, you have to add the following lines in your proguard file.
-dontwarn com.crashlytics.android.answers.shim.**
-dontwarn com.google.firebase.appindexing.**
-dontwarn com.android.installreferrer.api.**
With this change exclude module: answers-shim is not required in the gradle file.

Duplicate entry in build.gradle zznp.class

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

Android Studio : Unsupported major.minor version 52.0

My friend Gave me a project which was built in Windows platform and I have ubuntu. So when I import the project I am getting this error,
Error:(1, 0) Cause: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
How can get my project running. I have tried all the possible solutions but didn't work any one of them.
I have already point my SDK path and using JDK 1.7.0. Using Gradle 2.14.1 which is latest one.
Here is my gradle.build file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.lenovo.myapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
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'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.api-client:google-' +
'api-client-gson:+'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.http-client:google-http-client-android:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.google.android.gms:play-services-identity:9.2.1'
compile 'com.google.android.gms:play-services-plus:9.2.1'
compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha5'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.1.3'
testCompile 'junit:junit:4.12'
}
Any solution would be appreciated. I am stuck since last 2 days.
I have already point my SDK path and using JDK 1.7.0
You need JDK 1.8 with the new version of Studio and the build tools.
You are trying to use JDK 1.7. The project was built on 1.8 ( 52.0 - refer this link How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version). So, probaby using 1.8 JDK and JRE may work for you.

Duplicate files copied in APK META-INF

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.

cannot access NPOIFSFileSystem

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

Categories