Friday, October 30, 2015

Fix Mac boot hanging due to missing var/folders

Although /var/folders" (or "/private/var/folders") is "per-user temporary files and caches", and its content can be cleaned by system at any time, but the var/folders itself cannot be deleted. After I accidentally deleted var/folders fold from my mac, and the box could not reboot successfully.  

By restarting the mac in single user mode (pressing Command+S) in unix shell, I tried to add the var/folders back, however, the mkdir failed as the folder is mounted as readonly. Unfortunately, chflags does not work in this case.

The rescue is
mount -uw

which will mount the folder as read-write. After that, mkdir can successfully create the var/folders again, and the mac can reboot properly. The strange thing is you can delete var/folders using Finder, but you cannot put it back or create a new var/folders folder using Finder.

Sunday, October 18, 2015

Android studio build issues- gradle proxy, file path size, etc

1. When running android studio on Windows, the gradle build may get an error of "No Resource found that matches ..." or "unable to open file ...". 

One possible reason of the error is due to the limitation of the maximal length of the file path. To fix the issue, move the project close to a root folder of the current drive, instead of staying in a deep nested subfolder on the current drive.


2. The android studio only build armv7 apk when running the app on emulator
In Build.gradle, locate productFlavors item and remove the "armv7" element


3. set proxy for gradle
create a text file with name of gradle.properties and put the file under the project's root folder with the content of:

systemProp.http.proxyHost=proxy.phl.sap.corp
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.phl.sap.corp
systemProp.https.proxyPort=8080


4. for the error of "Unable to execute dex: method ID not in [0, 0xffff]"

You need to enable multiDex with the below steps:
First, update android defaultConfig
android {
   defaultConfig {
      ...
      multiDexEnabled = true
   }
}

Then, add multiple dependency
dependencies {
  ...
  compile 'com.android.support:multidex:1.0.0'


5. for the out of memory GC error
Add the below options in Android block
dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}

Friday, October 16, 2015

Show and copy android screen from device to mac

1.download droidAtScreen-1.2.jar from http://droid-at-screen.org/
2.connect the android device with mac and Configure your device to allow USB Debugging from (Settings-> Developer options -> USB debugging)
3.from command line, run
java -jar droidAtScreen-a.b.c.jar

Monday, October 5, 2015

How to move android emulator screen on Windows 8

1. select android emulator screen by mouse
2. press ALT+SPACE
3. while the mouse is shown as + sign, select Move menu
4. release mouse button, and use up, down or left, right key to move emulator screen
5. after press any direction key, then you can also use mouse to move the emulator screen