Android Studio新手遇Gradle构建错误:aaptFriendlyManifestOutputDirectory=null
Hey there, sorry to hear you're stuck with this frustrating Gradle build error—let's work through this step by step. I've run into similar null value glitches with Android Studio before, so here are some actionable fixes to get your build back on track:
Clean & Rebuild your project
Start with the basics: head toBuild > Clean Project, wait for it to finish, then runBuild > Rebuild Project. Corrupted cached build files are often the culprit behind weird null value errors like this, and this step clears them out.Invalidate Caches & Restart Android Studio
Sometimes Android Studio's internal cache holds onto outdated data that a clean build doesn't fix. Go toFile > Invalidate Caches..., check all three available options, then clickInvalidate and Restart. This gives Studio a fresh start and often resolves odd build inconsistencies.Check your app-level build.gradle for misconfigurations
Since the error references the manifest output directory, double-check your app'sbuild.gradlefile for any custom settings related to manifest processing. Look for blocks likeandroid { sourceSets { ... } }ormanifestPlaceholders—make sure none of these are accidentally setting a null value or pointing to a missing folder. Also, confirm that yourcompileSdkVersion,targetSdkVersion, andbuildToolsVersionare compatible (sticking to the latest stable versions you have installed is a safe bet).Update Gradle & Android Gradle Plugin
Outdated versions can cause unexpected compatibility issues. Go toFile > Project Structure > Project, then check theGradle VersionandAndroid Gradle Plugin Versiondropdowns. Update them to the latest stable recommended versions, then sync your project withFile > Sync Project with Gradle Files.Manually delete .gradle and build folders
If the above steps don't work, try deleting the hidden.gradlefolder in your project root, plus thebuildfolders in both the project root andappmodule. Restart Android Studio afterward and sync the project—this forces Gradle to regenerate all build files from scratch, which can fix persistent cache-related problems.
Give these steps a go in order (start with the quickest ones first!). If you still hit a wall, feel free to share more details like your app-level build.gradle code or your Android Studio version, and I can help dig deeper.
内容的提问来源于stack exchange,提问作者JBSchami

