3

A week ago the app was running perfectly but all of a sudden (without updating anything) the app is not running.

I am getting this error when I try to run the app

The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30). Dependency: androidx.work:work-runtime:2.7.0-beta01. AAR metadata file: /home/kishan/.gradle/caches/transforms-2/files-2.1/af85edd7f0482dfc2b2e0c9a0519784e/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.

Here is the screenshot for the same:

enter image description here

From my app level gradle file, I can see that I am having

compileSdkVersion 30 and targetSdkVersion 30

Not sure what is causing this issue.

Any help would be appreciated. Thank You!

Kishan Solanki
  • 13,761
  • 4
  • 85
  • 82
  • 1
    Does this answer your question? [App won't build in react native - Android?](https://stackoverflow.com/questions/69037481/app-wont-build-in-react-native-android) – humazed Sep 05 '21 at 10:04

2 Answers2

6

Ok So finally I resolve this issue.

The issue was because of the dependency androidx.work:work-runtime But I would like to first mention that I was not using that dependency in my project directly (not added in my app level gradle), probably some other dependency was using that internally.

So what I did is forcefully downgraded its version by adding this

configurations.all {
        resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
    }

inside

android {
 defaultConfig {
   //here
 }
}

and it resolved my issue.

Kishan Solanki
  • 13,761
  • 4
  • 85
  • 82
  • Thank you for finding this solution. It did the trick for me, though my problem module was with 'androidx.browser:browser' which I also forced back to a stable version. – Andy Duncan Jan 06 '23 at 10:20
1

Leave targetSdkVersion 30, but change compileSdkVersion to be 31.

The work manager beta probably also uses Android SDK 31.

When you compile Android SDK 30, work manager cannot compile since it uses Android SDK 31, and therefore uses new APIs which does not exist in Android SDK 30.

Edit

Work Manager release notes of 2.7.0 explicitly warns that this version and above only compatible with API 31.

So your options are:

  • Use 2.6.0, which compiles API 30.
  • Compile API 31 and try to handle the other broken dependencies - maybe Stack Overflow can help you out?
Shlomi Katriel
  • 2,103
  • 1
  • 7
  • 20