Scenario: under Linux, setup Android SDK, to be able to use an AVD (android virtual device) to test any given .apk - without using an IDE like Eclipe.
Preparing the system
# cd /opt (or any preferred install directory)
# wget ADT_DOWNLOAD_LINK
# unzip ADT_VERSION.zip
# chown -R your_user.your_user adt-bundle-linux-SYSTEM-VERSION
# ln -sf /opt/adt-bundle-linux-SYSTEM-VERSION/sdk/platform-tools/adb /usr/local/bin/adb
# ln -sf /opt/adt-bundle-linux-SYSTEM-VERSION/sdk/tools/emulator /usr/local/bin/emulator
# ln -sf /opt/adt-bundle-linux-SYSTEM-VERSION/sdk/tools/android /usr/local/bin/android
Using SDK GUI
$ android
will open SDK manager - use it if you want to install additional packages, including other targets/android versions for AVDs.
$ android avd
will open virtual devices manager - use to create/define/remove AVDs
Note 1
One may face difficulties to add specific brand emulators (ex: Samsung Galaxy S, Galaxy Tab, etc); you'll need to:
a) SDK manager > tools > manage add-on sites > user defined sites > new
OR
b) unzip/uncompress a downloaded add-on package in a new directory under sdk/add-ons/
(ref: http://developer.samsung.com/android/tools-sdks/Samsung-GALAXY-Tab-Emulator)
Note 2
AVDs do not support WiFi emulated connections, only 3G - so if you need to test i.e. a different behavior, likely your only option is to use a real/physical device
(ref: http://stackoverflow.com/questions/7876302/enabling-wifi-on-android-emulator)
Note 3
AppInventor 2 requires WiFi to work with the "MIT AI2 Companion" app (that syncronizes AppInventor with a device)
Note 4
By Jan/2014 AI2 doesn't support emulators under Linux, but to test your AppInventor .apk on an AVD, you can:
$ adb install your_package.apk (1st time)
$ adb install -r your_package.apk (when reinstalling)
Refs:
http://developer.android.com/tools/devices/managing-avds-cmdline.html
http://developer.android.com/tools/devices/emulator.html
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts
Thursday, January 23, 2014
Tuesday, December 3, 2013
Protecting VBox Virtual Networks
Be careful in a host having "ip_forwarding" (routing) kernel option enabled. Consider aways set iptables "filter" (firewall) rules. Setting up just iptables "masquarade" (nat) may allow access from outside.
$ sudo su -
# vi /etc/iptables_FW_rules
*filter
#
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
#
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Accepts all established routed connections
-A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#
# VIRTUALBOX VIRTUAL NETWORKS PROTECTION
# vboxnetX is created by type "host-only network" on VBox Manager
-A FORWARD -i eth+ -o vboxnet+ -j REJECT
-A FORWARD -i wlan+ -o vboxnet+ -j REJECT
# allow VMs access outside
-A FORWARD -i vboxnet+ -o eth+ -j ACCEPT
-A FORWARD -i vboxnet+ -o wlan+ -j ACCEPT
#
# Allows all outbound traffic
# You may want to modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
#
# Allow ping request to host
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
#
# log host denied calls (access via 'dmesg' command)
#-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
#
# Reject all other inbound - default deny unless explicitly allowed policy:
-A INPUT -j REJECT
-A FORWARD -j REJECT
COMMIT
# vi /etc/init.d/iptables-on-boot.sh
#!/bin/sh
/sbin/iptables-restore < /etc/iptables_FW_rules
# chmod ug+x /etc/init.d/iptables-on-boot.sh
# runlevel
# ln -s /etc/init.d/iptables-on-boot.sh /etc/rc2.d/S30iptables-on-boot
---- useful commands ---
Flush (clear) rules to test:
# iptables -F (flush default type filter/FW rules)
# iptables -t nat -F (flush masquerade/NAT rules)
For a complete report on iptables rules:
# iptables -L -v -n
# iptables -t nat -L -v -n
$ sudo su -
# vi /etc/iptables_FW_rules
*filter
#
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
#
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Accepts all established routed connections
-A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#
# VIRTUALBOX VIRTUAL NETWORKS PROTECTION
# vboxnetX is created by type "host-only network" on VBox Manager
-A FORWARD -i eth+ -o vboxnet+ -j REJECT
-A FORWARD -i wlan+ -o vboxnet+ -j REJECT
# allow VMs access outside
-A FORWARD -i vboxnet+ -o eth+ -j ACCEPT
-A FORWARD -i vboxnet+ -o wlan+ -j ACCEPT
#
# Allows all outbound traffic
# You may want to modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
#
# Allow ping request to host
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
#
# log host denied calls (access via 'dmesg' command)
#-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
#
# Reject all other inbound - default deny unless explicitly allowed policy:
-A INPUT -j REJECT
-A FORWARD -j REJECT
COMMIT
# vi /etc/init.d/iptables-on-boot.sh
#!/bin/sh
/sbin/iptables-restore < /etc/iptables_FW_rules
# chmod ug+x /etc/init.d/iptables-on-boot.sh
# runlevel
# ln -s /etc/init.d/iptables-on-boot.sh /etc/rc2.d/S30iptables-on-boot
---- useful commands ---
Flush (clear) rules to test:
# iptables -F (flush default type filter/FW rules)
# iptables -t nat -F (flush masquerade/NAT rules)
For a complete report on iptables rules:
# iptables -L -v -n
# iptables -t nat -L -v -n
Monday, December 2, 2013
VBox Virtual Networks Quick Guide
While I'm writing this post, VirtualBox 4.3.4 "NAT networks" (Network Address Translation Service) don't work properly (still experimental), so to have an internal network where VMs are accessible by Host but NOT from outside, and VMs are able to access networks outside host (as internet), I had to:
1) on Host VirtualBox Manager > file > preferences > network > host-only networks > add; on the (guest) VM settings > network > attached to > host-only adapter > set proper name
2) on Host, enable routing on the kernel:
$ sudo vi /etc/sysctl.conf
uncomment "net.ipv4.ip_forward=1"
3) on Host, enable NAT outside:
$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$ sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
To make it persistent under a Debian/Linux Mint host, create a new ifup rule:
$ sudo vi /etc/network/if-up.d/iptables_NAT_vboxnet_out
#!/bin/sh
#
# Don't bother to do anything for lo or VBoxNets.
IFTYPE=$(echo "$IFACE" | cut -c1-2)
if [ "$IFTYPE" = lo -o "$IFTYPE" = vb ]; then
exit 0
fi
# Only run from ifup.
if [ "$MODE" != start ]; then
exit 0
else
iptables -t nat -A POSTROUTING -o "$IFACE" -j MASQUERADE
fi
$ sudo chmod ugo+x /etc/network/if-up.d/iptables_NAT_vboxnet_out
Reestart the Host to test.
1) on Host VirtualBox Manager > file > preferences > network > host-only networks > add; on the (guest) VM settings > network > attached to > host-only adapter > set proper name
2) on Host, enable routing on the kernel:
$ sudo vi /etc/sysctl.conf
uncomment "net.ipv4.ip_forward=1"
3) on Host, enable NAT outside:
$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$ sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
To make it persistent under a Debian/Linux Mint host, create a new ifup rule:
$ sudo vi /etc/network/if-up.d/iptables_NAT_vboxnet_out
#!/bin/sh
#
# Don't bother to do anything for lo or VBoxNets.
IFTYPE=$(echo "$IFACE" | cut -c1-2)
if [ "$IFTYPE" = lo -o "$IFTYPE" = vb ]; then
exit 0
fi
# Only run from ifup.
if [ "$MODE" != start ]; then
exit 0
else
iptables -t nat -A POSTROUTING -o "$IFACE" -j MASQUERADE
fi
$ sudo chmod ugo+x /etc/network/if-up.d/iptables_NAT_vboxnet_out
Reestart the Host to test.
Wednesday, November 27, 2013
Installing VirtualBox (Bin Package)
Go to
https://www.virtualbox.org/wiki/Linux_Downloads
download "All distributions" (runs a bin installer)
$ sudo sh VirtualBox-VERSION-SYSTEM.run
After installing, go to https://www.virtualbox.org/wiki/Downloads
then click on "VirtualBox 4.3.2 Oracle VM VirtualBox Extension Pack"
choose open download directly on VirtualBox
To make VM fit on host screen etc:
running VM > devices > insert guest additions cd image
execute cd installer via SO
To update/upgrade VirtualBox, just make the same process; you'll need to reinstall Extension Pack
https://www.virtualbox.org/wiki/Linux_Downloads
download "All distributions" (runs a bin installer)
$ sudo sh VirtualBox-VERSION-SYSTEM.run
After installing, go to https://www.virtualbox.org/wiki/Downloads
then click on "VirtualBox 4.3.2 Oracle VM VirtualBox Extension Pack"
choose open download directly on VirtualBox
To make VM fit on host screen etc:
running VM > devices > insert guest additions cd image
execute cd installer via SO
To update/upgrade VirtualBox, just make the same process; you'll need to reinstall Extension Pack
Thursday, November 14, 2013
Keeping Firefox + Java up-to-date on a Linux Mint
1) UPDATE FIREFOX
Copy the link of updated Firefox from ftp://ftp.mozilla.org/pub/firefox/releases/ (navigate through the right version / platform / language)
$ cd /opt
$ sudo wget FIREFOX_DOWNLOAD_LINK
$ sudo tar xjf firefox-VERSION.tar.bz2
$ sudo mv firefox firefox-VERSION
$ sudo rm firefox-VERSION.tar.bz2
$ sudo ln -sf /opt/firefox-VERSION/firefox /usr/bin/firefox
(ref: # ln -sf TARGET LINK)
2) UPDATE JAVA
Copy the link of updated Java from http://www.java.com/en/download/manual.jsp list (Debian like users should choose "Linux" or "Linux x64")
$ sudo wget JAVA_DOWNLOAD_LINK
$ sudo mv DOWNLOAD_FILENAME java.tar.gz
$ sudo tar xzf java.tar.gz
$ sudo rm java.tar.gz
You should have a new /opt/jreVERSION
Now update the Java sym links:
$ sudo ln -sf /opt/jreVERSION/bin/java /etc/alternatives/java
$ sudo ln -sf /opt/jreVERSION/bin/java_vm /etc/alternatives/java_vm
$ sudo ln -sf /opt/jreVERSION/bin/javaws /etc/alternatives/javaws
3) UPDATE USER FIREFOX JAVA PLUGIN LINK
And last update the user Firefox Java plugin sym link:
$ ln -sf /opt/jreVERSION/lib/amd64/libnpjp2.so ~/.mozilla/plugins/libnpjp2.so
(if the platform is 64bits)
Restart Firefox and... voilá!
Refs:
http://www.libre-software.net/how-to-install-firefox-on-ubuntu-linux-mint
Copy the link of updated Firefox from ftp://ftp.mozilla.org/pub/firefox/releases/ (navigate through the right version / platform / language)
$ cd /opt
$ sudo wget FIREFOX_DOWNLOAD_LINK
$ sudo tar xjf firefox-VERSION.tar.bz2
$ sudo mv firefox firefox-VERSION
$ sudo rm firefox-VERSION.tar.bz2
$ sudo ln -sf /opt/firefox-VERSION/firefox /usr/bin/firefox
(ref: # ln -sf TARGET LINK)
2) UPDATE JAVA
Copy the link of updated Java from http://www.java.com/en/download/manual.jsp list (Debian like users should choose "Linux" or "Linux x64")
$ sudo wget JAVA_DOWNLOAD_LINK
$ sudo mv DOWNLOAD_FILENAME java.tar.gz
$ sudo tar xzf java.tar.gz
$ sudo rm java.tar.gz
You should have a new /opt/jreVERSION
Now update the Java sym links:
$ sudo ln -sf /opt/jreVERSION/bin/java /etc/alternatives/java
$ sudo ln -sf /opt/jreVERSION/bin/java_vm /etc/alternatives/java_vm
$ sudo ln -sf /opt/jreVERSION/bin/javaws /etc/alternatives/javaws
3) UPDATE USER FIREFOX JAVA PLUGIN LINK
And last update the user Firefox Java plugin sym link:
$ ln -sf /opt/jreVERSION/lib/amd64/libnpjp2.so ~/.mozilla/plugins/libnpjp2.so
(if the platform is 64bits)
Restart Firefox and... voilá!
Refs:
http://www.libre-software.net/how-to-install-firefox-on-ubuntu-linux-mint
Tuesday, January 25, 2011
Handling CD/DVD from shell
To create the ISO image:
$ genisoimage -RJ -o image.iso dir1/ dir2/
To burn ISO to CD:
$ cdrecord -v -eject speed=8 dev=/dev/cdrom image.iso
To burn ISO to DVD:
$ growisofs -dvd-compat -Z /dev/cdrom=image.iso -speed=2
And finally - ripping/dumping a CD/DVD to an ISO image:
$ dd if=/dev/cdrom of=image.iso
$ genisoimage -RJ -o image.iso dir1/ dir2/
To burn ISO to CD:
$ cdrecord -v -eject speed=8 dev=/dev/cdrom image.iso
To burn ISO to DVD:
$ growisofs -dvd-compat -Z /dev/cdrom=image.iso -speed=2
And finally - ripping/dumping a CD/DVD to an ISO image:
$ dd if=/dev/cdrom of=image.iso
Wednesday, November 10, 2010
Firefox: mudando CRTL+TAB para SHIFT+TAB
Eu uso o Compiz para incrementar a interface gráfica do Ubuntu 10.10
Por uma questão "ergonômica", prefiro o CTRL+TAB para alternar as janelas (normalmente isso é feito com o ALT+TAB). Acontece que o CRTL+TAB é normalmente usado pelo Firefox para alternar as abas, então eu queria usar SHIFT+TAB para isso. Como não há uma opção de configuração assim no Firefox no momento, executei os passos listados abaixo:
$ cd $HOME/tmp
$ cp /usr/lib/firefox-3.6.12/chrome/toolkit.jar ./
$ cp toolkit.jar toolkit.jar.orig
$ unzip -p toolkit.jar content/global/bindings/tabbox.xml > tabbox.xml
$ vi tabbox.xml
encontre e mude de:
(...)
switch (event.keyCode) {
case event.DOM_VK_TAB:
if (event.ctrlKey && !event.altKey && !event.metaKey)
if (this.tabs && this.handleCtrlTab) {
this.tabs.advanceSelectedTab(event.shiftKey ? -1 : 1, true);
event.stopPropagation();
event.preventDefault();
}
break;
(...)
para:
(...)
switch (event.keyCode) {
case event.DOM_VK_TAB:
if (event.shiftKey && !event.altKey && !event.metaKey)
if (this.tabs && this.handleCtrlTab) {
this.tabs.advanceSelectedTab(1, true);
event.stopPropagation();
event.preventDefault();
}
break;
(...)
$ mkdir content/
$ mkdir content/global/
$ mkdir content/global/bindings/
$ cp tabbox.xml content/global/bindings/
$ zip toolkit.jar content/global/bindings/tabbox.xml
$ rm -rf content
$ sudo cp -f toolkit.jar /usr/lib/firefox-3.6.12/chrome/
reinicie o firefox e... voilá!
[]'s
Marco.
referências
http://forums.mozillazine.org/viewtopic.php?f=7&t=168930
Por uma questão "ergonômica", prefiro o CTRL+TAB para alternar as janelas (normalmente isso é feito com o ALT+TAB). Acontece que o CRTL+TAB é normalmente usado pelo Firefox para alternar as abas, então eu queria usar SHIFT+TAB para isso. Como não há uma opção de configuração assim no Firefox no momento, executei os passos listados abaixo:
$ cd $HOME/tmp
$ cp /usr/lib/firefox-3.6.12/chrome/toolkit.jar ./
$ cp toolkit.jar toolkit.jar.orig
$ unzip -p toolkit.jar content/global/bindings/tabbox.xml > tabbox.xml
$ vi tabbox.xml
encontre e mude de:
(...)
switch (event.keyCode) {
case event.DOM_VK_TAB:
if (event.ctrlKey && !event.altKey && !event.metaKey)
if (this.tabs && this.handleCtrlTab) {
this.tabs.advanceSelectedTab(event.shiftKey ? -1 : 1, true);
event.stopPropagation();
event.preventDefault();
}
break;
(...)
para:
(...)
switch (event.keyCode) {
case event.DOM_VK_TAB:
if (event.shiftKey && !event.altKey && !event.metaKey)
if (this.tabs && this.handleCtrlTab) {
this.tabs.advanceSelectedTab(1, true);
event.stopPropagation();
event.preventDefault();
}
break;
(...)
$ mkdir content/
$ mkdir content/global/
$ mkdir content/global/bindings/
$ cp tabbox.xml content/global/bindings/
$ zip toolkit.jar content/global/bindings/tabbox.xml
$ rm -rf content
$ sudo cp -f toolkit.jar /usr/lib/firefox-3.6.12/chrome/
reinicie o firefox e... voilá!
[]'s
Marco.
referências
http://forums.mozillazine.org/viewtopic.php?f=7&t=168930
Subscribe to:
Posts (Atom)