duplicate library gradle animatorlistener duplicate - android

I'm trying to use some libraries into my android project and I'm facing some problems with different libraries. I have a library which I import from maven repository that has "nineoldandroids" library dependency. After that I have another import that uses the same library and I did a exclude of that module. Now if I sync Gradle everything works fine but when I try to run my app I get the following error
"Error:Class com.nineoldandroids.animation.Animator.AnimatorListener has already been added to output. Please remove duplicate copies."
I think that both libraries are trying to use the same Listener and I get that error but I'm not able to solve it and I didn't find useful information for me. If somebody can help me I would appreciate it. This is my gradle file. BTW last library must be manually included and it's placed in my "libs" folder.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.infortec.acostela.pescamerca"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories{
jcenter()
flatDir {
dirs 'libs'
}
}
dexOptions {
preDexLibraries = false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.+'
compile "com.android.support:gridlayout-v7:18.0.+"
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'commons-net:commons-net:3.3'
compile 'net.sf.opencsv:opencsv:2.3'
compile 'com.rengwuxian.materialedittext:library:1.8.2'
compile ('libs.example:material:0.4.3#aar'){
exclude module: 'nineoldandroids'
}
}

Finally I solved it.
The problem was that I must exclude the whole library, not only the module so writing the following solved it.
compile ('com.rengwuxian.materialedittext:library:1.8.2'){
exclude group: 'com.nineoldandroids', module: 'library'
}

Related

Cannot access ActivityCompatApi23 class

I am having runtime problems with my gradle file. I added this compile 'com.google.android:flexbox:0.3.1' as a compile time dependency to my Gradle file. I encountered an error and added this in my project level Gradle file.
maven {
url "https://maven.google.com"
}
Which finally looked liked this after adding the above
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
After adding the above in my app level Gradle file I am now encountering a different error when I am trying to run my app. So I did the following as per some answers from SO.
Tried a Clean and Rebuild.
Navigated to the path projectName\.idea\libraries and deleted the files that contained the support library version other than the current versions 25.3.1
3.In order to solve the error I further removed this line from my app level Gradle file,
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Now the final Gradle file looks like this with the error,
Error:
Error:(28, 8) error: cannot access ActivityCompatApi23
class file for android.support.v4.app.ActivityCompatApi23 not found
My Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 19
targetSdkVersion 25
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')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android:flexbox:0.3.1'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
testCompile 'junit:junit:4.12'
}
Like the Problem I meet。
When I Use Android Room like this :
compileSdkVersion 25
compile "android.arch.persistence.room:runtime:1.0.0"
I get the same Error.
Because compileSdkVersion should match support libs major version.
More Detail you can see this :
Error in support lib after room persistence
Room depends on 26.1 of support library, which is probably why it is broken because SupportLibrary does not promise interop between versions.
Also, you can fix the problem use this
compile ("android.arch.persistence.room:runtime:1.0.0") {
exclude group: 'com.android.support'
}
You have declared compileSdkVersion equal to 25, whereas 0.3.1 version of flexbox layout uses support libs version 26.0.0 - that's a problem, compileSdkVersion should match support libs major version.
Either upgrade your project to 26 or use a version of flexbox layout that relies on sdk 25, which seems to be v0.2.7:
compile 'com.google.android:flexbox:0.2.7'
use
compile 'com.android.support:appcompat-v7:26.1.0'
I just changed the line
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
to
compile 'com.android.support:appcompat-v7:26.+'
and it worked for me

com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex - Android Studio 3.0 stable

I made:
In "Settings"->"Android SDK"->"SDK Tools" Google Play services is checked and installed v.46
Removed folder /.gradle
"Clean Project"
"Rebuild Project
Error is:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.asanquran.mnaum.quranasaanurdutarjuma"
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-ads:11.4.2'
compile 'com.github.barteksc:android-pdf-viewer:2.3.0'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.google.firebase:firebase-ads:11.4.2'
compile 'com.google.firebase:firebase-messaging:11.4.2'
compile 'com.google.firebase:firebase-storage:11.4.2'
apply plugin: 'com.google.gms.google-services'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Go to <project>/app/ and open build.gradle file
Add the following line to the defaultConfig and dependencies sections
android {
...
defaultConfig {
...
multiDexEnabled true // ADD THIS LINE
}
}
...
dependencies {
...
implementation 'com.android.support:multidex:1.0.3' // ADD THIS LINE
}
I know it's too late to update.I had same issue on my project.
Possible Reasons
If you have added module in your project and that module has support libraries or any google play services libs which has different version then your app.
If you are using any open source library in your project and that library internally using any of libraries that your are also using in your project.
Solutions
If it is case 1 in your project then update your library versions and make it same in your project and module.
Check your dependencies tree using below command and see if any mismatch in dependencies.
./gradlew :app:dependencies
You can exclude particular module from any dependencies like below.
implementation('com.google.android.ads.consent:consent-library:1.0.4') {
transitive = true
exclude group: "com.android.support"
}
In above example, It will exclude the com.android.support group from consent-library dependencies.
You can also remove particular module as well.
compile ('junit:junit:4.12'){
exclude group: 'org.hamcrest', module:'hamcrest-core'
}
In above example it will exclude hamcrest-core from org.hamcrest.
I got the same problem, adding sourceCompatibility and targetCompatibility to my build.gradle helped me:
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
I was having a fit with this, and none of the answers I found worked. Finally found a solution -- sharing it here although I can't tell you definitively how to find which is the offending dependency -- maybe you'll have to do some trial and error.
In my build.gradle (Module:app) I added this exclude clause:
compile ('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2')
{ exclude module: 'support-v4' }
I did exact as the hint in the image except changed 11.0.4 to 11.8.0
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services:11.8.0'
I think it was due to Android Studio's latest version (at that time).
I tried it after a long time then the issue gone.
while creating Flutter Project, I encountered this issue. What I did is, opened MyProject/android/app/build.gradle file and added multiDexEnabled true inside defaultConfig tag as given below:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "Your Application ID Here"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
When the same issue appeared, my build.gradle already had the following was already there:
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
...
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
I cleaned the project, and then run build again, and the issue was gone.
in my case i change all com.android.support: libraries to 27.1.0 and it works

Gradle Build Run error (DebugUtils.class) in Android Studio 1.5

I'm getting the following error
Error:Execution failed for task
:app:transformClassesWithJarMergingForDebug.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/util/DebugUtils.class
I searched the entire day but couldn't found a proper answer which will solve my problem.
My app bulid gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.project.test"
multiDexEnabled true
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// depend files
dependencies
{
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-ads:+'
compile 'com.google.android.gms:play-services-identity:+'
compile 'com.google.android.gms:play-services-gcm:+'
compile files('libs/android-support-v4.jar')
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
}
I tried Clean and Rebuild, but that also not working.
Please help on this. Thanks in advance.
This issue happens when you add the same class twice.
In your project you are adding many times the support-v4 library.
remove android-support-v4.jar from libs folder
remove this line compile files('libs/android-support-v4.jar')
change the dependency of the library 'com.github.JakeWharton:ViewPagerIndicator:2.4.1' because it uses an old support-v4.jar
Use:
compile ('com.github.JakeWharton:ViewPagerIndicator:2.4.1') {
exclude module: 'support-v4'
}
After doing some research it seams that com.github.JakeWharton:ViewPagerIndicator:2.4.1 is already importing the android-support-v4.jar, from here your duplicate error. In order to fix it I recommend you to do the following changes:
remove android-support-v4.jar from libs folder
remove from gradle file the line compile files('libs/android-support-v4.jar').
Hope it fixes your problem.

NoClassDefFoundError: com.parse.ParseRequest. Android Parse Exception

I have create one sample app using parse.com jar. In this project Buid version SDK was 22(it was running fine). But after change it with 23 I am facing some issues in compiling app. I have tried to clean project, Invalidate caches. Rebuild project etc but I faced same issue error is:FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.parse.ParseRequest
at com.parse.Parse.initialize(Parse.java:184) I can't get find exact solution. I have checked libs folder have jar. I have also tried with latest gradle code but faced same error. After removing parse jar I can compile my project. My dependencies are
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/org.apache.http.legacy.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile project(':MaterialShowcaseView')
compile files('libs/Parse-1.9.2.jar')
compile files('libs/bolts-android-1.2.0.jar')
compile files('libs/universal-image-loader-1.9.4.jar')
}
If I Change this dependencies with compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.12.0' then error is different. Error is:java.lang.NoClassDefFoundError: com.parse.ParsePlugins$1
at com.parse.ParsePlugins.restClient(ParsePlugins.java:92)
at com.parse.Parse.initializeParseHttpClientsWithParseNetworkInterceptors(Parse.java:762)
at com.parse.Parse.initialize(Parse.java:365)
at com.parse.Parse.initialize(Parse.java:344)
Please suggest me, what is wrong with this dependency. Thanks in advance
Issue is not because of parse class.In error you get that error because of mulitdex not handled & Initilization of parse is on app start up thats why it will give class not found error.
add below lines to build.gradle to handle multi dex
To resolve issue what i give in my build.gradle
dexOptions {
incremental true
// here heap size give 4g i got this thing from https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
javaMaxHeapSize "4g"
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
// your dependencies which you are using.
}
Entire build.gradle
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
configurations {
// all*.exclude group: 'com.android.support', module: 'recyclerview-v7'
}
android {
signingConfigs {
/*
releasebuild {
keyAlias 'hellotest'
keyPassword 'hellotest'
storeFile file('path to keystore')
storePassword 'hellotest'
}
*/
}
compileSdkVersion 'Google Inc.:Google APIs:22'
buildToolsVersion '23.0.0'
/* if you got error regarding duplicate file of META-INF/LICENSE.txt from jar file
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
*/
dexOptions {
jumboMode = true
incremental true
// here heap size give 4g i got this thing from https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
javaMaxHeapSize "4g"
}
defaultConfig {
multiDexEnabled true
applicationId "com.myapp.packagenme"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releasebuild
}
debug {
signingConfig signingConfigs.releasebuild
}
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
// your dependencies which you are using.
}
With the help of android developer multidex guide MultiDexApplication class
To install MultiDex.install i refer android developer link
public class MyAppClass extends MultiDexApplication{
#Override
protected void attachBaseContext(Context newBase) {
MultiDex.install(newBase);
super.attachBaseContext(newBase);
}
}
Suggestion
Selectively compiling APIs into your executable
Don't use entire google play service use only required library.From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.4.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
Let me know if anything.

Provided dependencies can only be jars

I have an android projct in Android Studio, was all previously working the last time I used it, however, I've upgraded Android Studio and now I am getting a weird problem.
In the error output in Android Studio I have the following:
Warning: Project MyApp: provided dependencies can only be jars. com.google.android.gms:play-services.6.5.87 is an Android Library
Warning: Project MyApp: provided dependencies can only be jars. com.MyCompany.MyLibrary:aar:1.0 is an Android Library.
Below is my build.gradle file.
apply plugin: 'android'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
//applicationId "com.MyCompany.MyApp"
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
}
}
repositories {
mavenLocal()
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.MyCompany:CritiMon:1.0'
compile 'com.MyCompany:Library:1.1'
provided 'com.MyCompany:MyLibrary:1.0'
compile 'com.MyCompany:NavigationDrawerManager:2.1'
provided 'com.google.android.gms:play-services:+'
compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
}
Your provided dependencies can only be jars, your custom Android Libraries in your project should be compile at build time.
Change this:
provided 'com.MyCompany:MyLibrary:1.0'
provided 'com.google.android.gms:play-services:+'
to
compile 'com.MyCompany:MyLibrary:1.0'
compile 'com.google.android.gms:play-services:+'
I restore the Android Plugin Version from 1.1.0 to 1.0.0 and it work.
You can do it by the order:
Right-click your project.
Select `Open Module Settings`
Select `Project`
Change the `Android Plugin Version`

Categories

Resources