I am currently working with an Android project that originally using Android API version 31; however, I want my app to work on API version 25, so in the build.gradle, I changed compileSDK to 25. However, building the app fails because of mismatched dependencies. The app is currently compiled against android-25, but there are still dependencies that require on version 31 libraries.
How do I go about adjusting the dependencies to fit Android API 25? Also, If I could get a hold of an Android project that already had Nougat's respective dependencies and it compiled correctly that would be nice too, but new Android Studio projects only provide this even when I specify API 25.
This is one of the issues raised during build. This dependency happens to be specified in my build.gradle, but there are other issues that are not.
1. Dependency 'androidx.navigation:navigation-fragment:2.5.3' requires libraries and applications that
depend on it to compile against version 31 or later of the
Android APIs.
:app is currently compiled against android-25.
This is my build.gradle
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.zebcpu'
compileSdk 25
defaultConfig {
applicationId "com.example.zebcpu"
minSdk 25
targetSdk 25
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
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
}
I tried to compile my project against Android API 25, but there were dependencies that required API 31.
compileSdkandtargetSdkare usually given latest values for it to work on devices that have more recent versions. GivenminSdk 25, your app will work starting from sdk versions 25 onwards.I would recommend you update
compileSdkandtargetSdkto a more recent version since the dependencyandroidx.navigation:navigation-fragment:2.5.3requires compile version 31+ for its library to work.