Android studio: I am getting the following error “

2019-02-09 01:47发布

问题:

I am getting the following error

java.util.NoSuchElementException

When I click on it to reveal more information, this is what it says.

Caused by: java.util.NoSuchElementException

Unlike previous errors, it doesn't show where the error is coming from. How do I fix this issue? I am looking through all my files and nothing seems to be giving me an error. Any tips or suggestions are appreciated.

回答1:

@Izabela is right. However, in my case, I navigated to File -> Settings -> Build,Execution,Deployment -> Instant Run and disabled it by simply unchecking the topmost checkbox (which was enabled by default). Its working perfectly for me (till now). I am running Android Studio 3.0.1 on Ubuntu 16.04 LTS.



回答2:

try adding this to your gradle.properties file

android.enableAapt2=true


回答3:

There are two ways to fix this issue:

1st approach 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).

2nd approach 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.