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

后端 未结 5 809
小蘑菇
小蘑菇 2020-12-03 07:18

The project gets built without error from Android Studio -> Build -> Build APKs and after installation it works fine. But running the project with a Run Configuration gives

相关标签:
5条回答
  • 2020-12-03 07:57

    You can follow any of the following ways to fix the issue:

    For Android studio 3.1 or <3.2

    1. Update gradle.properties file with android.enableAapt2=false
    2. Disable Instant Run(Ctrl+shift+A(win+Linux) or Command+shift+A(Mac) then search for Instant run).

    For Android studio 3.2 or later

    1. Update Android studio to 3.2
    2. Update gradle.properties file with android.enableAapt2=true
    3. You can keep remain enable the Instant run now.
    0 讨论(0)
  • 2020-12-03 08:03

    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).

    0 讨论(0)
  • 2020-12-03 08:04

    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

    0 讨论(0)
  • 2020-12-03 08:18

    Open the File tab and then click on Invalidate Caches \ Restart. It worked for me :).

    0 讨论(0)
  • 2020-12-03 08:22

    I did below and it solved this issue:

    1. In gradle.properties file:

      android.enableAapt2=false

    2. I disabled the Instant Run.(Important)

    0 讨论(0)
提交回复
热议问题