从Eclipse迁移至Android Studio后aapt执行失败致Gradle构建出错求助
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.pnganddrawable-hdpi/ic_launcher.pngis fine, but two files namedic_launcher.pngin the same directory isn't) - Check for conflicts with resources in your
signaturePaddependency 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_widhtinstead ofandroid: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!
- Look for unclosed tags, misspelled attributes (e.g.,
Update (or adjust) your Build Tools version
Your currentbuildToolsVersion '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 yourcompileSdkVersionto 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 Restartto clear stale build files.Verify your
signaturePaddependency configuration
Since you're compiling thesignaturePadmodule, make sure its Gradle settings align with your main project. Check that itscompileSdkVersionandbuildToolsVersionmatch yours—version mismatches between modules often cause resource compilation failures. Also, audit the resources insignaturePadusing 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 --infoScan the output for lines starting with
error:—this will point you directly to the problematic resource or XML file.
内容的提问来源于stack exchange,提问作者Vaibhav More

