My team and I have been very excited about Google’s new release of Android Studio 3.1. We have decided to upgraded from Android Studio 3.0.1 to it immediately once it was available in Stable channel without expecting any major problems. Little did we know,
Stable release from Google doesn’t always mean bug free
I am going to discuss about my experience with Google’s Android Studio 3.1.; what’s new about it, what are the issues to expect, and how my team and I have managed to solve them.
Let us begin with Android Studio 3.1. new main features:
- C++ performance profiler : helps troubleshoot performance issues in app code.
- Better code support editor in SQL table and query creation statements for Room or SQLite database
- Added better lint support for Kotlin code
For more new features see: Release Note
Here are some issues we encountered after upgrading to Android Studio 3.1:
Issue #1: “Run” not compiling code
OR
Issue #2: Session ‘app’: Error Installing APK
These two issues (#1 and #2)seem to appear like bugs. The reason behind is either the code does not compile or Android Studio has failed to install the app.
Suggested solution: manually add Gradle-aware Make in Run/Debug Configuration.
Select Run and click Edit Configurations
Make sure, Gradle-aware Make is Added in TaskList or not. If not then:
- click +
- select Gradle-aware Make
- Leave the task empty and select OK
NOTE: Make sure Gradle-aware Make is before Instant App Provision
Issue #3: APK file does not exist on disk
What happened here is because APK file has not been created and there is no error message to show. So, in order to see what went wrong, click on Toggle View on the left side menu (see image below). You will see a list of error messages.
Note: Some might suggest to disable Instant Run. It might help in some cases. However we need to keep in mind that Instant Run is one of the most useful features in Android Studio to speed up build process.
Bonus
Here are some solutions to try out if you are having problems building Android project (not just on Android Studio 3.1):
- Sync / refresh Gradle
- Build → Rebuild
- File → invalidate caches / restart
- Delete .gradle folder
(Please note that you can try either one of the solution. You might not need to do all of them in this order.)
Note: Don’t worry, this .gradle folder will be generated automatically by Android Studio after your Gradle is synced successfully. In some cases, you might need to delete .gradle folder and re-sync it to make sure your Gradle is updated successfully.
Update #1
There was a situation when I ran my app in Android Emulator, and I tried to attach debug, my application crashed.
First Solution:
Restart your Android Emulator or use another Android Emulator.
Restart your Android Emulator or use another Android Emulator.
Second solution: Cold boot your Android Emulator
In Android Studio Menu Bar, select Tool → AVD Manager then find your Android Emulator. In Actions column, select drop down icon then click on Cold Boot Now.
In Android Studio Menu Bar, select Tool → AVD Manager then find your Android Emulator. In Actions column, select drop down icon then click on Cold Boot Now.
I will keep this article updated.
Update #2
Issue: app module cannot be built with the error message below.
Error: please select Android SDK.
Error: please select Android SDK.
Solution:
Here the steps that I found in StackOverflow that worked:
- File — > Invalidate Caches — > Invalidate
- File — > Close Project.
- Remove the project from the AS project selector window.
- Quit from Android Studio
- Start Android Studio and open project again
Update #3
Issue: I encountered below issue when try to build the app.
Circular dependency between the following tasks:
:compileTestGroovy
+--- :compileTestJava
| \--- :compileTestGroovy (*)
\--- :compileTestScala
\--- :compileTestJava (*)
(*) - details omitted (listed previously)
Solution: Disable Instant Run did the trick.
Update #4
Issue: I encountered below issue when try to build the app.
android studio Run Configuration Error: Broken configuration due to unavailable plugin or invalid configuration data.
Solution: Make sure android support plugin is checked in plugins section under preferences.
Update #5
Issue: I encountered below issue when try to build the app.
Write access is allowed from event dispatch thread only
Solution: Seems like android studio conflicted with my installed JDK version, so I need to make sure to use embedded JDK version in android studio SDK Location.
Comments
Post a Comment