Sunday, June 16, 2013

Terminal: adjusting prompt and PATH variables

You will find yourself using Terminal a lot, so it is important that when it opens it is just right for you.
To change your settings in Terminal, I change .profile, but you can go specifically for .bashrc
I use GNU nano because I hate vi.

Last login: Sun Jun 16 09:18:46 on ttys003
$ nano ~/.profile


  GNU nano 2.0.6                               File: /Users/uki/.profile                                                                  

# Adjust prompt.
# \d – Current date
# \t – Current time
# \h – Host name
# \# – Command number
# \u – User name
# \W – Current working directory (ie: Desktop/)
# \w – Current working directory, full path (ie: /Users/Admin/Desktop)
export PS1="@ \W $ "

# Java
export JAVA_HOME=`/usr/libexec/java_home`

# Maven
export M2_HOME=/usr/share/maven
export PATH=${PATH}:${M2_HOME}/bin

# Android
export ANDROID_HOME=/Applications/Android/adt-bundle-mac-x86_64-20130522/sdk/
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/build-tools/17.0.0

# some other things I use

# Current Project
export DEV_HOME=/Users/uki/Documents/workspaces/ .. current project ...
export PATH=${PATH}:${DEV_HOME}

# change directory to DEV_HOME
cd $DEV_HOME


^G Get Help            ^O WriteOut            ^R Read File           ^Y Prev Page           ^K Cut Text            ^C Cur Pos
^X Exit                ^J Justify             ^W Where Is            ^V Next Page           ^U UnCut Text          ^T To Spell

Friday, June 14, 2013

Getting Info About APK

Often you have apk that you need (e.g. package, version) info for, but you have no documentation about it. This little command gives you a lot of info.

$ aapt dump badging  someapp.apk
package: name='com.someapp.xyz' versionCode='1' versionName='1.1'
sdkVersion:'15'
targetSdkVersion:'17'
application-label:'SomeApp'
application: label='SomeApp' icon=''
application-debuggable
uses-feature:'android.hardware.touchscreen'
uses-implied-feature:'android.hardware.touchscreen','assumed you require a touch screen unless explicitly made optional'
supports-screens: 'small' 'normal' 'large' 'xlarge'
supports-any-density: 'true'
locales: '--_--'
densities: '160' '240' '320'
uki:~ uki$

Wednesday, June 12, 2013

Updating Android SDK from command line (Terminal)

You may want to create a script "Update Android SDK.bash" that quickly gets you up to speed without starting IDE (e.g. Eclipse) UI.

echo 'Android SDK home ' $ANDROID_HOME
$ANDROID_HOME/tools/android update sdk --no-ui --all --force 

Notice that it will ask you several times to click letter 'y'

Do you accept the license 'android-sdk-license-bcbbd656' [y/n]: y




Thursday, June 6, 2013

Creating Google API key for Map v2

The key will be needed in AndroidManifest.xml like this... 

<meta-data
          android:name="com.google.android.maps.v2.API_KEY"

          android:value="AIz...jshdkfjhdsjkhfkdjsh..bMI"/>

To get the key go to:

https://code.google.com/apis/console/

1) create a NEW app (drop-down on the left Create...)
2) Select "Services" and turn on Maps...

3) API Access "Create new Android Key.." button

4) Terminal:
$ cd .android/
uki$ keytool -list -v -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android 
Alias name: androiddebugkey
Creation date: Nov 23, 2011
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 4ecdba20
Valid from: Wed Nov 23 21:29:36 CST 2011 until: Fri Nov 15 21:29:36 CST 2041
Certificate fingerprints:
MD5:  7E:FA:01...fkdjsflkjdlksjflkdsjlfjdsljfljlkdsf....:49:61:36
SHA1: D0:5...sdjkflkdsjflkjsdklfjdsljkdsl....F:A1:43
Signature algorithm name: SHA1withRSA
Version: 3
uki:.android uki$ 


5) Enter the SHA1 key, SEMICOLON; and PACKAGE NAME of your app



6) copy the successfully generated KEY to AndroidManifest.xml

Yay!






Wednesday, June 5, 2013

Apache Server on Mac OS 10.8

The Apache server is available on Mac by deploying your html pages to:

/Library/WebServer/Documents/

uki:Documents uki$ ls -alt /Library/WebServer/Documents/
total 80
...
-rw-r--r--  1 root  wheel   3726 Aug 24  2012 PoweredByMacOSX.gif
-rw-r--r--  1 root  wheel  31958 Aug 24  2012 PoweredByMacOSXLarge.gif
uki:Documents uki$

You start the Apache server by:
$ sudo apachectl start


Re-deploying your code:
remove old:
$ sudo rm -r /Library/WebServer/Documents/my_project
Make directory:
$ sudo mkdir /Library/WebServer/Documents/my_project
copy new code in:
$ sudo cp -r /Users/uki/Documents/workspaces/.../my_project/* /Library/WebServer/Documents/my_project

you can view your local server at:
http://localhost/

Setting JAVA_HOME variable on Mac

$ edit ~/.profile

add line

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`

SAVE

re-open Terminal

$ echo $JAVA_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

$

Please note that the most current version (1.6) is loading when 1.7 is missing.

Wednesday, May 22, 2013

Updating Android JellyBean 4.2

Updating Android JellyBean 4.2 using ClockworkMod CWM & cyanogenmod for Android Developers.

If you are a Mac user you might be frustrated that there is no ODIN3 (Window software).
Actually, it is very easy with adb tool that every Android developer uses.

I am starting with stock Samsung Galaxy Tab 10.1 Android 3.0.1 (from Google I/O).




STEP 1)

Get cyanogenmod for your SPECIFIC device, get most stable version there is:

http://wiki.cyanogenmod.org/w/Devices#vendor=;




Examples:
Galaxy Tab 10.1 Wi-Fi only model
http://wiki.cyanogenmod.org/w/P4wifi_Info
I got cm-10.1-20130522-NIGHTLY-p4wifi.zip

Samsung Galaxy Tab 7 T-Mobile:
http://get.cm/?device=p1
http://download.cyanogenmod.org/?type=stable&device=p1
Stable cm-9.1.0-p1.zip

Motorola Droid2
http://download.cyanogenmod.org/?type=stable&device=droid2
cm-7.2.0-droid2.zip 

STEP 2)

Get Google Apps for your version of above
- cm-10 == Android 4.2.2
- cm-9 == ICS
- cm-7 == Gingerbread

you can easily find by searching "gapps-jb-2013"
http://rapidshare.com/files/3580601868/gapps-jb-20130301-signed.zip



STEP 3)
Get ClockworkMod CWM recovery.img

http://www.clockworkmod.com/rommanager


EXAMPLES:
Samsung Galaxy Tab (T-Mobile)


STEP 4) For Samsung: Inspect if there is no update in Kies (USB Debugging OFF), you can use thier for file transfer, too



STEP 5) Transfer there 2 ZIP files to /sdcard/  (USB Debugging ON)
- gApps
- cm-
Example:
uki:platform-tools uki$ adb push ~/Documents/Android/Samsung_Galaxy_Tab_7_TMobile/cm-9.1.0-p1.zip /sdcard/
3038 KB/s (144260310 bytes in 46.360s)
uki:platform-tools uki$ adb push ~/Documents/Android/Samsung_Galaxy_Tab_7_TMobile/gapps-ics-20120317-signed.zip /sdcard/
3263 KB/s (54485532 bytes in 16.304s)
uki:platform-tools uki$


I am showing 3 zip files because I tried older gApps previously.



STEP 6)
Turn OFF tablet by holding POWER button

STEP )
START device in fast boot mode (USB icon):
- hold VOLUME-DOWN (closer to power button) and press POWER button until device boots,
- select Fastboot, NOT download by pressing volume-down, make selection by pressing VOLUME-UP

STEP )
See if you can see your device
uki:platform-tools uki$ fastboot devices 
288420043805517 fastboot

If you see similar (number) line as above, you are good to proceed.

STEP )
Install ClockworkMod CWM tool

uki:platform-tools uki$ fastboot -u -S 0 flash recovery /Users/uki/Downloads/recovery-clockwork-6.0.3.1-p4wifi.img 
sending 'recovery' (4844 KB)...
OKAY [  0.341s]
writing 'recovery'...
OKAY [  0.605s]
finished. total time: 0.946s
uki:platform-tools uki$


STEP ) 
uki:platform-tools uki$ fastboot reboot
rebooting...

finished. total time: 0.000s

The Tablet should start and be healthy.

STEP )
uki:platform-tools uki$ adb reboot recovery  

The Tablet should start with ClockworkMod Recovery menu. If is does not start it same as bafore (POWER + VOLUME DOWN) and select recovery (icon with box expanding)



STEP )
select  - backup and restore (move with Volume UP, select with pressing Power button)
select  - backup (will take a while, but it is VERY IMPORTANT)
...
Backup complete!
*** Go Back ***

STEP )
wipe data/factory reset

*** Yes...

STEP )
select advanced
select - wipe Dalvik cache

*** Yes
*** Go Back ***

STEP)
select install zip from sdcard
choose..   cm-10.1-2013......-p4wifi.zip from sdcard
*** Yes...


STEP )
install gapps-jb-2013.....zip from sdcard

STEP )
restart, press POWER button for 10 seconds
- unplug,

If it fails recover backup (should not happen)

STEP)
IMPORTANT!!! To enable "USB Debugging" and other {} Developer options:
Settings -> About tablet -> CLICK "Build number" line 6 times!!!!!!

I guess the last one is for the code gurus that spent 6 years in the high mountains writing this, one click per year. :)


STEP )
Update Android SKD Manager to versions 16 & 17


SUCCESS!


KNOWN BUG:

The keyboard closes after first character typed, which makes impossible to use the keyboard. 

To fix it go to: 
settings -> language & input  -> click on settings icon next to "Android Keyboard (AOSP)" -> under TEXT CORRECTION
  • set 'Auto-correction' to 'Off' 
  • set 'Show correction options' to 'Always hide'.
The SWYPE will still work, but it will not show auto-correction words on top, it is a minor setback. When I don't get a correct word in Swype mode, I have to type it character-by-character.



Friday, May 17, 2013

Default Google Account

I have a couple of Google accounts:
- my name @google.com
- my company email which is also done via Google

To change DEFAULT google account I had to sign OUT from all and sign in FIRST with the one I want as default.

For some Google entities I had to do it in reverse as my new email did not work with them.

Thursday, May 2, 2013

Animation of 3D mesh in Unity3D


  1. importing the mesh with animation from Maja to Unity3D
  2. setting the position of the mesh
  3. testing the animation and adjusting 

Recommended videos:

Thursday, January 31, 2013

Getting Google YouTube API key

You should follow steps in here:
https://developers.google.com/youtube/android/player/register

with small exception since the command returns error:

$ keytool -list -v my-release-key.keystore
keytool error: java.lang.RuntimeException: Usage error, /Users/uki/Documents/Dropbox/Android_Keychains/my-release-key.keystore is not a legal command
java.lang.RuntimeException: Usage error, /Users/uki/Documents/Dropbox/Android_Keychains/my-release-key.keystore is not a legal command
    at sun.security.tools.KeyTool.parseArgs(KeyTool.java:375)
    at sun.security.tools.KeyTool.run(KeyTool.java:171)
    at sun.security.tools.KeyTool.main(KeyTool.java:166)

instead use the following:

$ keytool -list -v -keystore "my-release-key.keystore"
Enter keystore password:  


  • Make sure you use option -v to get both SHA1 and MP5
  • Make sure you quote the file path to your keystore file.