i am having a strange issue which stops me from developing further my app.
I need to make an UI with a Viewpager and some tabs (TabLayout) and in order to achieve this i need to compile android design and appcompat libraries.
But here's the problem, it keeps telling me that "ColorAccent" is already defined with an incompatible format.
I have tried everything i could to repair but it seems like it won't work. Had anyone solved this ? Please help!
here's my error log:
~ my path at MyApp's directory app\build\intermediates\res\merged\debug\values\values.xml
Error:(148) Attribute "colorAccent" already defined with incompatible
format.
Error:(3) Original attribute defined here.
Error:(148) Attribute "colorAccent" already defined with incompatible
format.
Error:(3) Original attribute defined here.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
EDIT: Here's my build code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "tap.myapp"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:support-v4:24.2.1'
compile 'com.journeyapps:zxing-android-embedded:3.0.2#aar'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.volley:volley:1.0.0'
compile "com.android.support:support-v4:24.2.1"
compile "com.android.support:appcompat-v7:24.2.1"
compile "com.android.support:support-annotations:24.2.1"
compile 'com.google.zxing:core:3.2.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
testCompile 'junit:junit:4.12'
}
FIXED: what i was doing wrong is that i declared a colorAccent variable inside my attributes xml (attrs.xml), so the gradle couldn't compile the library due to a possible duplicate of that specific value (color Accent). Removing that value fixed what i was doing wrong for hours.
Related
I'm working on my very first android application which is almost complete now and ready to post on play store. But I'm unable to make the APK file :(
I'm using Android Studio 3.0.1
gradle-4.1
When I tried to make the APK file I got the error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
which was quickly resolved by adding multiDexEnabled true to
app/build.gradle
file. But after adding this I'm now getting another error:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [D:\My Data\Android\1stApplicationTest\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\USER_NAME\.gradle\caches\transforms-1\files-1.1\support-media-compat-26.0.2.aar\d7c069de85684fc017734fd1ac5ba973\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/media/VolumeProviderCompat.class]))
I'm unable to resolve this issue I tried number of solutions
updated all the jars version as per build/sdk version of the application
Removed duplicate/extra dependencies, if any
Removed Build folders from root and inside of app folder
In Android Studio File -> Invalidate Caches/Restart
Restarted Android studio with the clean build, also removed extra jars in .idea folder
Please advise if i need to remvoe something from the SDK: C:\Users\USER_NAME\AppData\Local\Android\sdk
Here is app/build.gradle file of my application
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'Shah.Jee'
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.0.2'
/*
compile files('libs/android-support-v4.jar')
compile 'com.android.support:support-v4:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.2'*/
compile 'commons-lang:commons-lang:2.6'
compile 'com.github.bumptech.glide:glide:4.2.0'
compile 'com.google.android.exoplayer:exoplayer:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-dash:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-hls:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-ui:r2.4.0'
testCompile 'junit:junit:4.12'
compile project(':picasso-2.5.2')
}
Need a quick advise if I'm missing something. Thanks in advance.
Here my build.gradle:
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.mycompany"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
debuggable false
signingConfig signingConfigs.config
minifyEnabled true
zipAlignEnabled true
proguardFile 'proguard-rules.pro'
}
debug {
debuggable true
signingConfig signingConfigs.config
}
}
}
dependencies {
compile 'com.facebook.android:facebook-android-sdk:3+'
compile 'com.android.support:support-v4:+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:+'
compile 'com.github.codechimp-org.apprater:library:1.0.+'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile files('libs/disklrucache-2.0.2.jar')
compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/socialauth-4.2.jar')
compile files('libs/socialauth-android.jar')
}
I can compile my source code without problem but get the following error message when I try to run:
/Users/myname/Projects/myproject/build/intermediates/res/merged/release/values-v23/values-v23.xml
Error:(4) Error retrieving parent for item: No resource found that
matches the given name
'android:TextAppearance.Material.Widget.Button.Inverse'. Error:(34)
Error retrieving parent for item: No resource found that matches the
given name 'android:Widget.Material.Button.Colored'. Error:Execution
failed for task ':project:processReleaseResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'/Users/myname/.android-sdk/build-tools/21.1.2/aapt'' finished with
non-zero exit value 1
I really don't understand. My compiledSdkVersion and targetSdkVersion is 21 and I even don't have a file called values-v23. Why got this error? Can anybody help? Thanks.
Edit 1:
#Gabriele Mariotti's answer solved this problem. But here comes another problem.
Error:Execution failed for task '::transformResourcesWithMergeJavaResForRelease'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/org.brickred/socialauth/pom.properties
File1: /Users/xxxxxx/libs/socialauth-4.2.jar
File2: /Users/xxxxxx/libs/socialauth-4.2.jar
What could be the reason? I checkd there is of course only one socialauth-4.2.jar in my libs folder.
Since you are using
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:+'
you are using the latest versions which has a dependency with support libraries v24.
You have to use compileSdkVersion 24
In general it is not a good idea to use this kind of dependencies (+) because you will not be able to reproduce the build in the future (since the dependencies will change)
You have a resource file which is specifically targeted to API 23. You can either remove this file or change compileSdkVersion to 23. The later is preferable since your app will still be able to run on devices with versions of Android prior to level 23.
when I was trying to run a simple program , I got an error related to Gradle :
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration':app:_debugUnitTestCompile'.
> Could not resolve junit:junit:4.12.
Required by:
MyApplication:app:unspecified
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'htps://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Connection to htps://jcenter.bintray.com refused .
I don't know how can I fix it , please help .( I am currently using the android studio version 2.1.2 )
my module build-gradle includes these codes:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.n5110.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
}
The problematic part with your gralde.build is this line:
testCompile 'junit:junit:4.12'
This is a unit testing library. If you are just starting and are probably not gonna write testcases for your project then, you can resolve the issue by simply deleting the line. If however you essentially need that library then refer here.
I am getting this error when I try to build my project.
Error:(3, 5) No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Home\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1
And when I click on it it takes me to the v-23 values file of generated folder which contains following code.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CardView" parent="Base.CardView">
<item name="cardBackgroundColor">?android:attr/colorBackgroundFloating</item>
</style>
</resources>
This is my app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.xxxx"
minSdkVersion 19
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.commit451:inkpageindicator:1.0.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'ch.acra:acra:4.5.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.google.code.gson:gson:2.6.2'
}
And when I change everything in gradle to version 23 this error goes away but as I am using http libraries and they are removed from 23 version therefore I am forced to use 22 version. My project was working perfectly fine before and at a sudden it started giving this error. Only thing I done was install a support repository which I was using in other project and it start giving error in this project too.
Any way to resolve this error?
compile 'com.facebook.android:facebook-android-sdk:4.+'
needs V-23
In my case I use v-22 so
i changed Facebook sdk version to 4.8
compile 'com.facebook.android:facebook-android-sdk:4.8.0'
That error makes perfect sense, seeing as ?android:attr/colorBackgroundFloating
was only added in API 23 and you are using compileSdkVersion 22.
So, to fix the error, you need compileSdkVersion 23 to include that resource in your build. Also, having a v23 values file doesn't make sense when you have targetSdkVersion 22, which says you aren't targeting v23 devices anyways.
And you mentioned the "http libraries" you are using are gone? If you are referring to HttpClient from the org.apache package, then you can add it back by including this in your build.grade
android {
useLibrary 'org.apache.http.legacy'
}
if you dont want to upgrade your modules,in addition solution is excluding modules in build.gradle with compile tag
compile( 'com.facebook.android:facebook-android-sdk:4.11.0')
{
exclude module: 'cardview-v7'
}
Sorry if I asked a duplicate question, but I couldn't find a solution for this error. I surfed around stackoverflow,gradle site, android blogs, google search but there wasn't a working solution for several hours. I'm an android beginner so I not sure if I have missed something in other posts.
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1.'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
compile 'com.android.support:recyclerview-v7:22.2.1.'
compile 'com.android.support:cardview-v7:22.2.1.'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile files('libs/android-support-v4-22.2.1.jar')
compile files('libs/applovin-sdk-6.0.1.jar')
compile files('libs/appodeal-1.13.1.jar')
compile files('libs/chartboost-5.2.0.jar')
compile files('libs/my-target-4.0.13.jar')
compile files('libs/unity-ads-1.4.7.jar')
}
The project was working fine until I add some libs from appodeal (those compile file lines). I have tried to build the project but gradle gave the errors.
:app:transformClassesWithJarMergingForDebug'.
com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v7/widget/RecyclerView$ItemDecoration.class
There are also 2 more error of the same exception about duplicate entry- not sure why I got them: android/support/v4/PrintKitKat.class and android/support/multidex/MultiDex$V14.class.
I tried to upgrade gradle, invalidate and restart to clear cache, omit dependencies then rebuild/clean project, find potential duplicate module to exclude, and search projects for those .class but I found no duplication.
You can test putting this on root of directory in the Terminal
./gradlew clean