如何在Cordova(Android平台7)中设置android.enableAapt2=false?
How to set
android.enableAapt2=false in Cordova Android 7 Hey there! I’ve worked with Cordova Android 7 quite a bit, so I can walk you through exactly how to get this flag set up properly—here are two reliable methods, pick the one that fits your workflow best:
Method 1: Add to project-level gradle.properties (persistent, recommended)
- Navigate to the root directory of your Cordova project.
- Look for a file named
gradle.properties—if it doesn’t exist, create a brand new one. - Open the file and add this line at the end:
android.enableAapt2=false - Save the file, then run
cordova prepare androidto apply the changes. This method is ideal because it won’t get overwritten when you remove or re-add the Android platform later.
Method 2: Modify platform-specific Gradle config (for one-off changes)
If you need to target only the Android platform directly (note: this change might get reset if you update or re-add the platform):
- Go to the
platforms/androidfolder in your project. - Open the
gradle.propertiesfile located here. - Add the same line as above:
android.enableAapt2=false - Save the file and rebuild your project with
cordova build android.
A quick side note: AAPT2 is disabled by default in some older Cordova Android versions, but explicitly setting this flag in v7 will ensure your build uses the older AAPT tool exactly as you need it to.
内容的提问来源于stack exchange,提问作者Sujeet Shetty
相关产品推荐
相关产品推荐

