如何解决apktool d -d 出现错误Error occured while disassembling class

如何解决apktool d -d 出现错误Error occured while disassembling class
告诉你,这不是你的错误,这是apktool本身的错误,目前正式release的1.5.2版本不行,搞不定这个问题,你需要使用1.5.3的使用版本。
需要去google网站现在这个程序然后编译


# Build I was able to build on Linux (gentoo, amd64, java version "1.7.0_13", javac 1.7.0_13) using the following steps:

1) git clone https://code.google.com/p/android-apktool/
2) cd android-apktool/
3) ./gradlew
4) ./gradlew fatJar

# Run

java -jar brut.apktool/apktool-cli/build/libs/apktool-cli-1.5.3-SNAPSHOT.jar

不好意思,悲哀的告诉你,我们非常光荣正确的党已经阻挡了这个万恶的资本主义社会美国这个技术网站。怎么办,翻墙吧,或者找一个别人已经编译好的。
当然,你可能还会出错,请看下面的解决方法:
Installing javac for Apktool on linux
The build steps of the latest Apktool is detailed below

http://code.google.com/p/android-apktool/wiki/BuildApktool?tm=4

 

It uses something called gradlew to build the latest version of the binary.

The instructions are as follows:
We use gradle to build. Its pretty easy. First clone the REPO. git clone git://github.com/iBotPeaches/Apktool.git Move into the directory. cd Apktool Issue the build. ./gradlew build Then look in /brut.apktool/apktool-cli/build/libs/apktool-xxxxx.jar Other commands such as clean are ./gradlew clean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    
We use gradle to build. Its pretty easy. First clone the REPO.
 
git clone git://github.com/iBotPeaches/Apktool.git
Move into the directory.
 
cd Apktool
Issue the build.
 
./gradlew build
Then look in
 
/brut.apktool/apktool-cli/build/libs/apktool-xxxxx.jar
Other commands such as clean are
 
./gradlew clean

If you attempt that and dont have JDK installed, it will error out.

You need to download the latest version of the JDK available as a .tar.gz file at http://www.oracle.com/technetwork/java/javase/downloads/index.html

I used jdk-7u9-linux-i586.tar.gz

Once extracted, set the path as the path of the folder containing the bin folder (which contains javac). Note that the path should be the parent of the bin folder, and not include the bin folder itself.
export JAVA_HOME=/home/droidzone/android/java/jdk1.7.0_09
1
    
export JAVA_HOME=/home/droidzone/android/java/jdk1.7.0_09

Here, jdk1.7.0_09/bin contains javac.

The final file will be produced in a location brut.apktool/apktool-cli/build/libs/ relative to the parent and named of the form apktool-cli-1.5.1-SNAPSHOT.jar

So
cp brut.apktool/apktool-cli/build/libs/*jar ./
1
    
cp brut.apktool/apktool-cli/build/libs/*jar ./

should get you the latest file.

Note that you need the wrapper too.
wget http://android-apktool.googlecode.com/files/apktool-install-linux-r04-brut1.tar.bz2 tar -jxvvf apktool-install-linux-r04-brut1.tar.bz2
1
2
    
wget http://android-apktool.googlecode.com/files/apktool-install-linux-r04-brut1.tar.bz2
tar -jxvvf apktool-install-linux-r04-brut1.tar.bz2

Finally since the apktool refers to a file named apktool.jar, create a symlink.

 

Possible errors:
Exception in thread "main" java.lang.UnsupportedClassVersionError: brut/apktool/Main : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334) Could not find the main class: brut.apktool.Main. Program will exit.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    
Exception in thread "main" java.lang.UnsupportedClassVersionError: brut/apktool/Main : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: brut.apktool.Main. Program will exit.

That happens when your main system version java is older than version 7.

You can solve it either by:

1. Upgrading your main java version

2. Setting the PATH of your local java to override your system java.

Eg: If PATH is :/usr/bin:~/bin, make it ~/bin:/usr/bin

3. Creating a symlink in /usr/bin, point it to your version
cd /usr/bin su mv java java.old ln -s /home/droidzone/android/java/jdk1.7.0_09/bin/java java
1
2
3
4
5
6
7
    
cd /usr/bin
 
su
 
mv java java.old
 
ln -s /home/droidzone/android/java/jdk1.7.0_09/bin/java java
1 . 把apk拷到apktool根目录下,执行:./apktool d xxx.apk,会生成xxx目录,里面有res目录(各种资源文件),smali目录(类似src目录,里面文件的语法不一样)及AndroidManifest.xml。 [*.apk->*.jar: sh ./dex2jar/dex2jar.sh xxx.apk,生成xxx_dex2jar.jar通过jd-linux看源码] 2 . 什么apk汉化啊,就到res/values里string.xml里修改字符串,或者拷贝一份values目录改为values-zh-rCN,再去里面修改string.xml里英文字符串改为中文,所谓的汉化就是这么简单。另外,有些图片里不是中文的得去改图片,那得用Photoshop了,图片也不能乱改,格式,图片大小(尺寸)得原来的。 3 . 修改smali文件,这个有些难度。比如有些apk安装了后要积分什么的,比如大于100才可以用的,其实这个值是用SharedPreference存放的,也就是存在xml里,,位置:/data/data/[包名]/shared_prefs的某个xml里,文件不多肯定是可以找到的。另外一种方法就是修改.smali文件也可以达到这目的,软件实现肯定是读取积分那个值给它修改一下就可以了,例如 const/16 v0 100 (其实就是 v0 = 100)这个语法有点像汇编,觉得还是比汇编简单,v0 v1 ...是寄存器,之前会跟变量关联的。具体的还是自己看看smali语法。 4 . 打包生成apk,执行:./apktool b xxx,会在xxx里面生成,一个dist目录,里面就是xxx.apk,但不能安装滴,提示(Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]),没有给这个apk签名, 5 . 签名,执行:sh ./dex2jar/d2j-apk-sign.sh ./xxx/dist/xxx.apk 就是给刚才那个apk签名,生成的文件还是xxx.apkapktool根目录下。这样就大功告成啦。 [请看:http://blog.csdn.net/zhouyuanjing/article/details/7446988]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值