Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio: I am getting the following error "java.util.NoSuchElementException".However, I can't trace the error

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.

like image 313
Curt Rand Avatar asked Mar 27 '18 23:03

Curt Rand


People also ask

How do I fix Java Util NoSuchElementException?

Solution. The solution to this​ exception is to check whether the next position of an iterable is filled or empty. You should only move to this position if the check returns that the position is not empty.

What is the cause of a NoSuchElementException?

Cause for NosuchElementException If you call the nextElement() method of the Enumeration class on an empty enumeration object or, if the current position is at the end of the Enumeration, a NosuchElementException is generated at run time.

What is NoSuchElementException in Java scanner?

The NoSuchElementException is thrown by Scanner class, Iterator interface, Enumerator interface, and StringTokenizer class. These classes have accessors' methods to fetch the next element from an iterable. They throw NoSuchElementException if the iterable is empty or has reached the maximum limit.


2 Answers

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

like image 63
M. Arabi Hasan Sakib Avatar answered Sep 28 '22 00:09

M. Arabi Hasan Sakib


try adding this to your gradle.properties file

android.enableAapt2=true
like image 20
Akshay Shah Avatar answered Sep 27 '22 22:09

Akshay Shah