Android Tools: Zipalign

Hello friends!

Android provides developers the zipalign tool to align your .apk file before distributing to end-users. The tool not only provides better optimization but also ensures that that all uncompressed data starts with a particular alignment relative to the start of the file. It is important to note that the zipalign must only be performed after the .apk file has been signed with your private key. If you perform zipalign before signing, then the signing procedure will undo the alignment.

Through this post, we will learn how to use the zipalign tool in Android.

Pre-requisites: Eclipse IDE, Android SDK

How to export signed apk?

Launch Eclipse IDE and switch to your Android project workspace. Choose any of your existing Android projects for which you need to zipalign the .apk. Before generating the signed apk for your Android project, it is necessary to follow the below steps as per the official documentation for signing an application.

1. Check the AndroidManifest.xml and verify that android:debuggable attribute is set to false. The attribute indicates whether or not the application can be debugged, even when running on a device in user mode.

2. Check the android:versionCode and android:versionName attributes. If it is a new version of an existing apk, make sure these values are larger than the previous apk file.

3. Finally, right click your application, go to Android Tools -> Export Signed Application Package and sign the application using a release key certificate (not debug) as mentioned over here.

Running zipalign

Once you have obtained the signed apk, you can use the zipalign tool for optimization. The following command converts the signed apk to a zipalign signed apk that can be uploaded on the Google Play Store.

zipalign -v 4 AndroidRandomExamples.apk AndroidRandomExamples_aligned.apk

Syntax

zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk

The output of the zipalign process is as follows!

Output

Output

Reference: Android ZipAlign

Android Tools: ProGuard

Hey friends!

The Android SDK comes shipped with a bunch of tools that allow developers to create even better mobile applications. It is seldom that we use these tools, mainly due to the lack of understanding or awareness. ProGuard, for instance, is one such tool that is integrated into the Android build system, so you do not have to invoke it manually.

Today, it is quite easy to reverse engineer Android applications. If one wants to prevent this from happening, one should use ProGuard for its main function i.e code obfuscation. As mentioned on the developer’s page, the ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. Through this post, we will learn how to use ProGuard in Android.

Pre-requisites: Eclipse IDE, Android SDK

Step 1: Launch Eclipse IDE and open any of your existing Android projects.

Step 2: Enable ProGuard

Open up the file project.properties in the Eclipse text editor and uncomment the following line by removing the # symbol in the first column,

#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

Thus, ProGuard is now enabled. However, if there are any classes that you do not want to obfuscate, then the class must be added to the proguard-project.txt file as follows,

-keepclassmembers class com.app.test.TestArrowActivity {
public *;
}

Now, go ahead and create a signed APK of your Android project and use dex2jar to reverse engineer the executable APK. Here is the screenshot of a decompiled obfuscated Android APK followed by the image of a class that we chose not to obfuscate.

output_1

output_2

That’s it for this Android tip. Hope it helps! 🙂

Reference: Android ProGuard

Oracle Data Integrator tools: OdiFileDelete and OdiOutFile

Hello everyone!

It’s time for another cool ODI tutorial. Last time, I spoke about the OdiZip tool and how it can be used to create zip files from a directory. Through this post, I will talk about two more tools related to Files namely OdiFileDelete and OdiOutFile.

1. OdiFileDelete

The OdiFileDelete is a tool used to delete files present in a directory or a complete directory on the machine running the agent.

Usage

OdiFileDelete -DIR=<dir> | -FILE=<file> [-RECURSE=<yes|no>] [-CASESENS=<yes|no>] [-NOFILE_ERROR=<yes|no>] [-FROMDATE=<fromdate>] [-TODATE=<todate>]

If -FROMDATE is omitted, all files with a modification date earlier than the -TODATE date will be deleted. If -TODATE is omitted, all files with a modification date later than the -FROMDATE date will be deleted. If both parameters are omitted, all files matching the -FILE parameter value will be deleted.

It is important to note that both FILE and DIRECTORY cannot be deleted at the same time. In such a case, we need to use two instances of OdiFileDelete.

Pre-requisites: Oracle Data Integrator 11g (build version 11.1.1.7.0)

Now let’s implement the ODI using Oracle Data Integrator. Open ODI Studio and create a new Package named odifiledelete_test inside any of your existing Projects.

Create package

create_package_2

create_package_3

Command

OdiFileDelete "-FILE=C:\programs\odi_work\*.txt" "-RECURSE=YES" "-CASESENS=YES" "-NOFILE_ERROR=YES"

Save all the changes and run the package. Check the status of the operation under the Operator tab. If the operation was successfully completed, the files present in the directory specified will be deleted.

Output

2. OdiOutFile

The OdiOutFile is a simple tool used to generate a text file (.txt) in the path defined by file_name and contains the text specified by text.

Usage

OdiOutFile -FILE=<file_name> [-APPEND] [-CHARSET_ENCODING=<encoding>] [-XROW_SEP=<hexadecimal_line_break>] [CR/LF <text> | -TEXT=<text>]

To use this tool, let’s create another Package named odioutfile_test in any of the existing Projects and follow the below steps!

Create package

create_package_2

create_package_3

Command

OdiOutFile "-FILE=C:\programs\odi_work\my_output.txt" "-CHARSET_ENCODING=ISO8859_1"
Hi! This is a test message using OdiOutFile tool.

Save all the changes and run the package. Check the status of the operation under the Operator tab. If the operation was successfully completed, you should see a new file created in the directory specified.

Output

output_2

Source: OdiFileDelete and OdiOutFile

Oracle Data Integrator Tools: OdiSqlUnload

Hi friends!

Oracle Data Integrator inclues a number of tools that have their own specific function. The OdiSqlUnload tool is mainly used for unloading as well as generating a data file based on the SQL query provided for a specific data server connection. The file is written to the path defined by parameter -FILE.

Through this post, I will explain how to configure and use the OdiSqlUnload tool inside a Procedure.

Pre-requisites: Oracle Data Integrator 11g (build version 11.1.1.7.0)

Step 1: Create a new Procedure

Create a new procedure inside any of your existing Projects named test_sqlunload. Click on Details and then add a new entry as follows!

Select Target Technology as ODI Tools. The -PASS field contains the encoded password for your schema. You can encode the password using the encode tool present in the [ODI_HOME]\oracledi\agent\bin folder.

Usage: encode your-schema-password

procedure_1

create procedure

Command

OdiSqlUnload "-FILE=D:\programs\sample2.csv" "-DRIVER=oracle.jdbc.OracleDriver" "-URL=jdbc:oracle:thin:@localhost:1521:orcl" "-USER=system" "-PASS=aIya5uUlQXGMLmIzPj.f" "-FIELD_SEP=;" "-DATE_FORMAT=dd/MM/yyyy hh:mm:ss" "-QUERY=select empid, empname, city from system.karan_employee"

Step 2: Run the Procedure

Once you run the procedure, navigate to the file path that you have mentioned as a part of your command. You should see a .csv file containing the results of the query.

Output

Output

output_1