Putting a Boolean

const/4 v2, 0x1

iput-boolean v2, p0, a/b/c;->mDonatePlugin:Z


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Maven build failure on Linux – “Unable to locate the Javac Compiler in /usr/lib/jvm/java-6-openjdk/jre/../lib/tools.jar”

This happened even after installing OpenJDK and Sun’s JDK. A “which javac” proved that javac was working properly and was in the PATH.

Error:

[[email protected] brut.j.common]$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Brut Java commons
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to /home/droidzone/apktoolbuild/brut.j.common/target/classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
Unable to locate the Javac Compiler in:
/usr/lib/jvm/java-6-openjdk/jre/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Tue Mar 27 12:04:29 IST 2012
[INFO] Final Memory: 11M/130M
[INFO] ------------------------------------------------------------------------
[/code]

Solution:

[[email protected] brut.j.common]$ which javac
/usr/bin/javac

[[email protected] brut.j.common]$ ls -l /usr/bin/javac
lrwxrwxrwx 1 root root 23 2012-01-24 10:52 /usr/bin/javac -> /etc/alternatives/javac
[[email protected] brut.j.common]$ ls -l /etc/alternatives/javac
lrwxrwxrwx 1 root root 42 2012-01-24 10:52 /etc/alternatives/javac -> /usr/lib/jvm/java-7-openjdk-i386/bin/javac
[[email protected] brut.j.common]$ sudo rm /usr/bin/javac
[[email protected] brut.j.common]$ sudo ln -s /usr/lib/jvm/java-7-openjdk-i386/bin/javac /usr/bin/javac
[[email protected] brut.j.common]$ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
[[email protected] brut.j.common]$ mvn -e install
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Brut Java commons
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to /home/droidzone/apktoolbuild/brut.j.common/target/classes
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/droidzone/apktoolbuild/brut.j.common/src/test/resources
Downloading: http://repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar

[/code]

So the error was solved by resolving the symlink properly (A symlink to a symlink doesnt seem too good), and by setting the JAVA_HOME variable to the directory containing bin/javac.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Returning a Boolean of your choice in Dalvik

The following code will do this:

    const/4 v3, 0x1

invoke-static {v3}, Ljava/lang/Boolean;->valueOf(I)Ljava/lang/Boolean;

move-result-object v3

return v3[/code]


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Installing multiple versions of a decompiled app (Refactoring an apk)

You have to change the following:

  • AndroidManifest.xml, change the package name: package=”com.a.b”
  • apktool.yml, change apkFileName. It should be same as package name
  • The main class, which will be the smali directory with a name similiar to the package name..
  • Find a line:smali/../…/…/…/mainclassname.smali:1:.class public com/a/b;

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Reverse engineering APK files – A trial

Ok, we’ll just go back and forth from source..

 

See my Java class HellosWorldActivity.java:

package com.example.helloworld;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HellosWorldActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv=new TextView(this);

tv.setText("Hello, Android!");
setContentView(tv);
}
}[/code]


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.