I haven’t posted new content on this site for a few while. The reason is that I’m recently posting on Medium. If you want to get newer contents related to my activity, you can visit my Medium site:
https://medium.com/@voghDev_63848
I’ll keep this site open as it still contains some posts that could be useful for someone in the future
[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 {
ktlint
}
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
[ES]
Men煤 “Administrar versiones”
“Administrar versi贸n de producci贸n”
“Crear versi贸n”
“Subir APK”
“Revisar”
“Iniciar lanzamiento a producci贸n”
“Actualizar lanzamiento”
[EN]
Click on “Manage versions” on the left menu
Then on “Manage production version”
Then “Create version”
“Upload APK”
“Review”
“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
app/build.gradle
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
PATH=$PATH:/home/user/android-sdk/platform-tools:/home/user/java/jdk1.8.0_121/bin
export JAVA_HOME=/home/user/java/jdk1.8.0_121
export STUDIO_JDK=$JAVA_HOME
export JDK_HOME=$JAVA_HOME
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
[Xubuntu] Configuring Start menu in Windows key
Go to Application > Settings > Keyboard
Click on the central tab “Keyboard shortcuts”
Click on “Add”
in Command, enter “xfce4-popup-whiskermenu”
Now set it to “Start (Windows)” key. “Super L” value might appear.
http://lgallardo.com/en/2009/07/18/accesos-rapidos-en-xfce-4keyboard-shortcuts-in-xfce-4/
Tested and working in Xubuntu 14.04 and 16.04.2
[Git] Adding your key to Bitbucket
When using our Bitbucket origin from a new computer, we will usually find this message:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
That’s normal. Bitbucket does not trust our computer yet, we have to add its key to the list of trusted hosts.
If you already have a SSH key, copy it and add it to bitbucket.
First, to copy it, open a terminal and write the following
cd ~/.ssh/
cat id_rsa.pub
Then you will find something like this*
ssh-rsa AAAB3NzaC1yc2EAAAADAQABAAABAQDGf57XkGtFONIn5fskaF1/6obxgLUq3r+lnyUkBJP6qIOyJ+0K[…]OdecdoOL8hQZagq+ff3X23GwfvJPj1Ytf your.mail@company.com
Copy this key in your clipboard, then log in into Bitbucket and do the following:
1.- Click on the user account icon (in the top-right of the screen)
2.- Then on “Bitbucket Settings”
3.- Now, under “Security”, click on “SSH Keys”
4.- Click on “Add key”
5.- Now assign a name to your key (e.g.: “My Laptop key”) and paste your clipboard inside the “Key” field. Click on “Add key”.
* If there is no id_rsa.pub or any .pub files, go to “Generating a new SSH key” section
Generating a new SSH key
In order to generate a new SSH key, write the following
ssh-keygen -t rsa -C “your_mail@company.com”
Generating public/private rsa key pair.
Enter file in which to save the key (/home/olmo/.ssh/id_rsa): mykey
Enter passphrase (empty for no passphrase): passphrase
Enter same passphrase again: passphrase
Your identification has been saved in mykey.
Your public key has been saved in mykey.pub.
[Git] Squashing commits
Taken from here https://ariejan.net/2011/07/05/git-squash-your-latests-commits-into-one/
Summing up:
git rebase -i HEAD~3
What we’re doing is rewriting the history to make 3 commits become a single one.
You can replace 3 by any number of commits to rewrite
pick f392171 Added new feature X
pick ba9dd9a Added new elements to page design
pick df71a27 Updated CSS for new elements
write the word “squash” in the ones that will be squashed
pick f392171 Added new feature X
squash ba9dd9a Added new elements to page design
squash df71a27 Updated CSS for new elements
Then Ctrl+X (if using nano on Linux)
Now another screen will appear, customize the commit message for all squashed commits and Ctrl+X again.