Gradle Error:Execution failed for task ':app:processDebugGoogleServices' - android

I am following this link to integrate Google sign-in in my android app.https://developers.google.com/identity/sign-in/android/start-integrating
As given in last step on the above given page we have to include dependency
compile 'com.google.android.gms:play-services-auth:8.3.0'
in app-level build.gradle file but doing so and building project an error comes saying
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.brainbreaker.socialbuttons"
minSdkVersion 16
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.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services-auth:8.3.0'
}
In the build.gradle file the compile dependency line compile 'com.google.android.gms:play-services-auth:8.3.0' shows error
All com.google.android.gms libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 8.3.0, 8.1.0. Examples include
com.google.android.gms:play-services-base:8.3.0 and
com.google.android.gms:play-services-measurement:8.1.0 There are some
combinations of libraries, or tools and libraries, that are
incompatible, or can lead to bugs. One such incompatibility is
compiling with a version of the Android support libraries that is not
the latest version (or in particular, a version lower than your
targetSdkVersion.)
Here are the messages of gradle build.
Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :social_buttons:generateDebugSources, :social_buttons:generateDebugAndroidTestSources, :social_buttons:compileDebugSources, :social_buttons:compileDebugAndroidTestSources]
:clean UP-TO-DATE
:app:clean
:social_buttons:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library
:app:prepareComAndroidSupportDesign2301Library
:app:prepareComAndroidSupportSupportV42301Library
:app:prepareComGoogleAndroidGmsPlayServicesAds810Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth830Library
:app:prepareComGoogleAndroidGmsPlayServicesBase830Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement830Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
:app:processDebugGoogleServices FAILED
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
Information:BUILD FAILED
Information:Total time: 3.49 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
I am not able to see any way out for this version conflict. Any help is appreciated.

I'v got a same issue. but Now I'm fixed.
You should delete a line apply plugin: 'com.google.gms.google-services'
because "com.android.application" package already has same package.

I had the same issue and resolved it by adding the following line in the dependencies of the project-level build.gradle:
classpath 'com.google.gms:google-services:3.0.0'
For a full working example, check out the following project on github.
Hope this helps :)

I was finding the same error complaining about mixing google play services version when switching from 8.3 to 8.4. Bizarrely I saw reference to the app-measurement lib which I wasn't using.
I thought maybe one of my app's dependencies was referencing the older version so I ran ./gradlew app:dependencies to find the offending library (non were).
But at the top of task output I found a error message saying that the google plugin could not be found and defaulting to google play services 8.3. I used the sample project #TheYann linked to compare. My setup was identical except I applied the apply plugin: 'com.google.gms.google-services' at the top my app's build.gradle file. I moved to bottom of the file and that fixed the gradle compile error.

I also faced the same issue. But I forgot to add google-services.json in my project. You can get this file from Google.

Ensure that you have done these two things under defaultConfig in Android/app/build.gradle after wiring up Firebase for your Flutter app.
1) Whatever package name you entered while creating your Firebase android project, exactly the same should be updated as your applicationId under defaultConfig.
2) Add the line multiDexEnabled true under defaultConfig.
So defaultConfig{} should now look something like this
defaultConfig {
applicationId "com.companyName.appName"
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

I've solved this problem by deleting the google-services.json file and downloading it again from Firebase console.

Had the same problem
i added compile 'com.google.android.gms:play-services-measurement:8.4.0'
and deleted apply plugin: 'com.google.gms.google-services'
I was using classpath 'com.google.gms:google-services:2.0.0-alpha6' in the build project.

In my case when i was using firebase services the google.json file was mismatched check once that also

Important note: You should only apply plugin at bottom of build.gradle (App level)
apply plugin: 'com.google.gms.google-services'
I mistakenly apply this plugin at top of the build.gradle. So I get error.
One more tips : You no need to remove even you use the 3.1.0 or above. Because google not officially announced
classpath 'com.google.gms:google-services:3.1.0'

I just had to delete and reinstall my google-services.json and then restart Android Studio.

If you trying to connect to firebase, check if your app package name is the same as what is in google-services JSON file.
"client": [
{
"client_info": {
"mobilesdk_app_id": "......",
"android_client_info": {
"package_name": "com.something.package"
}
}, ...
thanks and good luck.

had the same issue as described by #scottyab.
all references were 8.4.0 but it failed due to a reference to app-measurement 8.3.0 that i did not reference anywhere (but one of the dependencies?).
you can see the problem if you hover over the bad(red) dependency in Android Studio.
explicitly adding
compile 'com.google.android.gms:play-services-measurement:8.4.0'
to app.gradle solved the issue.

Also please check your package name in Manifest and package name in google services json file. If both have package name differ from one another u will have this issue.

I fixed it without deleting apply plugin: 'com.google.gms.google-services'
I had the error Execution failed for task ':app:processDebugGoogleServices' because I was using two different versions of google services in my dependencies :
implementation "com.google.android.gms:play-services-maps:11.8.0"
implementation "com.google.android.gms:play-services-nearby:16.0.0"
I changed it to :
implementation "com.google.android.gms:play-services-maps:11.8.0"
implementation "com.google.android.gms:play-services-nearby:11.8.0"
Then it worked

When you create an android application in firebase console you should set your application package in future it will be recorded to google-services.json.
So this error can happen when you try to add google services in the application which has a different package (Current application package will not match to which was recorded to google-services.json).

My package name, when creating an application in Firebase, had an underscore '_' in the name.
I mistakenly excluded the underscore. Changing the package name in firebase solved this issue for me.

I ran into the same issue, I followed the top three steps in this thread.
However, I later found that package_name should match with appID in the google-service.json file as well.
Do look at what your package_name says in google.service.json and match it with the actual app id.

If You are trying to solve this problem for firebase then use this....
Deleting the ** 'com.google.gms.google-services' ** is not the correct way, this problem occurs because of the name changes.
Need to give the same name in the format firebase package name == android package name (check it in /android/app/src/main/AndroidManifest.xml)
Just change the name as android package name then again download the google-services.json then paste it in the /android/app/ like this (/android/app/google-services.json) and run your npm eg. npx react-native run-android
It will work 100%.

I had a similar issue/error..
fixed it by moving
apply plugin: 'com.google.gms.google-services'
to the end of app level gradle file.
And updated the version of gms:play-services and gms:play-services auth

same issue i have.
i tired all possible solutions that i found.
but non were worked.
always got this error
Cannot add task ':processDebugGoogleServices' as a task with that name already exists
Now, i solved it.
1) first i checked my config.xml
2) and removed unnecessary plugin. (I used firebase fcm plugin for pushnotification, but there was two unnecessary plugin phonegap-plugin-push and cordova-plugin-customurlscheme. I removed both these plugins)
3) then removed platform.
4) then add platform
5) then build it.
6) now it build successfully.

Had the same problem with malformed error
Deleted the line apply plugin: 'com.google.gms.google-services'
And the build got successful

NEVER DELETE apply plugin: 'com.google.gms.google-services' from the gradle. Sometimes you are using com.google.gms:google-services:3.1.0 , without apply plugin: 'com.google.gms.google-services' your gradle build successfully. BUT IT IS COMPLETELY WRONG !!!! This error comes due to google-service.json file is not at the correct location. Go to your PROJECT TAB at left side above. If you display it as ANDROID make it PROJECT then check your google-service.json file is at this location. EXPAND app then see google-service.json file below the build.gradle. IF NOT PLACE IT THERE BY RIGHT CLICK ON THE app .

This error comes up when there is change in your config.xml file resulting in mismatching of the data present in google-services.json file.
I got it fixed this just by updating changes to my google-services.json file and building the app again ...it worked well.

If you´re building a new app, put the jsonfile in the right place and make sure it's the jsonfile for that app. Before I realized this, when I clicked the jsonfile, I didn't get the information that wanted.
Go to firebase configurations, download the correct version of google-services.json, and replace the version that didn't work for you. When using the wrong version, you might see the wrong Projectid, storagebucket etc.

check gradle.properties and add
android.useAndroidX=true or you can also add
android.enableJetifier=true or you can comment it by #
worked for me

if you got an error
Execution failed for task ‘:app:fabricGenerateResourcesDebug’.
Crashlytics Developer Tools error.
remove also this line:
apply plugin: 'io.fabric'

In my case i have multiple product flavors. It used to work earlier. It stopped working after updating project gradle version to 4.0.1 and 'google-services:4.3.4'.
I got error like 'Task :app:processDebugGoogleServices FAILED' when i run the project.
I replaced 'google-services.json' in app module with 'my-product-flavor/google-services.json'. It is working fine now.

None of the answers here helped. I needed to have "apply plugin: 'com.google.gms.google-services'" in my gradle. What helped was updating Android Studio to the latest version. I was then able to add the plugin and connect to Firebase Messaging Service.

What work for me is
add this in build.Gradle(Project)
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
}

Try adding FirebaseAuth even though you don't need it. Don't delete any plugins.
This worked for me. Thanks.

Related

Message "error: resource android:attr/lStar not found"

A Flutter Android app I developed suddenly compiled wrong today.
Error:
What went wrong:
Execution failed for task ':app:processDebugResources'.
Android resource linking failed
/Users/xxx/.gradle/caches/transforms-2/files-2.1/5d04bb4852dc27334fe36f129faf6500/res/values/values.xml:115:5-162:25: AAPT: error: resource android:attr/lStar not found.
error: failed linking references.
I tried
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
The build failed in 16 seconds.
Using the answer from here
Update compileSdkVersion and targetSdkVersion to 31
And add this code snippet in your android/build.gradle file at the very end.
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
}
}
Just recently the original author of audioplayers package fixed this issue in his recent PR. It has been fixed in audioplayers version 0.20.1, so if your issue is related to audioplayers, do upgrade.
For those who have this issue in a Cordova application context like me and using an Android API version older than 31 (29 in my case), I found a clean way to bypass it.
TL;DR
If you are using the plugin cordova.plugins.diagnostic, uninstall it first then reinstall it using the following argument:
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
Refresh the whole android platform and you're project should not be using the androidx.core:core:1.7.0-beta02 anymore.
Full explaination
Solutions already mentionned in the thread (gradle rules to force a certain version of a package) will not work with Cordova as it handles the whole gradle process on it's own (gathering plugins dependencies, config.xml settings and processing everything) and it's really difficult to override specific things.
I did not manage to fix our problem using resolutionStrategy for example.
And migrating to Android API 31 isn't always an easy solution (plugins & dependencies need to support it in particular)
Instead, I tried to find which of my installed plugins were having a dependency linked to the androidx.core:core package, which breaks everything in its 1.7.0-beta02 version.
No one in my list was directly using it, but I found (with the help of the builded build.gradle) that the following package androidx.appcompat:appcompat was used and since it's related to AndroidX as well, I digged a bit and I quickly found-out that the version used for it was 1.+ (latest 1.xx).
Checking on mavenrepo, androidx.appcompat:appcompat has our buggy package androidx.core:core as dependency (1.7.0-beta02 on the latest).
After a quick search with my IDE, I found the definition of the dependency :
<framework src="androidx.appcompat:appcompat:$ANDROIDX_VERSION" />
It was used by a plugin named cordova-diagnostic-plugin. (Pretty common in a Cordova project, it basically handles Android settings, permissions and hardware stuff)
I noticed that an environment variable was used to define the package version (and set by default to 1.+).
Going on the plugin's GitHub documentation : https://github.com/dpa99c/cordova-diagnostic-plugin#androidx-library will tell you that you can indeed set a custom version when installing the plugin with the Cordova command.
Which I did (I removed the plugin first):
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
After rebuilding the android platform, I started a new build and it was finally successful !
androidx.appcompat:appcompat:1.0.0 was used as well as the androidx.core:core package in its 1.0.0 version. No more error: resource android attr/lStar not found issue !
To sum-up : check your plugins dependencies and if possible, set static versions instead of "latest". In that way, you can (in most cases) avoid using alpha/beta releases, which could be instable or not supporting your current environment.
I did this for solving it in my Flutter application.
Open the android/app project
Search the text androidx.core:core-ktx:+ in all solutions. In most cases this is found in build.gradle file.
If you found this text in some dependency, change androidx.core:core-ktx:+ to androidx.core:core-ktx:1.6.0
Sync and run again
In my case, I had this problem with the audioplayers: ^0.17.3 dependency. The + sign was causing the error.
I received this error in Android Studio when I created a new Android application. The latest versions of BOTH appcompat and core-ktx in dependencies appear to be the issue.
Open build.gradle, and look in dependencies
Roll back appcompat to 1.3.0
Roll back core-ktx to 1.6.0
Tap "Sync Now" (should be in the top right)
dependencies {
...
//implementation 'androidx.appcompat:appcompat:1.4.0'
//implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.core:core-ktx:1.6.0'
...
}
Rerun your program and cross your fingers.
I got the same error
C:\Users\pc.gradle\caches\transforms-2\files-2.1\7a25962662620ee4f1493c07e779c7ef\core-1.7.0\res\values\values.xml:105:5-114:25: AAPT: error:
resource android:attr/lStar not found.
fix this issue by =
replacing compileSdkVersion 30 in build.gradle
to
compileSdkVersion 31
Are you using the #react-native-community/netinfo library? You need to refresh this library if you are using it.
After updating or uninstalling and reinstalling the netinfo library it will work.
The solution for this error may change according to the platform which we are using for building the application.
For Cordova,
Reinstall cordova.plugins.diagnostic plugin
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
For React Native,
Reinstall #react-native-community/netinfo library
For Android Studio,
Specify specific or stable version of android core dependency in build.gradle(app) file.
dependencies {
...
implementation "androidx.core:core-ktx:1.6.0"
}
Major source of this issue is appcompat library. As a quick fix to run your project you can use appcompat version below 1.4.0 that is you can switch to appcompat version
implementation 'androidx.appcompat:appcompat:1.3.0'
or below.
remove dynamic version in project dependencies in all build.gradle files
example:
"androidx.core:core-ktx:+"
remove + or ^ operator in dependencies { } and mention specific version or stable version
"androidx.core:core-ktx:1.6.0"
source : https://flutter.dev/docs/development/packages-and-plugins/using-packages
If you are using React Native and started experiencing this issue later than November 4th 2022, it could be related to the next known issue: https://github.com/facebook/react-native/issues/35210
In order to try if this is what's causing your issue, you can upgrade react-native to the corresponding patch version specified in that link.
Doing that fixed the "error: resource android:attr/lStar not found" issue and two other issues that started suddenly happening for us, so it might be worth a try!
I resolved this issue by changing these compileSdkVersion 31, targetSdkVersion 31 and classpath 'com.android.tools.build:gradle:4.0.2'
this issue appeared with me in flutter and solved it thanks to this answer
https://issuetracker.google.com/issues/199180389#comment2
just adding the following to the bottom of our app/build.gradle seemed to work for us while our compileSdkVersion and targetSdkVersion remained at 29:
configurations.all {
resolutionStrategy {
force 'androidx.core:core:1.6.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
Add the following to your Project build.gradle:
buildscript {
ext {
androidXCore = "1.6.0"
}
}
If anyone is facing the same issue in ionic cordova, remove these plugin
cordova-plugin-androidx
cordova-plugin-androidx-adapter
And also any plugins dependent on them.
I removed implementation androidx.core:core:1.7.0, the project did not depend on it, and now everything is OK.
Update the following code in your build.gradle(:app) file:
compileSdkVersion 31
targetSdkVersion 31
For Cordova
Uninstall cordova.plugins.diagnostic and cordova-plugin-androidx by running
cordova plugin remove cordova.plugins.diagnostic
cordova plugin remove cordova-plugin-androidx
I solved this problem by down grading my androidx.test.espresso:espresso-core from
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
to
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
All you have to do is go in build.gradle and erase the entire line:
implementation "androidx.core:core-ktx:+"
super easy
Update: This was also related to this for me
None of the other answers worked for me. As a last resort I watched a video in a foreign language and it worked for me. I was compiling to sdk 31
add this in the app build.gradle:
android {
...
configurations.all {
resolutionStrategy {
force 'androidx.appcompat:appcompat:1.3.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
}
dependencies {
implementation "androidx.core:core-ktx:1.6.0"
implementation "androidx.appcompat:appcompat:1.3.0"
}
I got the from Saurabh Kumar but it wasn't working in android/build.gradle for some reason.
configurations.all {
resolutionStrategy {
force 'androidx.appcompat:appcompat:1.3.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
Sorry I cannot comment as I just created an account. Thanks to Nitrix and Codemaker for the hints.
This is the complete list of commands in Ionic just to add to Codemaker's answer to get rid of the not found error
Android resource linking failed /Users/xxx/.gradle/caches/transforms-2/files-2.1/5d04bb4852dc27334fe36f129faf6500/res/values/values.xml:115:5-162:25: AAPT: error: resource android:attr/lStar not found.
npm uninstall cordova.plugins.diagnostic
rm -rf plugins/
rm -rf node_modules/
rm -rf package-lock.json
delete from package.json if diagnostic is still somewhere
npm install
ionic cordova platform rm android
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0 // This probably cause an error if Capacitor is used or even lately it also causes error with Cordova, so just use the command below
npm install cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
npm install #ionic-native/diagnostic
ionic cordova platform add android
ionic cordova build android
I hope that this will help a bit.
comment this line in build.gradle
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//implementation 'androidx.appcompat:appcompat:1.4.0'
that work's for me
I've had this happen a few times and it always happens when I upgrade my dependencies.
I solved this each time by updating the following items in my gradle files to the latest versions:
compileSdk
targetSdk
compileSdkVersion
buildToolsVersion
The buildToolsVersion has always been the one that has caused the problem.
when craete new project:
select Use legacy android.support librares
build.gradle (project)
buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.0.2' } }
build.gradle (:app)
android {
compileSdkVersion 31
defaultConfig {
minSdkVersion 23
targetSdkVersion 31
}
}
dependencies {
def core_version = "1.7.0"
// Java language implementation
implementation "androidx.core:core:$core_version"
// Kotlin
implementation "androidx.core:core-ktx:$core_version"
}
Keep the same configuration of the app module for the feature modules so as not to generate inconsistencies.
GL
I solved this problem by down grading my appcompat lib from
implementation 'androidx.appcompat:appcompat:1.4.1'
To
implementation 'androidx.appcompat:appcompat:1.1.0'
For someone still trying to fix this while all of the above does not help, forcing dependency projects to build on the same SDK worked for me:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion = 31
buildToolsVersion = "31.0.0"
}
}
}
}
see https://github.com/react-native-image-picker/react-native-image-picker/issues/882
My situation is a bit different, I'm using mavenPublisher and don't want to upgrade the sdk version, so I need to put the configuration in library/build.gradle, it works for me.
configurations.all {
resolutionStrategy {
force 'androidx.core:core:1.6.0'
force 'androidx.core:core-ktx:1.6.0'
}
}
One major cause for this issue is the Gradle version difference between an added library and the projects build Gradle. This can result to a resource being unavailable during build time.
Matching the gradle versions can be an easy fix (If the library is you creation).
Use this::
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
androidXCore = "1.6.0"
}
}

Build Error -Ionic Cordova fails for android [duplicate]

This question already has answers here:
Running "cordova build android" - unable to find attribute android:fontVariationSettings and android:ttcIndex
(26 answers)
Closed 4 years ago.
I get following error while running the command "ionic cordova build android --stacktrace" :
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
FAILED
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
I am using following tools on Window's:
Editor : VScode
Ionic: C:\Users\xyz>ionic -version
3.19.1
Npm as packagemanager
Project Properties:
target=android-26
cordova.system.library.1=com.google.android.gms:play-services-analytics:+
cordova.system.library.2=com.facebook.android:facebook-android-sdk:4.+
cordova.gradle.include.1=cordova-plugin-appsflyer-sdk/customerapp-cordovaAF.gradle
cordova.gradle.include.2=twitter-connect-plugin/customerapp-twitter.gradle
cordova.system.library.3=com.android.support:support-v4:26.+
cordova.system.library.4=com.android.support:appcompat-v7:26.+
cordova.system.library.5=com.android.support:support-v4:24.1.1+
cordova.system.library.6=com.android.support:support-v4:+
android.library.reference.1=CordovaLib
I had to do the stuff of both the answers above:
In platforms/android/phonegap-plugin-barcodescanner:
Search for compile 'com.android.support:support-v4:+ and replace for compile 'com.android.support:support-v4:27+'.
In platforms/android:
Search for cordova.system.library.2=com.android.support:support-v4:+ and replace for cordova.system.library.2=com.android.support:support-v4:27.1.0.
Hope it helps.
Mine required a similar fix as above only it was in the de.appplant.cordova.plugin.local-notification plugin. I changed ‘com.android.support:support-v4:+’ to ‘com.android.support:support-v4:23+’ and then removed and added the android platform and it built. However, I had an extra brace '}' in my build-extras.gradle that had to be removed also.
found this on the ionic forum https://forum.ionicframework.com/t/android-build-broken-after-gradle-dependencies-update-execution-failed-for-task-processdebugresources-com-android-ide-common-process-processexception-failed-to-execute-aapt/109982/134 the suggestion that worked for me was "I got it working, my issue was in the cordova-plugin-file-opener2. Change com.android.support:support-v4:+ to com.android.support:support-v4:23+ in the plugin.xml for the cordova-plugin-file-opener2 in the plugins folder and the node_modules folder. Then do the same in the project.properties in platforms/android. My plugin however was the background-geolocation and actually i dont believe i had to make a fix in the project.properties for mine.
In my case, problem was in barcode scanner plug in. Removing and adding this plug in did not work, after all get it worked by changing 'com.android.support:support-v4:+' to 'com.android.support:support-v4:27+' in file 'platform/android/phonegap-plugin-barcodescanner/{projectName}-barcodescanner'. What I did not understand is project was working yesterday perfectly, what happened in 24 hours and this problem occured...
Had the same issue, what I did was following:
Clear the build directory
cordova clean
Add multiDexEnabled under android -> defaultConfig to the build.gradle file
"your project\platforms\android\app\build.gradle"
multiDexEnabled true
Change dependencies for "com.android.support" within the build.gradle file
com.android.support:support-v4:+ => com.android.support:support-v4:23+
Go through the plugins folder and look in all "plugins.xml" and replace:
com.android.support:support-v4:+ => com.android.support:support-v4:23+
Change project.properties under "platforms\android\project.properties"
cordova.system.library.4=com.android.support:support-v4:23+
Run "ionic cordova run build"
Unable to merge dex
https://stackoverflow.com/a/46591042
https://stackoverflow.com/a/47746531
Clean install
https://stackoverflow.com/a/24684622
Wrong Namespace / Version
https://stackoverflow.com/a/49164846
.
android {
defaultConfig {
multiDexEnabled true
versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
applicationId privateHelpers.extractStringFromManifest("package")
if (cdvMinSdkVersion != null) {
minSdkVersion cdvMinSdkVersion
}
}
}
I did not find "com.android.support:support-v4:+" in the indicated paths of the topics I searched for, as I tried lastly in all folders and found in
platforms/android/phonegap-plugin-barcodescanner.gradle
in my case the plugin was the barcodescanner, in yours may be another.
then I followed the information and replaced with "'com.android.support:support-v4:27+" and it worked.
I was wondering if it was working perfectly yesterday, today I changed only one text and gave this error ... during the build I realized that some downloads occurred I believe that an update happened that caused this.
I was having the same problem out of the blue yesterday. It started randomly but from reading around, it looks like it is to do with an update as mentioned above by #cpro90. However, I tried and could not find where to make the necessary manual change.
Eventually I identified that the problem was being caused by my cordova-plugin-crosswalk-webview plugin. On Github, I found the issue on the plugin repro this morning and it had over 520 views by lunch.
#UNUMObile suggested the following in the build.gradle file to force an earlier version globally:
configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:24.0.0'
}
This worked immediately for me and may help others with other plugins that also have had their dependancy on 'com.android.support:support-4:<28. The new version 28 seems to be the issue.
Hope this helps someone move forward.
Replacing 'com.android.support:support-v4:+' and 'com.android.support:support-v4:27+' with fixed versions in the plugin.xml didn't work for us - cordova crosswalk updated at least one support library to version 28.0.0-alpha1 though.
Forcing a fixed version of the support library for each dependency could solve the problem in the end.
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.android.support') {
details.useVersion "27.1.0"
}
}
}

java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files

I build the project at gitlab ci
./gradlew assembleDebug --stacktrace
and sometimes it throws an error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files
At my local pc it works correctly.
kotlin version is 1.2
multidex is enabled
What is the reason of this error?
./gradlew clean fixed the same error for me.
For Cordova developers,
If you get this build error in your project, as said Pierrick Martellière in the comments of this answer, in you project folder use :
cordova clean
It makes a cleaning and a build immediately
It seems I found the solution.
At the build moment gradle was showing warnings for me:
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
app: 'androidProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.arello-mobile:moxy-compiler:1.5.3' and apply the kapt plugin: "apply plugin: 'kotlin-kapt'".
I made a misspelling and forgot to remove unnecessary annotationProcessor for library:
annotationProcessor "com.arello-mobile:moxy-compiler:$moxyVersion"
kapt "com.arello-mobile:moxy-compiler:$moxyVersion"
So I removed first line.
After that I applied kapt plugin apply plugin: 'kotlin-kapt' and fixed some build errors in code after it.
After all I realized that I forgot to replace compile to implementation in some places. It is weird but without it build didn't work.
This changes fix my error build.
Simple Solution
For Ionic and Cordove Projects
cordova clean
Above answer is mostly right but in my case, i get this exception when i crate same name java and kotlin file then deletes one of them.
Solutions are: just Build -> Clean Project my project and it works. And my project also enabled multiDex.
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
As mentioned above by #mixel cleaning gets the job done. But as an option not to do it manually just add the gradle 'clean' task into app run configuration so it will be done all the time before launch. Of cource, it can slow down the whole process a bit.
I was able to get the problem to go away by closing and restarting Android Studio. Perhaps even a Rebuild Project would have done it as well (did not try that though).
Configuring for multidexing did not solve this issue for me.
However I did come up with a resolution...of sorts. Basically it involved creating a pull request for a second branch on the same commit as the build that was failing. The build for this pull request succeeded, and then Bitbucket thought that the original pull request was ok and allowed us to merge, even though we had made no changes on that branch. There is some unexplained weirdness there but the technique worked.
Here's how I did it:
Assume that the branch that is failing is called bad-branch.
I created a new branch called bad-branch-copy on the commit that was common between bad-branch and develop. Then I merged bad-branch into bad-branch-copy. The end result of this was a fast forward such that bad-branch-copy ended up on the same commit as bad-branch. I was expecting a separate commit so this result surprised me, but I was grasping at straws anyway so I kept going.
I then pushed bad-branch-copy to GitHub and created a pull request from bad-branch-copy to develop. This triggered a build on bad-branch-copy -> develop, which was successful.
At that point, buddybuild showed a successful build on bad-branch-copy -> develop and still showed a failure on bad-branch -> develop. However, Bitbucket showed a successful build on the pull request for bad-branch. Yes, that's right: buddybuild showed a failure but Bitbucket said it was ok.
We were then able to merge the bad-branch pull request and all was well with the world. Please don't ask me why, I will not answer. :)
I think the same thing could be accomplished with
git checkout bad-build
git checkout -b bad-build-copy
git push origin bad-build-copy
followed by creating a pull request for bad-build-copy.
Currently using Android Studio 3.3.2 I just disabled the instant run and it worked.
What resolved the issue for me was manually adding all the conflicting files manually. For example in my gradle file I had:
implementation 'com.android.support:support-compat:27.1.1'
it was underlined with red. I hovered over the line and android studio said there was a conflict with another file using a lower version. The error was similar to
come.android.support:support-annotations:26.0.1 conflicts/mix versions with 27.1.1.
It gave me the names of the files and I manually added them with the corresponding version so they would all match
compile 'com.android.support:support-annotations:27.1.1'
compile 'com.android.support:support-compat:27.1.1'
compile 'com.android.support:support-core-ui:27.1.1'
compile 'com.android.support:animated-vector-drawable:27.1.1'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
None of the current solutions worked for me and it was fixed by simply disabling Instant Run.
please find here the solution of this problem,
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}

Google-services.json not found

I am facing this error
Error:Execution failed for task ':app:processDebugGoogleServices'.
File google-services.json is missing. The Google Services Plugin cannot
function without it.
Searched Location:
C:\Users\Kartik\AndroidStudioProjects\barcode\app\src\debug\google-
services.json
C:\Users\Kartik\AndroidStudioProjects\barcode\app\google-services.json
I have added this path in build.gradle(project:barcode)
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
and added this in build.gradle(Module:app)
apply plugin: 'com.google.gms.google-services'
I have also added the google-services.json file in project->app folder but then also it is giving the same error.
i faced the same problem before .
check the json file name and make sure that there is no additional spaces
First of all please make sure that you have followed documentation for firebase and not google developers guidelines and alspo generated Google-services.json for firebase project that is running in your firebase-console, you can see all your running projects in your dashboard in firebase
Make sure you have correct json file, this problem is describe here.
You can follow these steps also as per firebase documentaion.
still if you are all correct and getting errors make sure you have updated play services version in your SDK and also put this line in your app module build.gradle file, to make sure that multidex is unable. Hope you will make something out of it.
defaultConfig {
multiDexEnabled true
}

Access to the dex task is now impossible, how to upgrade to 1.5.0?

I want to upgrade gradle to 2.0.0-beta or 1.5.0, I have the dex plugin in my gradle at the moment, but even when I removed it I was still getting the same error. How do I properly get rid of the multidex dependency
Error:Access to the dex task is now impossible, starting with 1.4.0
1.4.0 introduces a new Transform API allowing manipulation of the .class files.
See more information: http://tools.android.com/tech-docs/new-build-system/transform-api
build.gradle More info on multidex
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
The Transform API doesn't give too much info.
Is there any to get this work or any examples how to use the transform api, anything at all?
I know it works with 1.3.0, I need at least 1.5.0
At the project level build.gradle, put this (or whatever version you need)
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
As far as
How do I properly get rid of the multidex dependency?
You need to remove all references to multidex in the Gradle files, then sync Gradle and clean and rebuild the project
I'm not sure if it's going to help. I got a similar error and I deleted the directory which contained that dex file. The path was C:\Users\user\AndroidStudioProjects\AppName\app\build\intermediates\builds\debug\37393618208634. After deleting that directory it worked. You can try this if that does't work you can just put it back. I hope this helps.

Categories

Resources