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

从Eclipse迁移至Android Studio后aapt执行失败致Gradle构建出错求助

Fixing AAPT Non-Zero Exit Value 1 After Importing from Eclipse to Android Studio

Hey, let's work through this frustrating build error you're hitting. That aapt finished with non-zero exit value 1 almost always ties back to resource-related issues—here are the most common fixes to try, tailored to your Eclipse-to-Android Studio import scenario:

  • Audit your resource files and names
    Android Studio enforces stricter rules for resource naming than Eclipse. Make sure all your drawable, layout, and value files:

    • Use only lowercase letters, numbers, and underscores (no uppercase, spaces, or special characters like hyphens)
    • Don't have duplicate names across different resource directories (e.g., drawable/ic_launcher.png and drawable-hdpi/ic_launcher.png is fine, but two files named ic_launcher.png in the same directory isn't)
    • Check for conflicts with resources in your signaturePad dependency module too—duplicate resource IDs between modules will trigger this error.
  • Hunt down XML syntax mistakes
    Even tiny XML errors can break aapt. Go through all your layout, strings.xml, styles.xml, and other resource files:

    • Look for unclosed tags, misspelled attributes (e.g., android:layout_widht instead of android:layout_width)
    • Ensure special characters in strings are escaped (like replacing & with &)
    • Android Studio will usually highlight these errors with red squiggles—don't ignore them!
  • Update (or adjust) your Build Tools version
    Your current buildToolsVersion '19.1.0' is pretty outdated, which can lead to compatibility issues with newer Android Studio versions. Try upgrading to a more recent, compatible version (and match your compileSdkVersion to it):

    android {
        compileSdkVersion 28
        buildToolsVersion '28.0.3'
        defaultConfig {
            minSdkVersion 7
            targetSdkVersion 28
        }
        // Keep your existing buildTypes configuration
    }
    

    If upgrading causes new issues, try cleaning your project cache first: go to File > Invalidate Caches... > Invalidate and Restart to clear stale build files.

  • Verify your signaturePad dependency configuration
    Since you're compiling the signaturePad module, make sure its Gradle settings align with your main project. Check that its compileSdkVersion and buildToolsVersion match yours—version mismatches between modules often cause resource compilation failures. Also, audit the resources in signaturePad using the same rules as your main project.

  • Get detailed error logs
    The default error message doesn't tell you the root cause. Run this command in Android Studio's Terminal tab to get a full breakdown of what's breaking aapt:

    # Linux/Mac
    ./gradlew assembleDebug --info
    
    # Windows
    gradlew.bat assembleDebug --info
    

    Scan the output for lines starting with error:—this will point you directly to the problematic resource or XML file.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 03:49:56