144

I'm working on a React Native application. My Android builds began to fail in the CI environment (and locally) without any changes.

Execution failed for task ':app:processDevelopmentDebugResources'.

> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
.../app/build/intermediates/incremental/mergeDevelopmentDebugResources/merged.dir/values/values.xml:2682: AAPT: error: resource android:attr/lStar not found.

According to Android: Resource linking fails on test execution even when nothing has been changed, this happened because some library got upgraded.

lStar needs compileSdkVersion 31 and my project used compileSdkVersion 28.

How can I track which libraries got updated recently, or which library is causing this?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Eduardo Carminati
  • 1,313
  • 2
  • 8
  • 7

40 Answers40

63

The problem is @react-native-community/netinfo. Just try to update the package using

yarn add @react-native-community/netinfo

or

npm update @react-native-community/netinfo

There isn't any need to change anything over your Gradle or Android files as those might mess things up even more.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Barath Kumar
  • 627
  • 1
  • 4
  • 11
  • 8
    Yep, this one worked for us too. Upgraded from 5.x.x to 6.0.1 and no regression issues spotted so far – Adam McArthur Sep 02 '21 at 12:00
  • This solved my problem but why did it break in the first place? My `@react-native-community/netinfo` was set to `5.9.0` for some time and it worked like a charm... really annoying. – Elias Sep 02 '21 at 13:55
  • 2
    Wow this is really bad form. Nothing changed on my end and then it stops working one day!!! This fixed my problem. – Robel Robel Lingstuyl Sep 09 '21 at 00:53
  • @Elias because of [this](https://github.com/react-native-netinfo/react-native-netinfo/commit/d40d9b5704a7d6573f3832586626aceac8b680bd), which was fixed in the commit i've linked to, the "actual issue" is that this library was using the + shortcut which is to say "get the latest", a new, breaking, version of the androidXCore, was released upstream which this library was set to automatically use, but either the library or your app was not prepared for it so when you built it all fell apart. – fury-s12 Sep 30 '21 at 03:56
  • Many thanks really ... This wasn't an obvious problem to solve ! – Nicolas Dec 17 '21 at 15:59
  • 1
    In my case, I already have version 6.0.x and this didn't fix it. I'll try the android native solutions – Dror Bar Nov 07 '22 at 10:09
32

Go to android/build.gradle and add androidXCore = "1.6.0" to ext:

ext {
    buildToolsVersion = "29.0.2"
    minSdkVersion = 21
    compileSdkVersion = 29
    targetSdkVersion = 29
    googlePlayServicesAuthVersion = "16.0.1"
    androidXCore = "1.6.0"
}
28

Native Android:

The issue occurs because of androidx.core:core-ktx.

If you are using core-ktx, change

implementation "androidx.core:core-ktx:+"

to

implementation "androidx.core:core-ktx:1.6.0"

if you are not using core-ktx maybe one of your dependent libraries is using androidx.core:core-ktx.

Solution 1: Figure out the library using core-ktx and try not to use it.

Or:

Solution 2: Update compileSdkVersion and targetSdkVersion to 31

Or:

Solution 3: In app:build.grandle add below code: hou andy's solution

configurations.all {
    resolutionStrategy {
        force 'androidx.core:core-ktx:1.6.0'
    }
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sudhir G
  • 381
  • 4
  • 7
23

It looks like there is a bug with the alpha02 version of core-ktx.

There might be two reasons that this is happening to you project if you didn't upgrade it recently:

  1. You are using

    implementation "androidx.core:core-ktx:+"

    In this case, replace it with

    implementation "androidx.core:core-ktx:1.6.0" (or whichever version works for you)

  2. Some library is using that alpha02 version

    In this case you have two options:

    1. temporarily increase to compileSdkVersion 31

    2. Remove or downgrade the dependency that is using alpha02

    Run

     ./gradlew :app:dependencies > dependencies.txt
    

    A text file with dependency tree will be added to your project.

    Open the file and you will see something like this

     +--- MyApp:mylibrary:unspecified
     |    \--- com.android.support:appcompat-v7:25.3.1
     |         +--- com.android.support:animated-vector-drawable:25.3.1
     |         |    \--- com.android.support:support-vector-drawable:25.3.1
     |         |         \--- com.android.support:support-v4:25.3.1
     |         |              \--- LOCAL: internal_impl-25.3.1.jar
     |         +--- com.android.support:support-v4:25.3.1
     |         |    \--- LOCAL: internal_impl-25.3.1.jar
     |         \--- com.android.support:support-vector-drawable:25.3.1
     |              \--- com.android.support:support-v4:25.3.1
     |                   \--- LOCAL: internal_impl-25.3.1.jar
     \--- com.android.support:appcompat-v7:25.3.1
          +--- com.android.support:animated-vector-drawable:25.3.1
          |    \--- com.android.support:support-vector-drawable:25.3.1
          |         \--- com.android.support:support-v4:25.3.1
          |              \--- LOCAL: internal_impl-25.3.1.jar
          +--- com.android.support:support-v4:25.3.1
          |    \--- LOCAL: internal_impl-25.3.1.jar
          \--- com.android.support:support-vector-drawable:25.3.1
               \--- com.android.support:support-v4:25.3.1
                    \--- LOCAL: internal_impl-25.3.1.jar
    

    Search for something similar to this

     androidx.core:core-ktx:1.6.0 -> 1.7.0-alpha-02
    

    Track down which dependency is using that. To fix it you might need to either remove the dependency or downgrade it to an older version.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Donki
  • 660
  • 6
  • 21
  • It is coming in androidx.core:core:1.7.0->values.xml. Log says to increase the minSdkVersion to 24 or above. It went away when changed compileSdkVersion and targetSdkVersion to 31 OS version. – Abhinav Saxena Dec 23 '21 at 12:03
18

Go to your package.json file and delete as many dependencies as you can until the project builds successfully. Then start adding back the dependencies one by one to detect which ones have troubles.

Then you can manually patch those dependencies by acceding them on node_modules/[dependencie]/android/build.gradle and setting androidx.core:core-ktx: or androidx.core:core: to a specific version (1.6.0 in my case).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
martin
  • 338
  • 1
  • 3
  • 5
  • 2
    What was the dependency in your case? – Eduardo Carminati Sep 01 '21 at 23:46
  • 3
    You can open the `node_modules` folder using **vscode** and search(Ctrl+Shift+F) for **androidx.core:core** and **androidx.core:core-ktx** – Randunu.KSW Sep 01 '21 at 23:50
  • 3
    @martin, thank you so much! The issue was androidx.core:core version on netinfo's build.gradle. – Eduardo Carminati Sep 02 '21 at 00:03
  • 6
    @radosław-rudnicki latest version is fine (5.9.7) but go into 'node_modules\@react-native-community\netinfo\android\build.gradle' and change line 67 from implementation "androidx.core:core:$androidXCore" to implementation "androidx.core:core:1.6.0" – martin Sep 02 '21 at 00:04
  • 2
    @RadosławRudnicki I changed **implementation "androidx.core:core:$androidXCore"** on netinfo's **build.gradle** to version **1.0.1**. Then I'll create a patch with **patch-package** – Eduardo Carminati Sep 02 '21 at 00:04
  • 1
    when I have modified the file **node_modules/@react-native-community/netinfo/android/build.gradle** replacing line number 67 `implementation "androidx.core:core:$androidXCore"` to `implementation "androidx.core:core:1.6.0"` gradlew succeeded Thanks guys – RadekR Sep 02 '21 at 00:06
  • 1
    i am not able to solve the issue , above mentioned technique doesnot work . – seon Sep 02 '21 at 10:17
  • Replace implementation "androidx.core:core-ktx:+" with 'androidx.core:core-ktx:1.6.0' in your project or module level gradle will fix the issue. There is no need to increase the compileSdkVersion. – BAIJU SHARMA Sep 02 '21 at 12:29
  • check my answer for a more detailed way on how to find which dependency to remove – Donki Sep 02 '21 at 13:29
  • Thanks so much! Mine was also @react-native-communtiy/netinfo. I just had to upgrade it to ^6.0.1 – pbrune Sep 02 '21 at 15:16
  • upgrading @react-native-community\netinfo from 5.9.7 to 6.0.1 did the job for me - all builds fine – RadekR Sep 02 '21 at 18:24
  • Generally speaking, it's also a good idea to specify the exact version for each dependency (and in some cases sub-dependencies) in `package.json` to avoid changes from one build to another. – Bruno Sep 03 '21 at 13:26
14

I changed version 29 to 31 in compileSdkVersion and targetSdkVersion of the build.gradle file in the android folder. It solved my problem.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 2
    Yes; the same worked for me too. My changes `buildToolsVersion = "31.0.0"`, `compileSdkVersion = 31` and `targetSdkVersion = 31` – Amil Waduwawara Sep 03 '21 at 02:59
  • I referred to the AndroidManifest.xml of the package whose file contains the error point - and found that the targetSdkVersion was higher than what I had for the project. So increased it my project's gradle file - and it worked. – Ujjwal Singh Jan 03 '22 at 21:26
14

Solution for Flutter:

Simply search globally for core-ktx dependencies for all the Flutter packages including the Flutter project android folder and set the 1.6.0 version instead of +.

From:

implementation "androidx.core:core-ktx:+"

To:

implementation "androidx.core:core-ktx:1.6.0"

I faced the same issue with the audioplayers Flutter package in older version.

Patel Pinkal
  • 8,984
  • 4
  • 28
  • 50
  • 1
    Have a look at audioplayers v0.19.1, as it solves this issue (https://pub.dev/packages/audioplayers/changelog) – Manu Sep 02 '21 at 18:06
  • @Manu Thanks, I already review the same after the solution and upgrade the packages. But this answer might help for those who might want to use an older version or facing issues with other packages. – Patel Pinkal Sep 03 '21 at 04:13
13

Changing android/build.gradle and adding androidXCore = "1.6.0" worked for me.

ext {
    buildToolsVersion = "29.0.2"
    minSdkVersion = 21
    compileSdkVersion = 29
    targetSdkVersion = 29
    googlePlayServicesAuthVersion = "16.0.1"
    androidXCore = "1.6.0"    //Add this line
}
13

Force use this androidx-core version in your app module file build.gradle:

configurations.all {
    resolutionStrategy {
        force 'androidx.core:core-ktx:1.6.0'
    }
}

It's seems to work for me!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
hou andy
  • 131
  • 3
13

For Unity Game Engine Builds

In case someone ends up here searching for a solution with their Unity builds, the solution is to add

configurations.all {
  resolutionStrategy {
    force 'androidx.core:core:1.6.0'
    force 'androidx.core:core-ktx:1.6.0'
  }
}

At the end of your launcherTemplate.gradle file in Plugins/Android.

Bibzball
  • 303
  • 1
  • 7
  • What is a *"Unity build"*? The word "Unity" is heavily overloaded. Can you [add](https://stackoverflow.com/posts/69045181/edit) some reference to (authoritative) documentation? But ***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today. – Peter Mortensen Sep 10 '21 at 04:58
  • It worked for me after I added `force 'androidx.core:core:1.6.0'` to my AndroidManifest.xml (I had this error with a normal Android project) – Sidnei Bernardo Oct 28 '22 at 17:03
12

If you're using React Native and coming here after November 4, 2022, this may be the solution: github.com/facebook/react-native/issues/35210 React Native team messed something up with version and thats the reason why we have this message..

Vikki
  • 191
  • 1
  • 7
  • No way that this did the trick :) – mikegross Nov 24 '22 at 10:17
  • Could you link the comment from this issue that actually solves this problem, or tell us the solution? The issue has 360+ comments and it's hard to understand what to actually do. – reesaspieces Dec 11 '22 at 09:14
  • 1
    @reesaspieces You may follow the first post of React team: https://github.com/facebook/react-native/issues/35210#issue-1436785719 and patch your react-native with corresponding version. – Vikki Dec 12 '22 at 01:04
8

Solution for Cordova

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.

Nitrix
  • 481
  • 1
  • 2
  • 3
  • 1
    Thank you for the solution. I had same issue in my ionic cordova app and disgnostic plugin was there. Followed above steps and boom, error went away :) – Mian Azhar Oct 01 '21 at 07:15
  • Thanks for this! Tried this with AndroidX 1.6.0, and that works too. The issue seems to be only in the 1.7.0-beta02. – Hans Wouters Oct 01 '21 at 13:09
  • Thank you very much for your research! – user3980196 Dec 01 '21 at 18:57
  • Thank you, good sir. To expand your answer: this error is introduced by 1.4.0, switching to **androidx.appcompat:appcompat:1.3.0** solves the build problem perfectly! – andreszs May 05 '22 at 12:19
8

Changing appcompat version to 1.3.0 worked for me

implementation 'androidx.appcompat:appcompat:1.3.0'
PRANAV SINGH
  • 1,000
  • 11
  • 17
6

In my case, the problem was with react-native-screen-brightness, so I just changed implementation 'androidx.core:core:1+' to implementation 'androidx.core:core:1.6.0' in file android/build.gradle.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
6

Update your gradel.build

compileSdkVersion 31
targetSdkVersion 31
Harry Potter
  • 184
  • 1
  • 6
  • For me I had to force the SDK version on subproject dependencies: see https://stackoverflow.com/a/73298232/6877668 – Jiří Aug 10 '22 at 09:02
5

In my case problem was with @react-native-community/netinfo": "^5.3.3, so I just removed the netinfo library and installed it again with the latest version and the problem got solved.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
5

Just adding androidXCore = "1.6.0" solved it for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
marcoj
  • 51
  • 4
5

If you getting this issue in Android

if you using

implementation "androidx.core:core-ktx:+"

just replace it with:

implementation "androidx.core:core-ktx:1.6.0"

and in gradle-wrapper.properties: distributionUrl is:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

________________________________________________________________

Other wise

and if you want to use

 implementation "androidx.core:core-ktx:+"

just change distributionUrl in gradle-wrapper.properties:

#distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Sandeep Pareek
  • 1,636
  • 19
  • 21
4

I solved it by replacing

implementation 'androidx.core:core:1.0.0'

with this one:

implementation 'androidx.core:core-ktx:1.6.0'

If you have for some reason both, set only the ktx version.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
3

I couldn't figure out which library was causing the problem and upgrading compileSDK version was breaking the app, but I went to the core and you can see that the core library got updated a day back. So the alpha-02 was causing the problem.

I fixed my problem by converting

 implementation "androidx.core:core-ktx:+"

to

 implementation "androidx.core:core-ktx:1.6.0"

in the build Gradle file (app level) and then Sync now.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Aryan Barnwal
  • 53
  • 4
  • 8
3

In fact, the answer native android is correct:

"It looks like there is a bug with the alpha02 version of core-ktx"

You are using

implementation "androidx.core:core-ktx:+"

In this case, replace it with

implementation "androidx.core:core-ktx:1.6.0" 

but in many cases, it doesn't help because when you don't use explicit this dependency. What happened is jetbrain convert old library automatically to use androidx latest library, that's the origin of the issue. so you need to check every dependency implement in your build.gradle and update it to androidx version. for me it's a old project, the room before is:

compile "android.arch.persistence.room:runtime:+"   
annotationProcessor "android.arch.persistence.room:compiler:+"

to

implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

and you need add this in your build.gradle (you can add it globally in the end of the file):

configurations.all {
    resolutionStrategy {
        force 'androidx.core:core-ktx:1.6.0'
    }
} 
Guopeng Li
  • 81
  • 1
  • 9
2

While many of the solutions indicate to use

androidx.core:core:1.6.0

I discovered that in my project, one module was using version 1.7.0

After changing it to 1.6.0, this problem went away. So if you have multiple modules, make sure you check all of the build.gradle files that they are all using the same version.

Johann
  • 27,536
  • 39
  • 165
  • 279
2

If anyone else found this page having issues with react-native, there is information and a hot-fix available here https://github.com/facebook/react-native/issues/35210.

[READ ME] [FIX INSIDE] Android build failures happening since Nov 4th 2022 #35210

Jesper Johansson
  • 599
  • 3
  • 14
2

Update 2022

Solution

When this problem arises, it's likely one of your dependencies set compileSdkVersion to 30 or less in it's build.gradle file. You have to find that package and find a way to set the compileSdkVersion to 31.

My Solution

I faced this problem in React Native and it turned out one of my dependencies, namely react-native-device-number basically set compileSdkVersion to 29 in it's build.gradle. I had to change it to 31 and the problem was solved.

For me I didn't deem it good to edit the package's codes locally as it can cause issues when updating it, and editing the code won't solve the problem when run on CI/CD environments. So I had to fork the package on Github, make the changes, then install the forked version in my React Native project.

Here's the signature for installing node.js package from Github

npm install github_username/repo_name/#branch_name

And here's the entry in my package.json after the installation package.json

{
  ...
  "react-native-device-number": "github:stanleyugwu/react-native-device-number#develop"
  ...
}

Hope this helps...

Stanley
  • 89
  • 8
  • I had the same issue in React Native 0.69.7 with this library: TronNatthakorn/react-native-wheel-pick. Your solution worked for me. Did a PR to that repo with this fix. Thank you! – Krisid Misso Nov 16 '22 at 19:36
1

For me, the working solution was updating compileSdkVersion and targetSdkVersion to 31 in the app-level Gradle file.

1

If you're using compileSdkVersion lower than 31, use 1.6.0.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1

None of the previous answers worked for me.

I removed the Huawei IAP libraries, but I forgot to delete the agconnect-services.json file provided by Huawei. So after deleting that file, all went well.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Khalid Lakhani
  • 179
  • 2
  • 10
1

Replacing implementation "androidx.core:core-ktx:+" with 'androidx.core:core-ktx:1.6.0' in your project or module level Gradle file will fix the issue. There isn't any need to increase the compileSdkVersion.

It worked for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
BAIJU SHARMA
  • 276
  • 4
  • 9
1
  1. Update Gradle
  2. Update the SDK to version 31
  3. Accept the license
  4. Set compileSdkVersion to 31 in the build Gradle file
  5. Sync

Ready to go!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Just adding a note, I had to force SDK version on all subprojectsin order to fix this problem: https://stackoverflow.com/a/73298232/6877668 – Jiří Aug 10 '22 at 09:03
1

Find all dependencies in your project:

Replace all: implementation "androidx.core:core-ktx:+" with the specified version: 1.6.0, because with the +, you always use the newest version.

Now androidx.core:core-ktx updates to the 1.7.0-alpha version.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Matthew
  • 21
  • 4
1

Getting the same error

Solved the issue in may case by

changing

implementation "androidx.core:core-ktx:+" to

implementation "androidx.core:core-ktx:1.6.0"(updated)

issue fixed... thanks to above solution

Bhavesh Chand
  • 495
  • 6
  • 7
1

In my case updating @react-native-community/netinfo to 6.0.2 plus adding coreVersion = "1.6.0" into build.gradle for package @invertase/react-native-apple-authentication which is searching for this variable resolved the issue.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
lukhol
  • 318
  • 2
  • 6
  • 18
  • Hello lukhol what is the 'exact code to add 1.6.0 into build.gradle for package @invertase/react-native-apple-auhentication? – Engin Yilmaz Nov 05 '22 at 17:40
1

I have resolved my issue by updating the @react-native-community/netinfo library.

npm update @react-native-community/netinfo

1

core-1.7.0-alpha02

Suddenly build is failing without any code change?

It is quite common. This happened with me many times and most recently it happened with core-1.7.0-alpha02. My project was building fine and one day it stooped.

What might be the issue?

Gradle sync

Sometimes new version of libraries break project.

Solution?

Force you gradle to use the old stable versions. In this case androidx.core:core:1.6.0 was the stable release. You can see always find the stable version information

enter image description here

How to use older version of library?

Go to gradle.build (app level) and paste this

//Forcing 1.6.0 instead of 1.7.0-alpha02
configurations.all {
   resolutionStrategy {
       force 'androidx.core:core:1.6.0'    //This is stable version right now.
   }
}

Bonus:

General rule to fix these issues?

In my case this was the error message

/Users/singhr1/.gradle/caches/transforms-2/files-2.1/1ae857b36375746f9b0fa09af0c656f3/core-1.7.0-beta02/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

So the culprit was core-1.7.0-beta02.
I found the stable version on Developer's page and forced my Gradle to use it.

Rohit Singh
  • 16,950
  • 7
  • 90
  • 88
1

FOR IONIC CORDOVA, in the build.gradle where all your dependencies are put this

build.gradle

ext {
    buildToolsVersion = "29.0.2"
    minSdkVersion = 21
    compileSdkVersion = 29
    targetSdkVersion = 29
    googlePlayServicesAuthVersion = "16.0.1"
    androidXCore = "1.6.0".  <---------- this is important
}

configurations.all{

resolutionStrategy {
        force 'androidx.core:core:1.6.0' <---------- this is important
        force 'androidx.core:core-ktx:1.6.0'  <-----this is important
    }

}

dependencies

implementation "androidx.core:core-ktx:1.6.0"  <-----this is important
implementation "androidx.core:core:1.6.0" <-----this is important
ivan
  • 21
  • 3
0

For those using ionic 3 and firebase, the solution is change the project.properties and replace some androidx.core lines:

Before

# Project target.
target=android-28
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=androidx.legacy:legacy-support-v4:1.0.0
cordova.gradle.include.1=cordova-support-google-services/nosveja-build.gradle
cordova.system.library.2=com.google.firebase:firebase-analytics:17.5.+
cordova.gradle.include.2=cordova-plugin-firebase-lib/nosveja-build.gradle
cordova.system.library.3=com.google.android.gms:play-services-tagmanager:16.+
cordova.system.library.4=com.google.firebase:firebase-auth:18.+
cordova.system.library.5=com.google.firebase:firebase-core:17.+
cordova.system.library.6=com.google.firebase:firebase-messaging:19.+
cordova.system.library.7=com.google.firebase:firebase-config:18.+
cordova.system.library.8=com.google.firebase:firebase-perf:18.+
cordova.system.library.9=androidx.annotation:annotation:1.1.0
cordova.system.library.10=com.google.android.gms:play-services-location:16.+
cordova.system.library.11=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.12=androidx.legacy:legacy-support-v4:1.+
cordova.system.library.13=androidx.appcompat:appcompat:1.+

After

target=android-28
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=androidx.core:core-ktx:1.6.0
cordova.gradle.include.1=cordova-support-google-services/nosveja-build.gradle
cordova.system.library.2=com.google.firebase:firebase-analytics:17.5.+
cordova.gradle.include.2=cordova-plugin-firebase-lib/nosveja-build.gradle
cordova.system.library.3=com.google.android.gms:play-services-tagmanager:16.+
cordova.system.library.4=com.google.firebase:firebase-auth:18.+
cordova.system.library.5=com.google.firebase:firebase-core:17.+
cordova.system.library.6=com.google.firebase:firebase-messaging:19.+
cordova.system.library.7=com.google.firebase:firebase-config:18.+
cordova.system.library.8=com.google.firebase:firebase-perf:18.+
cordova.system.library.9=androidx.annotation:annotation:1.1.0
cordova.system.library.10=com.google.android.gms:play-services-location:16.+
Diego Desenvolvedor
  • 378
  • 1
  • 6
  • 22
0

In my case, changing compileSdkVersion = 29 and targetSdkVersion = 29 to compileSdkVersion = 31 and targetSdkVersion = 31 works without changing androidxCoreVersion = '1.2.0' to androidxCoreVersion = '1.6.0'

0

The problem is caused by newer version of androidx.core:core-ktx missing lStar.

To find the package causing the problem, I searched through all installed node_modules for core-ktx: and found implementation "androidx.core:core-ktx:+" in the react-native-camera-kit package.

I would like to lock this to core-ktx:1.6.0 to fix the build issue. Using patch-package that is straight forward (make sure you have a fresh package installation without build artifacts):

  • Change core-ktx:+ to core-ktx:1.6.0 in the build.gradle file, in my case node_modules/react-native-camera-kit/android/build.gradle
  • Run yarn patch-package <package to fix>, in my case yarn patch-package react-native-camera-kit
  • Rebuild for Android to check that it works
  • Commit patch
Bjørn Egil
  • 2,398
  • 1
  • 20
  • 22
0

In my case, it was caused by the line in build.grale, classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0".

After I added a new empty activity to the project with Android Studio Arctic Fox 2020.3.1 Patch 4, Android Studio altered the build.gradle file

from: classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

to: classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"

Eric Cen
  • 3,616
  • 1
  • 13
  • 17
0

Adding kotlin-gradle-plugin in build.gradle fixed the issue for me: classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"