Category: Android

Fix: Android emulators not starting in Ubuntu 2

Fix: Android emulators not starting in Ubuntu

Often this happens when for some reason or the other your OpenGL config is broken. This is often an issue on Ubuntu 17.04.

To confirm this is your problem, (Assuming your Android SDK lives in ~/Android/Sdk)

Step 1
Get your emulator’s name:
~/Android/Sdk/emulator/emulator -list-avds

In my case it was Nexus_4_API_25

Step 2
Test running using system OpenGL
~/Android/Sdk/emulator/emulator -avd Nexus_4_API_25 -use-system-libs

If the emulator starts successfully we can make this solution semi-permanent by having a symbolic link in the android Sdk dirs to the system’s openGL

Step 3
cd ~/Android/Sdk/emulator/lib64/libstdc++/
mkdir backup
mv libstdc++.so.6 backup/
ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 .

Voilà, you should now be able to launch your emulator from android studio or anywhere else. In the case of any future updates, you can just run the above commands again.

 

Source: Martin Revert (stackoverflow)

How to fix gradle in Intellij IDEA 0

How to fix gradle in Intellij IDEA

When starting a project in Intellij IDEA if you see an error around the lines of

Gradle sync failed: The newly created daemon process has a different context than expected.
 It won't be possible to reconnect to this daemon. Context mismatch: 
 Java home is different.
 Wanted: DefaultDaemonContext[uid=null,javaHome=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.3.2\jre,daemonRegistryDir=C:\Users\Ronald\.gradle\daemon,pid=7044,idleTimeout=null,daemonOpts=-Xmx1536m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]
 Actual: DefaultDaemonContext[uid=7819e5ac-98ac-4dd2-8891-cacf4e56f662,javaHome=C:\Program Files\Java\jdk1.8.0_112,daemonRegistryDir=C:\Users\Ronald\.gradle\daemon,pid=4720,idleTimeout=60000,daemonOpts=-Xmx1536m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]
 Consult IDE log for more details (Help | Show Log)

The solution would be to explicitly tell grade where your java directory is. You can do this in two places

  1. Open up %USERPROFILE%\.gradle\  and create the file gradle.properties
  2. In your android project create or edit the gradle.properties file

Inside that file put the location of your java path using forwardslashes instead of backslashes

org.gradle.java.home=Your/path/here/with/forwardslashes

In my case it looks like:

org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_112