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
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.
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.
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)
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.
Update #5
Issue: I encountered below issue when try to build the app.
Write access is allowed from event dispatch thread only
Update #6
Issue:
Error while executing: am start -n “SplashActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=SplashActivity }
Error type 3
Error: Activity class {SplashActivity} does not exist.
Error while Launching activity
Possible cause:
- You installed the current app to different user. you can have owner user and guest user or more user as you added
So if you install the app for owner and try to re-install the app for Guest user, you will see the error.
Solution:
Switch to the user where the app was install before re-install the app, or delete the old app from the unwanted user.
- Another cause is that your application was not properly uninstalled.
Solution:
You can go to setting -> Apps & notifications -> select the app -> then uninstalled the app
Update #7
Issue:
Sometime, when I run the Android emulator, I do not see any logs in logcat; at the end of the log, there’s an error:
Update #9
Issue:
Error: Failed to open zip file.
Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync product (requires network)
Solution:
- Delete all gradle folder in:
Linux or Mac: ~/.gradle/wrapper/dists
(~ is the home directory)
Windows: C:\Users\{user-name}\.gradle\wrapper\dists
- Restart Android Studio