Building APKs with minSdk in both AOSP and Android Studio

580 views
Skip to first unread message

Baran Jean-Marie

unread,
Apr 2, 2019, 11:51:43 AM4/2/19
to Android Building
Hello,

We have an APK which must define a minSdk version of at least 16 because of dependencies. Adding <uses-sdk android:minSdkVersion='25' /> in the AndroidManifest.xml works in the AOSP but not in Android Studio:

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.

However, removing <uses-sdk android:minSdkVersion='25' /> works in Android Studio, but not in the AOSP:

Error: Main manifest has <uses-sdk android:minSdkVersion='1'> but library uses minSdkVersion='16'

I tried as well with <uses-sdk tools:merge="override" />, but that only works for the AOSP. Is there a way to have a cross-build AndroidManifest.xml that would work for both the AOSP and Gradle? Because currently we have to manually edit it each time we want to build in Android Studio, which is not practical.

Dan Willemsen

unread,
Apr 2, 2019, 12:02:41 PM4/2/19
to Android Building
In AOSP master, you should be able to set `min_sdk_version: "25"` in your Android.bp (or `LOCAL_MIN_SDK_VERSION := 25` in an Android.mk). Older branches you may need to do some workarounds with merging in another manifest, but I think you'd only get the above error on master.

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Baran Jean-Marie

unread,
Apr 3, 2019, 3:11:03 PM4/3/19
to Android Building
Thanks for the information, this does help.

Unfortunately for us, we are on a rather old branch (7.1.2) and the LOCAL_MIN_SDK_VERSION is broken there. There is a commit which seems relevant in platform/build, but it's tricky to apply on our branch: d01997f. Anyway, I'll look into the second option you suggested.

Jean-Marie.

Baran Jean-Marie

unread,
Apr 4, 2019, 12:11:53 PM4/4/19
to Android Building
Sorry, I linked the wrong commit in the previous post. For reference it was 9deb331.

Jean-Marie.

Le mardi 2 avril 2019 17:51:43 UTC+2, Baran Jean-Marie a écrit :
Reply all
Reply to author
Forward
0 new messages