I am working in an android project with Android Studio 2.2 that uses OpenCV 3.1.0 library. I imported the library according to this answer. The situation is the following:
Gradle log
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
> java.lang.ClassNotFoundException: android.hardware.camera2.CameraAccessException
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)...
I found these similar questions:
In both of them the solution was to set the compileSdkVersion
to minimum 21 (the version where camera2
API was introduced) and make sure that build.gradle
files of the project and OpenCV match.
Unfortunately, it does not work for me. I still get the same error. Any idea?
My code is available here: Github repository.
Thanks for your help!
Finally, I found a temporal solution thanks to @JavierMollá.
Switching off Instant Run solved the issue. Go to File > Settings > Build, Execution, Deployment > InstantRun
and uncheck Enable Instant Run to hot swap code...
.
Instant Run is a major feature of Android Studio, but unfortunately it seems that it is still work-in-progress... As @AndreKR suggests, it can be related with this issue #212672.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With