apk反编译返回的代码跟正向开发的代码语法有出入,看不懂

apk反编译回来的代码跟正向开发的代码语法有出入,看不懂.
本帖最后由 szuzsq 于 2013-09-27 12:09:38 编辑
反编译涉及到的工具有3个:apktool1.5.2, dex2jar-0.0.9.15, jd-gui.exe

例如枚举类型:

源代码为:


package com.example.test;

import android.os.Bundle;
import android.app.Activity;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

enum TestEnum {
one, two, three, four, five, six, seven, eight, nine, ten;
}


编译之后,将bin/classes.dex反编译:
dex2jar.bat classes.dex
得到classes_dex2jar.jar,使用jd-gui.exe打开这个jar,查看反编译之后的代码:

package com.example.test;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity
{
  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903040);
  }
}

 enum TestEnum
{
  static
  {
    three = new TestEnum("three", 2);
    four = new TestEnum("four", 3);
    five = new TestEnum("five", 4);
    six = new TestEnum("six", 5);
    seven = new TestEnum("seven", 6);
    eight = new TestEnum("eight", 7);
    nine = new TestEnum("nine", 8);
    ten = new TestEnum("ten", 9);
    TestEnum[] arrayOfTestEnum = new TestEnum[10];
    arrayOfTestEnum[0] = one;
    arrayOfTestEnum[1] = two;
    arrayOfTestEnum[2] = three;
    arrayOfTestEnum[3] = four;
    arrayOfTestEnum[4] = five;
    arrayOfTestEnum[5] = six;
    arrayOfTestEnum[6] = seven;
    arrayOfTestEnum[7] = eight;
    arrayOfTestEnum[8] = nine;
    arrayOfTestEnum[9] = ten;
  }
}


大家注意看,反编译回来之后的代码,跟源代码之间的差别.
MainActivity类基本上没有,但TestEnum这个枚举差别大了去.呵呵..

/////////////////////////////
虽然差别很大, 但是通过试验,能够知道原始代码是怎么一种形式的...
但是下面这个类,就确实不知道它的原始代码是怎么样子的了,求各位一起看看...


public class BinderProxy {
private IBinder mBinder;
private ServiceConnection mCon = new ServiceConnection() {
public void onServiceConnected(ComponentName paramComponentName, IBinder paramIBinder) {
//问题出现在这里了,从头到尾,我都没找着access$002有这个函数..问问大家这个是怎么样回事...它原始的代码可能是怎么样子的?????
BinderProxy.access$002(BinderProxy.this, paramIBinder);
}

public void onServiceDisconnected(ComponentName paramComponentName) {
BinderProxy.access$002(BinderProxy.this, null);
}
};
//以下省略一些代码............
}


如上面代码access$002这个函数是神马情况???????
反编译 apk

------解决方案--------------------
这是编译器自动生成的,用于内部类调用外部类的方法或者变量。
可以看一下这个帖子。