Android Studio 3.0.1遇Gradle刷新失败及URI未注册问题求助
Hey there, let's break down and fix the two problems you're encountering with Android Studio 3.0.1—these are pretty typical hurdles, so we'll work through them step by step.
1. Fixing "Gradle project refresh failed" Error
Since you've already tried reinstalling Studio/SDK and adjusting Gradle paths, let's dive into more targeted solutions:
Verify Gradle Plugin & Version Compatibility
Android Studio 3.0.1 requires the Gradle plugin version3.0.1, paired with Gradle version 4.1 or 4.4 (these are the most stable matches). Double-check your project files:- In your root
build.gradle, ensure the plugin dependency is correct:buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' } } - In
gradle/wrapper/gradle-wrapper.properties, set the matching Gradle distribution URL:distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
- In your root
Clear Android Studio Caches
Corrupted caches often cause refresh failures. Go toFile > Invalidate Caches / Restart, then select Invalidate and Restart. This will clear stale cache files and restart Studio—this alone fixes many Gradle-related glitches.Fix Repository Access Issues
If Gradle can't download dependencies, check your network or switch to a reliable mirror:- Replace the default repositories in your
build.gradlewith domestic mirrors to avoid connectivity issues:repositories { maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/jcenter' } } - If you use a proxy, confirm it's correctly configured in
Settings > Appearance & Behavior > System Settings > HTTP Proxy.
- Replace the default repositories in your
Validate Local Gradle Installation
If you're using a manually specified Gradle directory, make sure the folder is intact (no missing files) and the version matches the plugin requirement. A corrupted Gradle zip can cause silent failures.
2. Resolving "URI not registered" for http://schemas.android.com/apk/res/android
This error usually stems from missing SDK components or incomplete project indexing. Try these fixes:
Resync Your Project with Gradle
Click the Sync Project with Gradle Files button (the elephant icon in the toolbar). This triggers Studio to reindex your project resources and often registers the missing URI automatically.Check SDK Platform Installation
Ensure you have the SDK Platform matching your project'scompileSdkVersioninstalled:- Open
Tools > Android > SDK Manager - Go to the SDK Platforms tab, find the version matching your project's
compileSdkVersion(e.g., if your build.gradle hascompileSdkVersion 26, install Android 8.0 (API 26)) - Click Apply to install the missing platform.
- Open
Fix Project Structure Configuration
Go toFile > Project Structure, then navigate to the Modules tab. Confirm:- The Compile SDK Version matches the installed SDK platform
- The Build Tools Version is compatible (for 3.0.1 plugin, build tools 26.0.2 or later works well)
Manually Register the URI
If the above steps don't work, manually add the schema to Studio:- Go to
Settings > Languages & Frameworks > Schemas and DTDs - Click the
+button in the top-right corner - Enter
http://schemas.android.com/apk/res/androidas the URI - For the "File" field, browse to your local SDK directory, then select
platforms/android-[your compileSdkVersion]/data/res/values/attrs.xml - Click OK to save, then restart Studio.
- Go to
Give these steps a try—they should resolve both issues for you.
内容的提问来源于stack exchange,提问作者user2875874

