Failed to execute aapt (NoSuchElementException at AbstractIndexedListIterator.next(AbstractIndexedListIterator.java:80)

It is a bug in gradle plugin code that calls AAPT1. It was fixed but not cherry-picked, it should be available in the next released version (it should be fixed in 3.2 canary 3 and newer).
This only affects AAPT1. Removing the android.enableAapt2=false flag will make the code not hit this codepath (check your gradle.properties file and the extra arguments you pass to gradle from Android Studio).


I did below and it solved this issue:

  1. In gradle.properties file:

    android.enableAapt2=false

  2. I disabled the Instant Run.(Important)


In your gradle properties: remove android.enableAapt2=false, and upgrade the buildToolVersion in your app build.gradle and in all the other modules(if used) too.

Run the command gradlew --info assembleDebug in your terminal and check for other errors and if you find them then manually go and fix them. In my case there was a 9 patch image which was causing all the trouble.

Try to clean and rebuild your project.

Or

Try to disable instant run feature and see if it works.

Or

Try and enable multiDexEnabled.

defaultConfig {
    multiDexEnabled true
}

Or

File -> Invalidate caches and restart