mercoledì 3 settembre 2014

Show the Android app version and permissions

Here there are some helpful commands to check an Android app using the setup file (APK):

# application version
aapt d badging file.apk | head -n 1

# application permissions
aapt d permissions file.apk

Identity of an Android app creator

To show or verify the identity of the Android app creator, you need the Android application setup (APK file).
Each Android app (file .apk) are digitally signed with a certificate.
This certificate identifies the author of an app.

You can choose one of the following commands:

# Direct with standard Java tools
jarsigner -verify -certs -verbose file.apk

# Indirect with standard Java tools
unzip -p file.apk  META-INF/CERT.RSA \
| keytool -printcert

# Indirect with OpenSSL
unzip -p file.apk  META-INF/CERT.RSA \
| openssl pkcs7 -inform DER -print_certs -text

# Indirect with OpenSSL
unzip -p file.apk  META-INF/CERT.RSA \
| openssl pkcs7 -inform DER -print_certs -text


With OpenSSL you can retrieve more information:
# extract the certificate in PKCS#7 format
unzip -p file.apk META-INF/CERT.RSA > /tmp/cert.pkcs7
# extract the certificate in PEM format
openssl pkcs7 -inform DER -in /tmp/cert.pkcs7 -print_certs \
| tail -n +3 > /tmp/cert.pem
# dump the certificate
openssl x509 -inform PEM -in /tmp/cert.pem -text

mercoledì 4 giugno 2014

Remove BOM header from UTF-8 file in Unix

A lot of Windows editors save your UTF-8 files with the BOM header (the hexadecimal sequence ef bb bf). You have some problem when it's necessary to use these files in Unix platform.
To remove the BOM header from the your file, you can choose one of the following ways.

# On Linux
tail --bytes=+4 your_utf-8_file

# On Unix (IBM AIX or Oracle SOLARIS)
tail +4c your_utf-8_file

Ubuntu with GNU compiler tools

The GNU project offers a lot of tools for your Ubuntu machine.
To install what you need to create a C/C++ project with Automake, use the following commands:

# Install the GNU tools
sudo apt-get install build-essential libtool automake

# Install libz library
sudo apt-get install libz-dev

Use apt-get in outdated Ubuntu release

When an Ubuntu release is outdated, all source files are moved from archive.ubuntu.com to old-releases.ubuntu.com.
In order to continue to use the apt-get command, you have to update the source list (see /etc/apt/sources.list)

# replace the source list automatically
sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

# resynchronize the package index files from their sources
sudo apt-get update 

# install the newest versions of all packages currently installed on the system from the sources
sudo apt-get dist-upgrade

venerdì 30 maggio 2014

Honeywell Dolphin Android SDK in MacOS/X

I'm developing a software for the Honeywell's Dolphin 70e Black, but the installation of the Honeywell Dolphin Android SDK in MacOS/X needs some manual steps.

You have to download the SDK Android Add-on provided by Honeywell: see the file "Honeywell_SDK_Windows_Android_Addon" on the Software tab.

To install it, please run the following commands:

# NOTE: This is the path of your add-on folder in the Android SDK
export DEST=$HOME/android-sdk-macosx/add-ons

# Please, check the downloaded file name unzip
# unzip the file content in the temporary folder ...
unzip $HOME/Downloads/Honeywell_SDK_Windows_Android_Addon_2.19.zip -d /tmp/
# ... and move them to the Android SDK
mv /tmp/addon_honeywell_dolphin_black_15 $DEST/honeywell_dolphin_black_15
mv /tmp/addon_honeywell_dolphin_7800_10 $DEST/honeywell_dolphin_7800_10

You can see the new add-ons in the android command


Now, you have to register the Honeywell USB vendor id in the Android list: in this way, adb recognizes the Honeywell Dolphin as an Android device.

# run the command to update the $HOME/.android/adb_usb.ini file
android update adb
# restart the adb server in order to see the modifications
adb kill-server
adb start-server

To see your Honeywell Dolphin device, try

adb devices

martedì 8 aprile 2014

Create ext2 filesystem file with the directory contents

The genext2fs tool is a great tool if you use QEmu!
Without the superuser account, the following lines shows you how to create a ext2 filesystem file with the directory contents.

# set the destination directory
export DESTDIR=/home/davidez/projects/arm-data

# generate arm-data.ext2 file with 10% free space
genext2fs -b `du -k $DESTDIR | tail -n -1 | awk '{ print $1 + $1 * 0.1 }'` -d $DESTDIR $DESTDIR.ext2

giovedì 6 marzo 2014

Change the keystore in Eclipse ADT

To simplify the development of an Android app, I suggest to configure the Eclipse ADT plug-in with the same certificate used to publish the app in Google Play.
In this way, you can debug your published app in case of problem or crash directly from Eclipse!

Create a copy of your keystore: for example, eclipse.keystore

In according with Signing Your Applications, modify the keystore file in this way:

# change the keystore password with "android" 
keytool -keystore eclipse.keystore  -storepasswd

# change the alias with "androiddebugkey"
keytool -keystore eclipse.keystore -changealias -alias app-alias -destalias androiddebugkey

# change the password for the alias with "android"
keytool -keystore eclipse.keystore -keypasswd -alias androiddebugkey

Configure the Eclipse ADT plugin, specifying the eclipse.keystore file as "Custom debug keystore" in the Eclipse Preferences > Android > Build panel.



venerdì 14 febbraio 2014

Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files on MacOS/X

With Java 1.7 the key size is limited due to US export laws: you can find here an example.
To fix this problem, you have to
  • download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files from Oracle
  • copy the file in the standard place for JCE jurisdiction policy JAR files
But where is this "standard place" in MacOS/X ?
If you have installed the Oracle official JDK,
cd /tmp
unzip $HOME/Downloads/UnlimitedJCEPolicyJDK7.zip
sudo cp /tmp/UnlimitedJCEPolicy/*.jar /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre/lib/security/

mercoledì 22 gennaio 2014

Error while building Android project with Ant

The ADT (Android Developer Tools) version 22 contains a bug while building an Android project with Ant.

[aapt] invalid resource directory name: <your-project path>/bin/res/crunch

The cause is the compatibility between the Eclipse Android Plug-in and the Ant script: the first generates the crunch-ed image files ignored by the second!

A simple workaround is to remove the crunch directory (generated by the Eclipse plugin) before to build:

find . -name crunch -exec rm -Rf {} + ; ant