Wednesday, October 26, 2011

How to setup ADB for Linux terminals

Run adb from terminal
Since the new Eclipse and Android SDK install I had to redo this:

Open your .bashrc, located in your /home/"user"/ and add this:

# Android tools 
export PATH=${PATH}:~/android-sdk-linux_x86/tools 
export PATH=${PATH}:~/android-sdk-linux_x86/platform-tools

Save the file, then in a terminal, type in "source" to refresh the terminal

http://forum.xda-developers.com/showthread.php?p=11823740

Eclipse - Dependency Issues

Failure to Launch
Early this morning I loaded up Eclipse after the latest update(Indigo). To my surprise, all my extra plugins such as ADT and C/C++ were gone. Of course I tried to install them manually again via "Help > Install New Software" and ran into "Dependency Issues". After plenty of installing and re-installing and considering going back to an older version, further Googling led me to just REMOVE all the Eclipse files INCLUDING config files:
Run these commands
sudo -i
 - login as root
apt-get autoremove eclipse
 - unistall
rm -r /usr/lib/eclipse 
 - remove all config files

apt-get install eclipse 
- reinstall
http://ubuntuforums.org/showthread.php?t=1412320

Friday, October 7, 2011

How to disable Avahi Daemon

Disable
package: avahi-daemon
open config file:
 sudo gedit /etc/default/avahi-daemon
set: 
 AVAHI_DAEMON_START = 1

you might also have to:
 sudo gedit /etc/avahi/avahi-daemon.conf
set: 
 use-ipv4=no
 use-ipv6=no

restart:
 sudo /etc/init.d/avahi-daemon restart
or Unistall - Remove Package
sudo apt-get remove avahi-daemon

Friday, September 23, 2011

How to fix 'for' loop initial declarations are only allowed in C99 mode in Eclipse

For loop problem
Once again, programming in C using Eclipse in Linux is great, however when using "for" loops I get this error:
'for' loop initial declarations are only allowed in C99 mode
After a little bit of research, in Eclipse, go to Project > Properties > C/C++ Build > Settings > GCC C Compiler > Miscellaneous > add "-std=c99" to the "Linker Flags" text field.
http://www.eclipse.org/forums/index.php?t=msg&goto=212981&

How to fix undefined reference to `sqrt' in Eclipse

Math.h problem
Programming in C using Eclipse in Linux is great, however when i added variables that were doubles into the "sqrt" function from the "math.h" library there was a problem that came up.
undefined reference to `sqrt'
After a little bit of research, in Eclipse, go to Project > Properties > C/C++ Build > Settings > GCC C Linker > Miscellaneous > add "-lm" to the "Linker Flags" text field. That way it is properly linked to the project.
http://cboard.cprogramming.com/c-programming/88943-undefined-reference-sqrt.html

Thursday, September 8, 2011

How to change your MAC Address

Media Access Control address(MAC)

Linux in General (3 Possible Ways):
sudo ifconfig wlan0 down
- turn device off
sudo ifconfig wlan0 hw ether XX:XX:XX:XX:XX:XX
- set the mac you want
sudo ifconfig wlan0 up
- turn device on
sudo ip addr
- show config
sudo ip link set dev wlan0 address XX:XX:XX:XX:XX:XX
- set the mac you want
sudo pico /etc/network/interfaces
- edit your network devices
- add hwaddress ether XX:XX:XX:XX:XX:XX to your device

After you change your MAC address, run sudo /etc/init.d/networking stop then sudo /etc/init.d/networking start

GNU Mac Changer: www.alobbs.com/macchanger
Install: Install: sudo apt-get install macchanger

macchanger -s wlan0
- shows the current mac on the device

macchanger -mac wlan0 XX:XX:XX:XX:XX:XX
- set the mac you want

You might want to add a script in the /etc/rc.local to automatically change your MAC Address everytime on boot.

Monday, September 5, 2011

How to change your Hostname in Android

DHCP Hostname
With GingerBread, some devices show up in a router's DHCP list as 'android-sdr4r55ed'
Old Ways:
You can change host name in Gingerbread:
 > go to Settings -> Applications -> Development -> Device hostname or
Settings -> Wireless & networks -> Bluetooth settings -> Device name

Using adb shell, then
 > hostname NAME or edit /proc/sys/kernel/hostname
    echo NAME > /proc/sys/kernel/hostname

Using adb shell with busybox installed
 > busybox hostname NAME 

Best Way:
This worked for my Droid X, .602+ Rooted was using adb shell, then:
getprop net.hostname
setprop net.hostname NAME

Since the above code gets reset after each reboot, here is what else
I have found:


after

editing net.hostname
># getprop net.hostname
android_430217a864834bd5
># setprop net.hostname NAME

after the reboot it reverts to android_

so, hook your phone up to your computer:

your computer > adb > phone

> adb shell

> su
 - always backup all files first
> cp /data/data/com.android.providers.settings/databases/settings.db 
/data/data/com.android.providers.settings/databases/settings.db.backup

> cp /data/data/com.android.providers.settings/databases/settings.db 
/mnt/sdcard/settings.db

> rm /data/data/com.android.providers.settings/databases/settings.db

now click disk storage on the usb to access the mnt on your own computer

your computer > access your sdcard

> file settings.db

Ex. settings.db: SQLite 3.x database, user version 57

> sqlite3 settings.db

to show databases:

sqlite> .databases
seq  name             file                                                      
---  ---------------  ------------------------------
0    main             /media/249A-11E0/z/settings.db

to show tables:

sqlite> .tables
android_metadata   bookmarks          system           
bluetooth_devices  secure 

to show the column names:

sqlite> .schema secure
CREATE TABLE secure (_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT 
UNIQUE ON CONFLICT REPLACE,value TEXT);
CREATE INDEX secureIndex1 ON secure (name);

The column names go from left to right: _id, name, value.

now select the table, secure, this command with show everything:

sqlite> select * from secure;

Here I picked id = 24, this is where my id was.

sqlite> select * from secure where _id = "24";
24|android_id|
 - just another way
sqlite> select * from secure where name = "android_id";
24|android_id|
 - just another way
sqlite> select * from secure where value = "";
24|android_id|

We can easily change the "ID" value from the <16 digit id> 
to any number. Here I changed it to 0:

sqlite> update secure set value = 0 where _id = 24;

Type .exit in order to exit.

sqlite> .exit

On the USB notification change from storage to charge to mount your 
sdcard to your phone.
phone > sdcard

again
> adb shell

> su

> cp /mnt/sdcard/settings.db 
/data/data/com.android.providers.settings/databases/settings.db

Now simply reboot your phone. You should now see "android_0" as your 
new hostname. I know I didnt change the entire hostname, however I will 
continue to look into this.

Thursday, September 1, 2011

Android - FREE Samples

Free Code and Projects
I used Google to find these, very helpful for learning new layouts and different android features.

GitHub
https://github.com/

Blogspot(Google Blogs)
http://android-coding.blogspot.com/
http://androidblogger.blogspot.com/
http://techdroid.kbeanie.com/

Google Code
http://code.google.com/p/androidnetworktester/
http://code.google.com/p/myandroidwidgets/

StackOverflow
http://stackoverflow.com/

Wordpess
http://pareshnmayani.wordpress.com/