You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio更新后执行aapt失败,运行报错求助

Fixing AAPT Execution Failure & Theme Resolution Issues After Android Studio Update

Hey there, let's work through these two issues you're facing post-update—they're pretty typical when Studio gets a refresh, so we'll get you sorted out.

1. Resolving AAPT Execution Failure (Runs Fail Even After Clean/Rebuild)

Even though Clean and Rebuild complete successfully, runtime AAPT errors usually stem from version mismatches or lingering cache issues. Try these steps in order:

  • Align SDK Build Tools with Compile SDK Version
    Open your app-level build.gradle file and check these lines:

    android {
        compileSdkVersion 34 // Use your project's target SDK version
        // Either remove buildToolsVersion (Studio auto-picks compatible version) or set it to match compileSdk
        // buildToolsVersion "34.0.0"
    }
    

    If you keep buildToolsVersion, make sure it’s the latest stable version available in your SDK Manager. You can open SDK Manager via Tools → SDK Manager → SDK Tools and update Android SDK Build Tools to the newest non-preview version.

  • Wipe All Caches (More Thorough Than Invalidate)
    Sometimes the standard Invalidate isn’t enough. Do this:

    1. Close Android Studio completely.
    2. Delete these folders:
      • Project root: .gradle and build (both project-level and app-level)
      • Studio system cache: On Windows it’s C:\Users\<YourName>\.AndroidStudio<Version>\system\caches; on Mac it’s ~/Library/Caches/Google/AndroidStudio<Version>
    3. Restart Studio and re-sync your project.
  • Check Gradle Plugin Compatibility
    Open your project-level build.gradle file and ensure the Android Gradle Plugin version matches your Studio version:

    buildscript {
        dependencies {
            classpath 'com.android.tools.build:gradle:8.2.0' // Adjust to match your Studio version
        }
    }
    

    Newer Studio versions require newer plugin versions—if you updated Studio to the latest stable release, grab the corresponding plugin version from the built-in suggestions (Studio will usually flag this with a tooltip).

  • Scan for Hidden Resource Errors
    AAPT can fail at runtime if there’s a subtle resource issue that Rebuild doesn’t catch. Run this command in your project root terminal to lint for problems:

    ./gradlew lint
    

    Look for errors related to XML syntax, duplicate resources, or invalid vector drawables—fix those and try running again.

2. Fixing "Theme Cannot Be Resolved to a Symbol" in styles.xml (No Rebuild Errors)

This is almost always an IDE indexing glitch, but let’s rule out real issues first:

  • Sync Gradle & Refresh Index
    Click the Sync Project with Gradle Files button (the elephant icon in the top toolbar) or right-click your project → Sync with Gradle Files. This often clears up false IDE warnings.

  • Verify Theme Dependencies
    If you’re using a Material Components theme (like Theme.MaterialComponents.*), make sure you have the Material library added to your app-level build.gradle:

    dependencies {
        implementation 'com.google.android.material:material:1.11.0' // Use latest stable version
    }
    

    Sync after adding this—missing dependencies can cause IDE-level theme resolution errors even if Rebuild works.

  • Reset IDE Index Completely
    If the warning persists:

    1. Close Studio.
    2. Delete the .idea folder in your project root.
    3. Re-open Studio and import your project again. This forces Studio to rebuild its entire index from scratch.

内容的提问来源于stack exchange,提问作者user9353624

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:55:11