Execution failed for task ':app:processDebugResources'. Gradle Build Failed - android

Facing Errors on my Gradle build in Android Studio. Where do I need to change the code to fix the issue?
This is my project build.gradle
buildscript {
repositories {
jcenter{ url "http://jcenter.bintray.com/"}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
this is my app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.atmajaa.adda"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
resConfigs "auto"
manifestPlaceholders = [onesignal_app_id : "01bab543-cce8-4e36-a755-6bc23fd66b7c",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
multiDexEnabled true
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.mikepenz:fastadapter:2.6.3#aar') {
transitive = true
}
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:cardview-v7:26.0.2'
implementation 'com.android.support:support-v4:26.0.2'
implementation 'com.android.support:animated-vector-drawable:26.0.2'
implementation 'com.android.support:design:26.0.2'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.synnapps:carouselview:0.1.4'
implementation 'com.mikepenz:fastadapter-commons:2.6.3#aar'
implementation 'com.mikepenz:fastadapter-extensions:2.6.3#aar'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'org.jsoup:jsoup:1.10.3'
implementation 'com.thefinestartist:finestwebview:1.2.7'
implementation 'com.github.chrisbanes:PhotoView:1.3.1'
implementation 'com.fnp:material-preferences:0.1.4'
implementation 'com.thebluealliance:spectrum:0.7.1'
implementation 'com.firebaseui:firebase-ui-auth:2.3.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-invites:17.0.0'
implementation 'com.google.firebase:firebase-ads:18.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.onesignal:OneSignal:3.10.9'
implementation 'com.android.support:multidex:1.0.3'
// Required only if Facebook login support is required
implementation('com.facebook.android:facebook-android-sdk:4.22.1')
// Required only if Twitter login support is required
implementation("com.twitter.sdk.android:twitter-core:3.0.0#aar") { transitive = true }
}
apply plugin: 'com.google.gms.google-services'
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
Android resource linking failed
error: invalid config 'auto' for -c option.

In your App-level build.gradle, I can see you've used resConfigs "auto" :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.atmajaa.adda"
minSdkVersion 16
targetSdkVersion 26
...
resConfigs "auto"
...
}
}
Use the following code instead of auto, as mentioned in this documentation reference link and define/limit your language resources to whichever languages you prefer:
android {
defaultConfig {
...
resConfigs "en"
}
}

Now getting error on this line:

Related

Execution failed task ':app:kaptGenerateStubsDebugKotlin'

When I want to run the app, I get the following Build output:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all files for configuration ':app:kapt'.
> Could not find com.android.databinding:compiler:4.2.1.
I searched it already up on stackoverflow but it didn't help. I am stuck on this issue for 2 days now and it's driving me nuts :/
My project build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.10"
ext.version_navigation = "2.3.0"
ext.version_core = "1.3.1"
ext.version_constraint_layout = "2.0.0-rc1"
ext.version_lifecycle_extensions = "2.2.0"
ext.version_material = "1.2.0"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Navigation
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$version_navigation"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My module build.gradle file:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'androidx.navigation.safeargs'
id 'kotlin-kapt'
}
android {
buildFeatures {
dataBinding = true
viewBinding = true
}
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.commentapp"
minSdkVersion 27
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Navigation
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
kapt "com.android.databinding:compiler:4.2.1"
}
I hope you can help me with that. Write me if you need more information on my project (e.g. fragment file or something like that).
you dont need to put
kapt "com.android.databinding:compiler:4.2.1"
only need enable data binding in the gradle, and you did this
documentation: https://developer.android.com/jetpack/androidx/releases/databinding

Error com.android.dex.DexException: Multiple dex files define Lcom/google/android/libraries/places/internal/dh;

I got this Error:
Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/libraries/places/internal/dh;
I tried cleaning and rebuilding the project, but it didn't work. Any help will be appreciated.
Android Studio 3.0.1
Project level build.gradle
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
maven { url 'https://jitpack.io'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "in.mycrony"
minSdkVersion 16
targetSdkVersion 27
versionCode 86
versionName "2.86"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.github.barteksc:android-pdf-viewer:2.0.3'
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.4.1'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.squareup.picasso:picasso:2.5.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
implementation 'com.squareup.okhttp3:okhttp:3.7.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation 'com.google.android.libraries.places:places:1.1.0'
implementation project(':library')
}
apply plugin: 'com.google.gms.google-services'
Library level build.gradle
apply plugin: 'com.android.library'
apply from: "quality.gradle"
group = 'com.github.eggheadgames'
android {
compileSdkVersion 27
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 13
versionName "1.5.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
warningsAsErrors true
disable 'OldTargetApi'
disable 'GradleDependency'
}
}
dependencies {
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation 'org.json:json:20160212'
implementation 'com.android.support:appcompat-v7:27.1.1'
}
I have tried all the answers given but I am unable to solve this error.
Cause: com.android.dex.DexException: Multiple dex files define
Lcom/google
You should use one of them
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
implementation 'com.google.android.libraries.places:places:1.1.0' //Remove
Then Clean-Rebuild-Run.
Finally, I just used implementation 'com.google.android.libraries.places:places:1.0.0' for Place Autocomplete and used the same old 'com.google.android.gms:play-services' dependency for Place Picker.

Dex Error while building the project

I am getting the following error when I try to build my project. This error occurs when I was trying to add JavaMail api in my project.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.persi.eatery"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/mailcap.default'
exclude 'META-INF/mimetypes.default'
}
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.sun.mail:android-mail:1.6.1'
implementation 'com.sun.mail:android-activation:1.6.1'
implementation project(':library')
}
apply plugin: 'com.google.gms.google-services'
My library gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
P.S I have already tried Clean project followed by rebuild project as suggested in other answers but its still not working.Thanks in advance
Unable to merge dex
You have a dependencies conflict. Try to see your dependencies via command ./gradlew app:dependencies (Details here ). And you will see the next situation:
As you can see android-mail depends on android-activation. I think you don't need to use the line implementation 'com.sun.mail:android-activation:1.6.1'
P.S. For debugging builds you can use the next flag "--stacktrace". Then you can see more information about your issue.

Error while setting up Instant Apps

I'm trying to implement Android Instant Apps Support to my app and I've followed this tutorial:
http://androidkt.com/instant-app/
Everything was going perfect and I've successfully completed the tutorial.
But, I faced this error:
Error:FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':appapk:preDebugBuild'. > Android dependency 'com.android.support:support-v4' has different
version for the compile (25.2.0) and runtime (27.0.1) classpath. You
should manually set the same version via DependencyResolution
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
My project targets the latest version of Android (Android 8.1 API 27) and because of this, all versions should be 27 and above.
I think that this error is because of com.android.support:support-v4 is version 25.2.0 but when I searched my whole project, I was not able to find that com.android.support:support-v4 or any file that is 25.2.0.
Here are my gradle files if necessary:
build.gradle (Project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
maven { url 'https://jitpack.io' }
}
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (module: app-base):
apply plugin: 'com.android.feature'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
baseFeature = true
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
multiDexEnabled true
versionCode 3
versionName "2.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
implementation 'com.android.support:support-v4:27.0.1'
implementation 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 'android-support-v7-appcompat:25.0.1'
implementation 'com.github.HITGIF:TextFieldBoxes:1.3.8'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-ads:11.8.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.android.support:design:24.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:cardview-v7:24.2.1'
implementation 'com.android.support:customtabs:27.0.2'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (module: appapk):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "tr.k12.evrim.evrimnews.app"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':app-base')
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
build.gradle (module: instantapp):
apply plugin: 'com.android.instantapp'
android {
buildToolsVersion "26.0.2"
}
dependencies {
implementation project(':app-base')
}
With reference to google issue Tracker we were able to reproduce the issue in app with the same setup as in your build.gradle files.
The app can be successfully compiled when changing the com.android.support:support-v4 dependency in base from implementation to api and updating com.android.support:appcompat-v7:27.0.1 to 27.0.2.
The difference between implementation and api is that
implementation does not expose the dependency to other modules that depend on it, including libraries that need to be sync’d to the higher version (in this case, 25.x.x to 27).
While api dependencies will be exposed to all consumers of the library.

Unable to merge dex - gradle 3.0.0

I'm new to Android and I'm trying to work though this tutorial (just the Room database part): here.
When I execute my app I get the following error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This issue seemed to show up after I followed this to fix another error (regarding the schema export directory for Room). I've tried to follow this post's advice about fixing this issue by using multiDexEnabled true and doing clean/re-build but it hasn't worked.
Any advice would be appreciated. This is my first post here so if I've done anything wrong please let me know.
Project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
buildToolsVersion = "25.0.2"
supportLibVersion = "25.3.1"
archRoomVersion = "1.0.0-alpha1"
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' } //needed for Room
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.myname.room_example"
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()] // Room schema
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:multidex:1.0.2'
implementation "android.arch.persistence.room:runtime:1.0.0-alpha1"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha1"
implementation 'com.android.support:support-annotations:27.0.0'
}
Update buildToolsVersion and supportLibVersion to the latest in your code below.
ext {
buildToolsVersion = "25.0.2"
supportLibVersion = "25.3.1"
archRoomVersion = "1.0.0-alpha1"
}
And then Clean and Rebuild Project to see if it works.
I found a solution. Replacing:
"android.arch.persistence.room:runtime:1.0.0-alpha1"
and
"android.arch.persistence.room:compiler:1.0.0-alpha1"
with
"android.arch.persistence.room:runtime:1.0.0"
and
"android.arch.persistence.room:compiler:1.0.0"

Categories

Resources