Issue when using compileSdkPreview "CinnamonBun" and targetSdkPreview "CinnamonBun" in Android


We are currently trying to upgrade the Android SDK version and review possible deprecations and impacts.

When we attempt to use the preview SDK with the following configuration:

compileSdkPreview "CinnamonBun"
targetSdkPreview "CinnamonBun"

we encounter the following error:

Requires libraries and applications that depend on it to compile against version 35 or later of the Android APIs.

:app is currently compiled against android-CinnamonBun.

It seems there is a mismatch between the required Android API version and the preview SDK configuration.

Has anyone faced a similar issue when compiling against the Android preview SDK?
What would be the correct way to resolve this or configure the project properly?

0
Mar 13 at 6:13 AM
User AvatarVijayadhas Chandrasekaran
#android#android-gradle-plugin

Accepted Answer

The problem is usually caused by Android Gradle Plugin (AGP) not fully supporting the preview SDK codename.

When using the Android 17 preview configuration:

compileSdkPreview "CinnamonBun"
targetSdkPreview "CinnamonBun"

Gradle may show an error like:

Requires libraries and applications that depend on it to compile against version 35 or later of the Android APIs.
:app is currently compiled against android-CinnamonBun.

This happens because older AGP versions do not correctly handle preview SDK codenames. The build tooling expects a numeric API level (like 35), so it misinterprets android-CinnamonBun and throws the AAR metadata error.

Solution

Upgrade the Android Gradle Plugin to a version that supports the Android 17 preview SDK.

For example:

Version catalog / plugin config

agp = "8.13.2"

or

plugins {
    id("com.android.application") version "8.13.2" apply false
}

Then use the preview SDK configuration:

android {
    compileSdkPreview "CinnamonBun"

    defaultConfig {
        targetSdkPreview "CinnamonBun"
    }
}

After upgrading AGP, the project should compile correctly against the Android 17 preview SDK.

Recommendation

When working with Android preview SDKs:

  • Use the latest Android Gradle Plugin

  • Use the latest Android Studio preview

  • Install the Android SDK Platform for the preview version

Preview SDKs often require very recent tooling, and older AGP versions can fail even if the configuration is correct.

User AvatarVijayadhas Chandrasekaran
Mar 13 at 9:16 AM
1