๐ŸŒฑ Android Development for Beginners

Android SDK vs JDK vs Gradle: What's the Difference?

SDK, JDK, Gradle, AGP, compileSdk, the Gradle JVM... Android build errors are full of acronyms. This guide explains what each piece is, how they cooperate when you press Run, and how to read and fix the version errors that confuse beginners.

โœ๏ธ Yunok Tech ๐Ÿ“… Updated โฑ 5 min read ๐ŸŽฏ Beginner
On this page
  1. The one-line definitions
  2. The JDK: what Gradle runs on
  3. Gradle and the wrapper
  4. The Android Gradle Plugin (AGP)
  5. compileSdk, minSdk and targetSdk
  6. Version catalogs: one place for dependency versions
  7. Reading and fixing common build errors
  8. Real situations
  9. Frequently asked questions
  10. Conclusion

You press Run and see: "Android Gradle plugin requires Java 17 to run", or "compileSdk 34 is lower than the version required by dependency X". To fix errors like these with confidence, you need a clear mental model of the build tools.

This article explains the Android SDK, the JDK, Gradle and the Android Gradle Plugin (AGP), plus the three SDK version settings in every Android project, using a real build file as the reference.

The one-line definitions

ToolWhat it isAnalogy
JDKJava Development Kit: the Java runtime and compiler tools that Gradle and the Kotlin compiler run onThe engine the workshop machines run on
GradleA general-purpose build automation tool: runs tasks, resolves dependencies, caches resultsThe workshop manager scheduling jobs
AGPAndroid Gradle Plugin: teaches Gradle how to build Android apps (resources, DEX, signing, APK/AAB)The Android-specific machinery
Android SDKAndroid platform APIs (android.jar per API level), build tools, platform-tools (adb), emulatorThe parts catalogue and test bench
How the JDK, Gradle, AGP and the Android SDK cooperate in a build The JDK runs Gradle. Gradle loads the Android Gradle Plugin, which uses the Android SDK to compile against android.jar, process resources, convert bytecode to DEX with D8 or R8, and package and sign an APK or AAB. JDK runs Gradle loads AGPAndroid plugin uses Android SDK + build steps 1. compile Kotlin vs android.jar 2. process resources (AAPT2) 3. D8/R8 โ†’ DEX bytecode 4. package + sign โ†’ APK / AAB 5. adb installs on device
Each layer has its own version, and most build errors are a version mismatch between two adjacent boxes.

The JDK: what Gradle runs on

Android apps don't run on a desktop JVM, but the build does. Gradle, the Kotlin compiler and AGP are JVM programs, so they need a JDK. Recent AGP versions require a minimum JDK version to run. Android Studio bundles a suitable JDK (the JetBrains Runtime) and uses it by default.

Two different "Java versions" appear in a project, and mixing them up causes most confusion:

  • The Gradle JDK, which runs the build. It's set in Android Studio under Settings โ†’ Build Tools โ†’ Gradle โ†’ Gradle JDK, or with a toolchain.
  • The Java/Kotlin target (jvmTarget, sourceCompatibility), which is the bytecode level your code is compiled to. Android's toolchain supports it through desugaring.

Gradle and the wrapper

Each project pins its Gradle version in gradle/wrapper/gradle-wrapper.properties. The Gradle wrapper (gradlew) downloads exactly that version, so every developer and CI machine builds with the same Gradle.

gradle/wrapper/gradle-wrapper.propertiesProperties
distributionUrl=https\://services.gradle.org/distributions/gradle-<version>-bin.zip
Terminal: build without the IDEShell
./gradlew assembleDebug        # build a debug APK
./gradlew testDebugUnitTest    # run local unit tests
./gradlew --version            # shows Gradle, Kotlin and JVM versions in use

The Android Gradle Plugin (AGP)

AGP adds the android { } block and Android-specific tasks. AGP versions are tied to minimum Gradle versions, minimum JDK versions and supported Android Studio versions. Google publishes a compatibility table in the AGP release notes. Use the AGP Upgrade Assistant in Android Studio to move between versions safely.

compileSdk, minSdk and targetSdk

app/build.gradle.ktsGradle KTS
android {
    namespace = "com.example.notes"
    compileSdk = 36                 // APIs you can CALL in code (compile against this android.jar)

    defaultConfig {
        applicationId = "com.example.notes"
        minSdk = 24                 // oldest Android version that can INSTALL the app
        targetSdk = 36              // Android version whose BEHAVIOUR changes you've tested
        versionCode = 1
        versionName = "1.0"
    }
}
SettingControlsPractical rule
compileSdkWhich APIs exist at compile timeUse the latest stable SDK. Newer libraries often require it.
minSdkWho can install the appA product decision: balance reach against development cost. Guard newer APIs with version checks.
targetSdkWhich behaviour changes apply to your appKeep it recent. Google Play requires new apps and updates to target a recent API level.

The values above are examples. Check the current Google Play target API requirement before each release.

Calling a newer API safely when minSdk is lowerKotlin
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
    // POST_NOTIFICATIONS runtime permission exists only on Android 13 (API 33)+
    permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}

Version catalogs: one place for dependency versions

gradle/libs.versions.tomlTOML
[versions]
agp = "<agp-version>"
kotlin = "<kotlin-version>"
composeBom = "<bom-version>"

[libraries]
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
app/build.gradle.ktsGradle KTS
dependencies {
    implementation(platform(libs.androidx.compose.bom))   // BOM aligns all Compose library versions
    implementation(libs.androidx.material3)
}

Reading and fixing common build errors

Error message (paraphrased)Which layerFix
"Android Gradle plugin requires Java N to run"JDK โ†” AGPSet Gradle JDK to the bundled JDK or JDK N+
"Minimum supported Gradle version is X"Gradle โ†” AGPUpdate distributionUrl, or use the Upgrade Assistant
"Dependency requires compileSdk X or later"Library โ†” SDKRaise compileSdk and install that SDK platform
"Failed to find target with hash string 'android-X'"SDKInstall the platform in the SDK Manager
"Inconsistent JVM-target compatibility"Kotlin โ†” Java targetAlign jvmTarget and compileOptions, or use a toolchain
"Unresolved reference" after adding a libraryDependenciesSync Gradle; check the artifact name, version and repository

Real situations

Cloning an old GitHub project

It pins an old AGP that doesn't support your JDK. Either use a matching older JDK for that project, or upgrade AGP and Gradle with the Upgrade Assistant and fix deprecations.

CI build fails, local build works

CI uses a different JDK. Pin the JDK in the CI workflow (for example the setup-java action) and rely on the Gradle wrapper.

Play Console rejects an update

The target API is too old for current Play requirements. Raise targetSdk and test the behaviour changes for that Android version.

Frequently asked questions

Is the Android SDK the same as the JDK?

No. The JDK provides Java tooling that runs the build. The Android SDK provides the Android APIs, build tools and device tools. You need both.

Should compileSdk and targetSdk always match?

Often they do, but they mean different things. You can compile against a newer SDK before you've finished testing its behaviour changes, then raise targetSdk.

Do I need to install Gradle globally?

No. Use the project's Gradle wrapper (./gradlew), which downloads the correct version automatically.

What's the difference between Groovy and Kotlin DSL build files?

Both configure the same build. Kotlin DSL (.kts) is the default for new projects and offers better IDE completion and type safety.

Conclusion

The JDK runs Gradle, Gradle runs AGP, and AGP uses the Android SDK to compile, dex, package and sign your app. Each has its own version, and most build errors are a mismatch between two of them. Read the error, identify the layer, and fix the version at that boundary.

Next step: open your project's libs.versions.toml and gradle-wrapper.properties and identify each version. Then learn what happens after the build in How an Android App Works Internally.

Official references

๐Ÿ“ฑ Apps built by Yunok Tech

Real Android apps on Google Play, free to download.

See all our apps โ†’

Ready to build real Android applications?

Reading a roadmap is the easy part. The real progress happens when you build a foundation step by step, with someone reviewing your code and answering the questions that come up along the way.

Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.

Explore the Android course and take your next step as an Android developer.

Share: LinkedIn X / Twitter WhatsApp