[Android Studio] Red cross (X) in app module

This issue has been annoying me for a while now. It’s present in many of my projects, in various 3.1.x versions of Android Studio. Solutions can be found in this thread and the ones that best worked for me are in this comment:

Copying and Pasting:

I’m having this error so often, and I find myself coming to this page again and again. Let me just collect the different answers that worked for me.

[Solution 1] Combines the ones that @TheAnonymous010 and @Farwa proposed

1.- File > Sync project with Gradle Files

2.- Build > Clean Project, Build > Rebuild Project

[Solution 2] Recreating Gradle folder

1.- File > Close Project

2.- You will see a small Android Studio window with a list of projects on the left, click on the “X” mark next to your current project (the one you’re working on)

3.- Now choose “Open an existing Android Studio Project” and re-open it from zero. After the “Indexing…” phase, you’ll probably get your app module back to work

[Android] Configuring ktlint for your Android project (Kotlin)

1.- app/build.gradle

android {
// …

configurations {

2.- Add dependency and these two blocks

dependencies {
// …
ktlint “com.github.shyiko:ktlint:0.15.0”

task ktlint(type: JavaExec) {
main = “com.github.shyiko.ktlint.Main”
classpath = configurations.ktlint
args “src/**/*.kt”

check.dependsOn ktlint

task ktlintFormat(type: JavaExec) {
main = “com.github.shyiko.ktlint.Main”
classpath = configurations.ktlint
args “-F”, “src/**/*.kt”

[Android] AutoCompleteTextView not showing suggestions in Kotlin

It’s been a long time without posting 馃檪 Today I’ll comment one of these stupid issues that make you waste several hours.

I was implementing an AutoCompleteTextView in my Android App, written in Kotlin. Given an arbitrary array of Strings (let’s say, country names), I was setting the adapter like this:

autoCompleteTextView?.apply {
setAdapter(ArrayAdapter(context, android.R.layout.simple_expandable_list_item_1, R.array.countries))

Note the last parameter: It is not a string array, but a Resource ID*

All I had to do is to pass a String array instead of the ResourceId. So I resolved it like this

autoCompleteTextView?.apply {
setAdapter(ArrayAdapter(context, android.R.layout.simple_expandable_list_item_1, resources.getStringArray(R.array.countries)))

I wasted several time discovering where the problem was!

Hope you find this useful 馃檪

Have a nice coding day!


* Compiler does not complain about this because there is a consturctor for ArrayAdapter that accepts a resource ID as third parameter, but that’s the ID of the TextView containing the suggestion.

[Android] Upload APK in new Google Play panel


Men煤 “Administrar versiones”
“Administrar versi贸n de producci贸n”
“Crear versi贸n”
“Subir APK”
“Iniciar lanzamiento a producci贸n”
“Actualizar lanzamiento”


Click on “Manage versions” on the left menu
Then on “Manage production version”
Then “Create version”
“Upload APK”
“Iniciar lanzamiento a producci贸n”
“Update launch”

[Android] Kotlin + Dagger2: Unresolved reference AppComponent when generating signed APK

I was having this error when deploying a signed APK of my App, running and debugging were both working fine.
After two hours fighting this issue, this was the solution


kapt {
generateStubs = true

dependencies {

I placed the “kapt” block before the “dependencies” one and after “android”. Now I can deploy signed APKs

[Ubuntu] Adding a folder to your path permantently

After various incorrect SO answers, I’ve found the right solution for ubuntu 16.04 LTS.

cd ~
cat .profile

edit .profile file and add these lines

export JAVA_HOME=/home/user/java/jdk1.8.0_121

Then Ctrl+X and save

After rebooting my machine (closing the terminal didn’t work, I don’t know if closing session will be enough, but anyway my machine boots in 15 seconds so rebooting is quite fast :P) I can work with the new path. To check it:

java -version

should return the correct version of Java installed