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.
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.
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.
I am importing eclipse project, and project has some libraries like googleplay service, google uri auth and parse. Now I am importing an eclipse project in android studio but I am facing an error. I had tried cleaning the project and all the things that is required but I didn't get the reply. Below is my error:
Error:Execution failed for task ':weddinhHall:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'C:\Program Files (x86)\Java\jdk1.7.0\bin\java.exe'' finished with
non-zero exit value 2
and my build.gradle file is like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.xxx.xxxxxx.main"
minSdkVersion 14
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':parallaxScroll')
compile project(':googleDateTimePickers')
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-api-client-1.10.3-beta.jar')
compile files('libs/google-http-client-1.10.3-beta.jar')
compile files('libs/google-oauth-client-1.10.1-beta.jar')
compile files('libs/google-play-services.jar')
compile files('libs/Parse-1.5.0.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
}
Has anyone met this issue before?
Please remove compile files('libs/google-play-services.jar') . dexDebug occurs when duplicate entry happen . You already initialize google play service compile 'com.google.android.gms:play-services:+'.
FYI: Please use latest google play service version , like compile 'com.google.android.gms:play-services:5.0.89'
I've been developing this small project for some days now but suddenly today, Android Studio started to give me this error
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 14 declared in library com.android.support:support-v4:21.0.0-rc1
I understood that it is because it's trying to compile the library of Android-L. The version I want it to compile is the old version but it won't. It keeps giving me the above error no matter which version I enter. Here is the dependencies.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.android.support:support-v4:20.+'
}
UPDATE
I just installed Android Studio Beta and changed my dependencies to the one Eugen suggested below. But syncing the project gives the same error no matter which version of appcompat, support version I specify. It gives this error every single time I sync
uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
My updated dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.android.support:support-v4:19.+'
}
UPDATE 2
I don't think I understand the dependencies system of Android Studio correctly. I just removed both the appcompat and support from the dependencies and it still gives me the same error. Do I have to remove the initially included libraries from somewhere?
build.gradle
*note - I added those two libraries back in again and tried syncing, just in case. But no chenges.
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "taz.starz.footynews"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.android.support:support-v4:19.+'
compile project(':ParallaxScroll')
compile files('src/main/libs/Header2ActionBar-0.2.1.jar')
compile 'com.arasthel:gnavdrawer-library:+'
compile 'com.koushikdutta.ion:ion:1.2.4'
}
Top level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
UPDATE: Found the real fix for my case. Make sure none of your dependencies are silently including support-v4 r21 by doing this in your build.gradle:
compile("com.blahblah:blah:123") {
exclude group: 'com.android.support', module:'support-v4'
}
You can add the exclude to all libraries, then remove one-by-one until you figure out which one was pulling in support-v4 and giving you the error. And leave exclude on that one.
There is a new bug filed here: https://code.google.com/p/android/issues/detail?id=72430
Assuming you are using the Support Repository, the workaround is to comment or remove the line
<version>21.0.0-rc1</version>
in the local Maven repo listing file at <android-sdk>/extras/android/m2repository/com/android/support-v4/maven-metadata.xml
With the last updates, using this:
compile 'com.android.support:support-v4:20.+'
or
compile 'com.android.support:support-v4:+'
you are using the support lib in L-preview.
These support libs are declaring minSdkVersion L.
You have to force the minSdkVersion to be 'L' (check the doc)
This is because these APIs are not final. It is a way to prevent installing the apps on a final API 21 device or publishing it on the store using support lib 21-r1.
Using
compile 'com.android.support:support-v4:19.1.0'
you are using the "old" support library 19.1.0.
I had the same issue as one of my dependencies had specified 'support-v7:+' as a dependency. I was able to track this down using gradle dependencies
Gradle provides a way to force resolution to a specific version. I ended up having this in my build.grade:
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
compile('com.android.support:support-v4:19.1.0'){
force = true
}
This worked for me
That is correct. The new support library is not compatible (yet) with old Android versions.
Change your gradle to:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.1.+'
compile 'com.android.support:support-v4:19.1.+'
}
I hope your still have something like this:
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
I was getting the error:
Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 4 declared in library
C:\Users\Igor\AppData\Local\Android\sdk\samples\android-21_1\legacy\ApiDemos\app\build\intermediates\exploded-aar\com.android.support\support-v4\21.0.3\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v4" to force
usage
Then I resolved it by putting the following in my defaultConfig gradle block:
minSdkVersion 15
targetSdkVersion 21
In Android SDK Manager install "Android Support Repository" from "extra" group. It helps me. When I added "exclude group: 'com.android.support', module:'support-v4'" build was completed, but some other errors was occured