Build failed after updating SDK tools and plays services libraries - android

Hi I've currently updated my SDK tools as well as the other components of my SDK except for the M-preview and the sample files which is currently I won't be using. Now problem is after updating the libraries and syncing the gradle it gives me this error:
error: Attribute "track" has already been defined
error: Attribute "thumbTextPadding" has already been defined
error: Attribute "switchMinWidth" has already been defined
error: Attribute "switchPadding" has already been defined
and now my app won't build or run due to this values error on which I'm not sure of why it happens. Here's my current gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
lintOptions{
checkReleaseBuilds false
abortOnError true
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 17
versionName "1.1.0"
}
buildTypes {
release {
runProguard true
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 'com.android.support:design:22.2.0'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'in.srain.cube:grid-view-with-header-footer:1.0.9'
compile 'com.felipecsl.quickreturn:library:1.5.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'it.sephiroth.android.library.imagezoom:imagezoom:+'
compile 'com.makeramen:roundedimageview:1.5.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:facebook')
}
Can someone point out to me on why does this happen? TIA.

By the look of it the attributes you are using ie
error: Attribute "track" has already been defined
error: Attribute "thumbTextPadding" has already been defined
error: Attribute "switchMinWidth" has already been defined
error: Attribute "switchPadding" has already been defined
might being used by the M-Preview SDK.Just change your attributes of the Switch you are using in the attrs.xml file and you are good to go!

Related

Android: Multiple dex files define Lcom/google/android/gms/location/places/zza;

I can't stop getting this error every time, and I don't know what caused it and how I can solve it:
Multiple dex files define Lcom/google/android/gms/location/places/zza;
I think it may have to do with google-services, but I'm not entirely sure.
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.xxxx.xxxx"
minSdkVersion 14
targetSdkVersion 28
versionCode 10173
versionName "4.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// Fixes "Duplicate files copied in APK" build bug
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 {
// Pushy SDK
implementation 'com.google.firebase:firebase-messaging:17.5.0'
compile 'me.pushy:sdk:1.0.43'
// AppCompat v7 Dependency
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.google.android.gms:play-services-maps:16.1.0'
compile 'com.google.android.gms:play-services-places:10.2.0'
// Google Play Services Dependencies
compile 'com.google.android.gms:play-services-location:16.0.0'
compile 'com.google.android.gms:play-services-ads:17.1.1'
// All .jar files in ./libs
compile fileTree(dir: 'libs', include: ['*.jar'])
}
apply plugin: 'com.google.gms.google-services'
If your app has more than 65535 methods, you need to enable the multidex format for your app.
This can be caused by having lots of dependencies in your project.

android studio: duplicating files even when using exclude fix

I am having trouble building my app all of a sudden.
the error:
Error:Execution failed for task
Duplicate files copied in APK lib/x86_64/libogg.so
File1: C:\Users\name\.android\build-cache\72c018be052ae391eef4ab43483d6a04be10a818\output\jni
File2: C:\Users\name\.android\build-cache\425f82e82c18acce2ff0ced2ade670804d31a815\output\jni
I have attempted to fix using packaging options:
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LGPL2.1'
}
entire file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LGPL2.1'
}
defaultConfig {
applicationId "myappsid"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = 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:26.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v4:26'
compile 'com.android.support:support-vector-drawable:26'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'
compile 'com.ibm.watson.developer_cloud:java-sdk:3.9.1'
testCompile 'junit:junit:4.12'
compile project(':library-release')
}
any help is greatly appreciated. I have tried longer exclude options as well in other posts that I have found but that didn't help either.
You can try using pickFirst in packagingOptions. You need to get the correct package name of libogg.so from File1 or File2:
packagingOptions {
pickFirst 'com/library/name/lib/x86_64/libogg.so'
...
}
UPDATE:
There is a conflicted dependencies:
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'
compile 'com.ibm.watson.developer_cloud:java-sdk:3.9.1'
From the Watson Developer Cloud Java SDK documentation you can find the following:
The Android SDK utilizes the Java SDK while making some
Android-specific additions. This repository can be found here. It
depends on OkHttp and gson.
which is pointing to the first library. So, you should only use:
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'

transform.TransformException in Android

I get an error when I try to use iText to generate a PDF at run time.
The error comes when the Application is run in device or geny Motion.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/lowagie/bc/asn1/ASN1Encodable.class.
My Gradle Code is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.visioneering.tfd"
minSdkVersion 15
targetSdkVersion 24
versionCode 5
versionName "1.5"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
android {
lintOptions {
checkReleaseBuilds false
}
}
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:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.github.florent37:materialtextfield:1.0.5'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.itextpdf:itext7-core:7.0.3'
compile 'com.itextpdf:itext-pdfa:5.5.11'
compile 'itext:itext:1.3.1'
compile 'org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.6'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Please help me to solve this problem.
duplicate entry: com/lowagie/bc/asn1/ASN1Encodable.class - that points to iText 2.1.7 or older, which is not known to be compatible with Android.
There are a couple of things wrong in your Gradle file:
compile 'com.itextpdf:itext-pdfa:5.5.11' - that points to the PDF/A add-on of iText 5, version 5.5.11, which is compatible with Android, but you still need the Android port of iText 5, which is called iTextG. So you need to add compile 'com.itextpdf:itextg:5.5.10'. Yes, 5.5.10, not 5.5.11, because there is no itextg:5.5.11. See http://repo1.maven.org/maven2/com/itextpdf/itextg/
I am guessing that you think the "a" in "pdfa" means Android, but it doesn't. It stands for PDF/A: the PDF spec for archiving (ISO 19005), see https://en.wikipedia.org/wiki/PDF/A. If you don't need archiving (you probably don't, in a typical Android app), so you probably need to remove compile 'com.itextpdf:itext-pdfa:5.5.11'
compile 'com.itextpdf:itext7-core:7.0.3' - this is iText 7, which is not compatible with Android. Remove that line.
compile 'itext:itext:1.3.1' - is an ANCIENT version of iText, and is probably what is causing your error. Remove that line.
compile 'org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.6' - this is something special, which I don't know enough about. It may or may not pull in another dependency of iText, which may or may not be the wrong version. Tag your question with flying-saucer to attract extra attention.

Error during Building an APK file in Android Studio 2.1.1

Couple of days ago, I upgraded my Android Studio, and now I am facing a problem.
Actually I am trying to build an APK file from my project to test my app on a real device and when I click at Build--> Build Apk then I receive couple of errors in Message Gradle Build. I don't know why these errors are coming please elaborate on the reason as well.
Errors
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/android/volley/VolleyError;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: 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
build.gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dovezeal.gapp"
minSdkVersion 19
targetSdkVersion 23
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
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
//compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.1'
// Volley
compile 'com.android.volley:volley:1.0.0'
//compile 'com.mcxiaoke.volley:library:1.0.+'
/* compile files('libs/com.mcxiaoke.volley library-1.0.0.jar')*/
// RecyclerView
compile 'com.android.support:recyclerview-v7:23.0.+'
// A simple way to define and render UI specs on top of your Android UI.
compile 'org.lucasr.dspec:dspec:0.1.1'
compile files('libs/library-1.0.0.jar')
// YouTube Player
compile files('libs/YouTubeAndroidPlayerApi.jar')
// GOSN
/* compile files('libs/gson-2.2.3.jar')*/
}
Edit - 1
As janki gadhiya said in her comment below, to change minifyEnabled true and try adding multiDexEnabled true under defaultConfig
with these changes both errors above are gone, but now this following error is coming up.
Error:Execution failed for task:app:transformClassesWithJarMergingForDebug'
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/android/volley/Request$Priority.class
build.gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dovezeal.gapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
//compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.1'
// as you already compiled gradle for volley here
compile 'com.android.volley:volley:1.0.0'
// RecyclerView
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'org.lucasr.dspec:dspec:0.1.1'
// you don't need this so comment the below line.
//compile files('libs/library-1.0.0.jar')
// YouTube Player
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
Edit : Explanations
Your errors 1 - 2 : mean you are having more than 65,000 methods in your project, so I told you to set multiDexEnable true.
Your error 3 : means you're having more than one library having the implementation for the class Request$Priority.class, so the compiler is confused which to choose. So it is showing the error Duplicate entry. This will be solved by packaging options, this will let you use duplicate files.
Add this in your build gradle
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
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'
}
I am also getting the same error. When adding the
compile 'com.google.firebase:firebase-ads:10.2.0'
but it is removed when i do as follow:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.firebase:firebase-ads:10.2.0'
}
apply plugin: 'com.google.gms.google-services'**
and in BuildVarient use debugging mode.
I think it will help you.
while updating firebase any google play services then try to update all the libraries. this worked for me. hope it works in some cases.
Bit late to answer but I faced the same issue.
I was able to rectify it using multiDexEnabled -> true
and used packaging options in build.gradle, post the changes .apk got installed successfully.
Syntax:
defaultConfig {
....
....
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
...
...
}
Hope it helps.

Failed to resolve: com.google.android.gms:play-services-gcm:8.7+

I want to use some Google services in my application, so I have added this line to the .gradle file: com.google.android.gms:play-services-gcm:8.7+. But after trying to sync the project I got this error:
Failed to resolve: com.google.android.gms:play-services-gcm:8.7+
I checked all the available answers on Stackoverflow. They suggest installing the sdk for Google repository and Google play services and I did that. Here is a screenshot of the sdks installed on my computer:
Here is the gradle file code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.project.android.eyedetection"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled 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'
exclude 'META-INF/localization/LocalizedFormats_fr.properties'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile project(':libraries:opencv')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services:8.7+'
compile files ('libs/commons-math-2.2.jar')
compile files ('libs/commons-math-2.2-javadoc.jar')
compile files ('libs/commons-math-2.2-sources.jar')
}
I tried to remove the +, but that didn't solve it.
How can I solve the problem?
EDIT: As suggested by Stanojkovic and Gabriele Mariotti using 8.4 solves the problem, this is because I was mistakenly trying to use 8.7 which is not released yet. Thanks all.
Try with
com.google.android.gms:play-services-panorama:8.4.0
Your issue depends by
compile 'com.google.android.gms:play-services:8.7+'
This version is not published yet (the apk is still in rollout, but the library is not public in the IDE)
Use the last stable release:
compile 'com.google.android.gms:play-services:8.4.0'

Categories

Resources