Abhimanyu
Abhimanyu

Reputation: 14817

Dependency issues in navigation with Android Jetpack Compose

I am exploring compose navigation as specified in the docs.

Adding the dependency with version 2.4.0-alpha07 as specified in docs, gives the following error,

Error 1

One or more issues found when checking AAR metadata values:

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.navigation:navigation-compose:2.4.0-alpha07. AAR metadata file: /Users/abhimanyu/.gradle/caches/transforms-3/0575ff5712e0a9c15b8d7424501c07b8/transformed/jetified-navigation-compose-2.4.0-alpha07/META-INF/com/android/build/gradle/aar-metadata.properties.

This error forces me to upgrade compileSdkVersion and targetSdkVersion of my app from 30 to 31.

Upgrading the version gives this error,

Error 2

Manifest merger failed: Apps targeting Android 12 and higher are required to specify an explicit value for android: exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

To solve that, checked this post.

Even after adding the android:exported, I am getting the same error (error 2).

Is the compileSdkVersion upgrade to 31 mandatory?

If yes, how to solve Error 2. If no, how to solve Error 1?

I personally prefer to stick with SDK 30 if possible.

Upvotes: 3

Views: 6294

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363905

Now every AndroidX library released is compiled with API 31.

You can check it also in the Accompanist release notes:

Accompanist is now built against SDK 31: This means that your apps also need to compile against SDK 31. This was necessitated by the latest AndroidX releases also being built against SDK 31.

Just use in your build.gradle

compileSdkVersion 31

but you should always compile with the latest SDK since it doesn't change your app behavior. This has no bearing on your targetSdkVersion, you can continue to set that as you need.

The only rule is:

minSdkVersion <= targetSdkVersion <= compileSdkVersion 

More details in the doc.

Upvotes: 15

Related Questions