Android Studio构建报错:无法下载bundletool.jar
Hey there! As someone new to Android Studio, this dependency download error can feel frustrating, but let's work through it step by step:
1. Update the Bundletool Version (Most Likely Fix)
The version 0.1.0-alpha01 is an extremely early, unstable alpha release that's probably no longer hosted in official Maven repositories. Let's switch to a stable, supported version:
- Open your project root directory's
build.gradlefile (not the one inside your app module). - Look for the
buildscriptblock'sdependenciessection. You'll see a line like this:classpath 'com.android.tools.build:bundletool:0.1.0-alpha01' - Replace it with a recent stable version (e.g.,
1.15.0– you can check for the latest stable version via Android Studio's dependency suggestions):classpath 'com.android.tools.build:bundletool:1.15.0' - Click "Sync Project with Gradle Files" (the elephant icon in the toolbar) to apply changes.
2. Verify Maven Repository Configurations
Bundletool is hosted on Google's Maven repository, so make sure your project is set to pull from it:
- In the same root
build.gradlefile, check both thebuildscriptandallprojectsblocks'repositoriessections. Ensure they include:repositories { google() mavenCentral() } - If
google()was missing, add it, then sync the project again.
3. Clear Gradle's Local Cache
Sometimes corrupted cache files cause download issues. Let's do a deeper clean than just "Invalidate Caches/Restart":
- Close Android Studio.
- Navigate to your local Gradle cache directory:
- Windows:
C:\Users\<YourUsername>\.gradle\caches - Mac/Linux:
~/.gradle/caches
- Windows:
- Delete the
modules-2folder (this stores downloaded dependency files). - Reopen Android Studio and sync the project again.
4. Manual Download (Last Resort)
If you absolutely need to use 0.1.0-alpha01 (not recommended), you can manually place the jar in Gradle's cache:
- Download the
bundletool-0.1.0-alpha01.jarfrom Google's Maven repository. - Navigate to
~/.gradle/caches/modules-2/files-2.1/com.android.tools.build/bundletool/0.1.0-alpha01(create the directories if they don't exist). - Place the downloaded jar in this folder – you may need to match the existing hash-named subfolder (if one exists) or create a new one with the correct hash for the file.
A quick tip for future projects: Stick to stable release versions of dependencies whenever possible, as alpha/beta versions are often removed or replaced once stable builds are available.
内容的提问来源于stack exchange,提问作者Daniel Rika

