Thursday, January 12, 2017

Feedback page for my basic Android Web app development project


As said on the project page, you are invited to post here if you find problems of any kind in the project.
Just please first search the comments of this entry to see if somebody has posted your problem before. This way, if it has already been posted, you'll spare me some time (to read and direct you to the relevant comments) and you'll spare yourself some time (to post your comment and wait for me to answer it).

2 comments:

V. Sim. said...

Studio hangs after creating a new project

I'll make the start, with the problem that I've encountered most often, as said on my Web app project page.

After opening a Studio project, Gradle sync and afterwards Gradle build are executed automatically. If it's a new project, that is these processes are done for the first time on the given project, they last a lot longer. Quite often in my experience it happens that Studio hangs at this point. It seems to have stopped working in the background for some time, like 10 minutes, but it shows that it's still working (but the status bar indication doesn't change).

First you try the usual tricks, close the project and open it again, close Studio (from Task manager if necessary) and reopen it, restart your system. Also, Clean project (from the Build menu) often fixes such situations.
If these don't work (after repeating them a few times):

I've found 3 things to do, so far they've helped solve any of the 2 such situations I've had.

First, if you're short of RAM (less than 2G), otherwise you can skip this.
Open gradle.properties, which you find in the project structure pane, directly under the app name. You will find a line that says something like

org.gradle.jvmargs=-Xmx1536m

I'm not sure the value after Xmx will always be the same. Anyway, change it to something like Xmx500m .

Second, make sure you have at least 5G free on the system volume.

3rd, if it still hangs, look in the Gradle console in the lower right corner of the project window. If you find exceptions that look like

Exception in thread "png-cruncher_4" java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at C:\Users\android\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe can run successfully (some anti-virus may block it) or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds

then try what Studio suggests, 1. check your anti-viruses and 2. set environment variable SLAVE_AAPT_TIMEOUT to a bigger value, like 30 instead of 5 (seconds).

As said, these worked for me. If you try them and still no luck, take a look at this thread:

https://code.google.com/p/android/issues/detail?id=188627

One can see many people having the same problem and trying various fixes, some work for some, others don't but usually everybody solves it some way. So there's hope for you too.

Anonymous said...

Thanks for writing a clear and (even better) working example for this simple app - it's exactly what I was looking for - you're a star!