Deprecated: Return type of PMXI_Config::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/dh_4am2ce/vsaytech.com/wp-content/plugins/wp-all-import/classes/config.php on line 85

Deprecated: Optional parameter $featured_image declared before required parameter $asset_id is implicitly treated as a required parameter in /home/dh_4am2ce/vsaytech.com/wp-content/plugins/boldgrid-inspirations/includes/class-boldgrid-inspirations-asset-manager.php on line 400

Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/dh_4am2ce/vsaytech.com/wp-content/plugins/boldgrid-inspirations/includes/config/survey.config.php on line 24
Android Studio — How to fix it - VSayTech

Android

Android Studio — 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...

Written by Vortana Say · 3 min read

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
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 ToolAVD 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.

Update #5

Issue: I had below issue when try to build the app.

buildOutput.apkData must not be null

Solution: clean and re-make the android project.

Build -> Clean Project

Build -> Make Project

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:

Solution:

In the emulator, go to developer options and set logger sizes per log buffer to max, in my case I set to 16M.
Then restart android emulator. Refer to images below as references:

Update #8

Issue:

Error running ‘app’: Default Activity not found

Solution:

Option 1: Clear cache folder inside AndroidStudio and rebuild your project.

Option 2:

  • Go to Edit Configuration
  • -> Select your Application Module
  • -> Under Launch Options
  • -> Select Nothing from Launch drop down.

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