Maneki Neko
Maneki Neko

Reputation: 1247

Android Manifest: Can't force minSDK anymore. "should not be declared in the android manifest file"

Got a little build issue.

Got a lib that requires minSDK:23 while I still want to support 21.

The solution of

    <uses-sdk
    android:minSdkVersion="21"
    tools:overrideLibrary="a.rogue.library" />

Doesn't sync anymore and shows

The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file. Remove minSdkVersion and sync project Affected Modules: approot

Strange observation: Sync fails but Build succeeds. Moreover, sync after build succeeds, too.

It's an unhealthy situation, though:

Any way to settle this out? Can overrideLibrary reside somehow in the build.gradle?

Thanks

Upvotes: 0

Views: 2404

Answers (3)

Paras Palli
Paras Palli

Reputation: 194

Refer this Doc For Detail Understanding and the answer to the the error link

<application>
<meta-data
    android:name="androidx.car.app.minCarApiLevel"
    android:value="1" />
<service android:name="com.example.places.carappservice.PlacesCarAppService" ...>
    ...
</service>

Upvotes: 0

Will Buffington
Will Buffington

Reputation: 1670

I just did this and it worked. In the app-level build.gradle file just make sure you specify 'minSdkVersion #' in the defaultConfig section where the # sign mentioned previously is the SDK number you are targeting. Example:

android {
compileSdkVersion 30
buildToolsVersion "29.0.2"
defaultConfig {
    applicationId "com.example.ranchhand1"
    minSdkVersion 23
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

}

Upvotes: 0

Zsolt Boldizsar
Zsolt Boldizsar

Reputation: 2582

I also bumped into this today, and as far as I see it has been introduced as part of version 4.0.0 of the Android Gradle Plugin (I'm still searching for reference) and while it looks frustrating at first I think is the right thing to do as it actually avoids some potential runtime crashes. (e.g. when a consumer calls into an API of the library which relies on some other API that has been introduced in a newer SDK version but we've forced it to be older anyway)

If you can afford just go back to the previous stable version 3.6.3 and you'll be fine for now, but the library developers chose the minimumSdkVersion for a reason. Maybe reach out to them to clarify the rationale behind it and get some advise. Good luck!

Upvotes: 1

Related Questions