Android Studio 3.2 Canary11中kapt搭配databinding 3.2.0-alpha11无法构建运行
The Issue
When working with Android Studio 3.2 Canary11 paired with Gradle Plugin 3.2.0-alpha11, you’ll run into a build failure when using kapt alongside DataBinding. The core problem is that the build system can’t locate com.android.databinding:compiler:3.2.0-alpha11, which causes the :app:kaptGenerateStubsDevDebugKotlin task to crash. The exact error message is:
Execution failed for task ':app:kaptGenerateStubsDevDebugKotlin'. Could not resolve all files for configuration ':app:kapt'. Could not find com.android.databinding:compiler:3.2.0-alpha11. Searched in the following locations: file:/Users/xxxx/Library/Android/sdk/extras/m2repository/com/android/databinding/com...
Notably, switching back to version 3.2.0-alpha10 resolves the issue entirely.
Solutions to Try (Ordered by Priority)
Add the Google Maven Repository
Alpha versions of the DataBinding Compiler are hosted on Google’s Maven repo, not the older Android SDK extras repository. Ensure your project-levelbuild.gradleincludes this critical repo:allprojects { repositories { google() // Required for accessing alpha dependencies jcenter() // Any other repositories your project needs... } }If you prefer the legacy syntax,
maven { url 'https://maven.google.com' }works too, butgoogle()is the recommended shorthand.Explicitly Align DataBinding Compiler Version with AGP
In your module-levelbuild.gradle, explicitly set the compiler version to match your Android Gradle Plugin (AGP) version. This eliminates version mismatches that can break dependency resolution:android { dataBinding { enabled = true } } dependencies { // Match this exactly to your AGP version (3.2.0-alpha11 here) kapt "com.android.databinding:compiler:3.2.0-alpha11" // Optional: Use a variable to keep versions in sync automatically // kapt "com.android.databinding:compiler:$agp_version" }Clear Caches and Resync
Cached data often causes weird dependency resolution glitches. Try these steps to reset:- Go to
File > Invalidate Caches / Restartand selectInvalidate and Restartto clear Android Studio’s internal caches. - Manually delete the
.gradlefolder in your project root and thebuildfolder in your module directory. - Run a Gradle Sync again to fetch fresh copies of all dependencies.
- Go to
Temporarily Downgrade to 3.2.0-alpha10
If the above fixes don’t work, roll back your AGP and DataBinding versions to 3.2.0-alpha10 to get your project running while Google addresses the alpha11 issue. Update your project-levelbuild.gradle:dependencies { classpath 'com.android.tools.build:gradle:3.2.0-alpha10' }Adjust the compiler version in your module-level
build.gradleif you explicitly set it earlier.
Why This Happens
Most cases boil down to two root causes:
- Missing Google Maven repository configuration, so the build system can’t locate the alpha version of the compiler.
- A temporary sync delay with Google’s Maven repo, where the 3.2.0-alpha11 compiler hasn’t fully propagated to all mirror locations yet.
内容的提问来源于stack exchange,提问作者TeeTracker

