Skip to main content

Android Studio 3.1.x — How to fix it

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,
http://www.quickmeme.com/meme/3sghsd
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.
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.
I will keep this article updated.

Update #2

Issue: app module cannot be built with the error message below.
Error: please select Android SDK.
Solution:
Here the steps that I found in StackOverflow that worked:
  1. File — > Invalidate Caches — > Invalidate
  2. File — > Close Project.
  3. Remove the project from the AS project selector window.
  4. Quit from Android Studio
  5. 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

Popular posts from this blog

web2apk

http://web2apk.com/create.aspx Create App   Intro   About   Changes   MalWare ?   Contact   Privacy Useful Links Bluetooth Mini Keyboards Android Mini PC Reset Android URL App Title Icon or

Android Bar Chart Using MpAndroidChart Library Tutorial

https://www.numetriclabz.com/android-bar-chart-using-mpandroidchart-library-tutorial/ Android Bar Chart Using MpAndroidChart Library Tutorial Objective In this tutorial we learn how to implement Bar Chart using MpAndroidChart Library in your Android App. Download Source Code       Step 1 Contents ·        1  Introduction ·        2  Creating Bar chart o    2.1  Create a new Project o    2.2  Adding library in Project o    2.3  Create Layout o    2.4  To Plot Bar Chart §   2.4.1  Initialize the graph id §   2.4.2  Creating a Dataset §   2.4.3  Defining X-axis labels §   2.4.4  Set the data §   2.4.5  Add the description to the chart §   2.4.6  Run your App §   2.4.7  Set the color §   2.4.8  Adding Animations o    2.5  To plot grouped bar chart §   2.5.1  Creating Dataset o    2.6  Get the best of Android plus exclusive deals and freebies in your inbox!

how to retrieve image from sqlite database in android and display in listview

 Android platform provides several ways to store data in our application. 1. SQLite database 2. SharedPreferences etc For our post, we will only work with SQLite database. First and foremost, we need to understand what an SQLite database is? SQLite database  is an open source SQL database that stores data to a text file on a device. It executes SQL Commands to perform a set of functions, that is, create, read, update and delete operations. On my previous post, I showed how to  store data in SQLite database from edit text, retrieve and populate it in a listview . For this post, I will show the SQLite CRUD operations with images from gallery and text from EditText. We need to understand this; images are stored in SQLite database as BLOB data type. A BLOB is a large binary object that can hold a variable amount of data.  Note, we can only store images in the database as BLOB data type. We need to convert our image path to a bitmap then to bytes. Also