android-How to solve java.util.NoSuchElementException in Android Studio

1. The purpose of this post

I would demo how to solve this error when using android studio

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexWithInstantRunDependenciesApkForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)

Caused by: java.util.NoSuchElementException
at com.google.common.collect.AbstractIndexedListIterator.next(AbstractIndexedListIterator.java:80)
at com.google.common.collect.Iterators.getOnlyElement(Iterators.java:315)
at com.google.common.collect.Iterables.getOnlyElement(Iterables.java:263)

2. Environments

  • Android Studio 3.x

3. Solution and Code

Try to disable instant run like this: disable_instant_run_as