打开main.txt代码如下:
xmlns:android=""
android:orientation="1"
android:layout_width="-1"
android:layout_height="-1"
>
android:id="@7f050000"
android:layout_width="-1"
android:layout_height="-2"
>
为了比对打开源程序中的main.xml代码如下(大家比对一下吧):
http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@ id/apk_web"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
2.用baksmali.jar反编译classes.dex:将apkinstaller.apk里的classes.dex解压到tools目录里,然后baksmali.jar就派上用场了,在cmd命令行里输入如下命令:java -jar baksmali.jar -o classout/ classes.dex .
下面我们看一下apkinstaller.smali内容是什么,如以下代码:
.class public lcom/tutor/apkinstaller/apkinstaller;
.super landroid/app/activity;
.source "apkinstaller.java"
# instance fields
.field private apkweb:landroid/webkit/webview;
# direct methods
.method public constructor ()v
.registers 1
.prologue
.line 8
invoke-direct {p0}, landroid/app/activity;->()v
return-void
.end method
# virtual methods
.method public oncreate(landroid/os/bundle;)v
.registers 5
.parameter "savedinstancestate"
.prologue
.line 13
invoke-super {p0, p1}, landroid/app/activity;->oncreate(landroid/os/bundle;)v
.line 14
const/high16 v2, 0x7f03
invoke-virtual {p0, v2}, lcom/tutor/apkinstaller/apkinstaller;->setcontentview(i)v
.line 15
const/high16 v2, 0x7f05
invoke-virtual {p0, v2}, lcom/tutor/apkinstaller/apkinstaller;->findviewbyid(i)landroid/view/view;
move-result-object v2
check-cast v2, landroid/webkit/webview;
iput-object v2, p0, lcom/tutor/apkinstaller/apkinstaller;->apkweb:landroid/webkit/webview;
.line 16
iget-object v2, p0, lcom/tutor/apkinstaller/apkinstaller;->apkweb:landroid/webkit/webview;
invoke-virtual {v2}, landroid/webkit/webview;->getsettings()landroid/webkit/websettings;
move-result-object v1
.line 17
.local v1, websettings:landroid/webkit/websettings;
const/4 v2, 0x1
invoke-virtual {v1, v2}, landroid/webkit/websettings;->setjavascriptenabled(z)v
.line 19
const-string v0, ""
.line 20
.local v0, apkurl:ljava/lang/string;
iget-object v2, p0, lcom/tutor/apkinstaller/apkinstaller;->apkweb:landroid/webkit/webview;
invoke-virtual {v2, v0}, landroid/webkit/webview;->loadv
.line 21
return-void
.end method
同样为了比对我们看一下apkinstaller.java的源代码如下:
package com.tutor.apkinstaller;
import android.app.activity;
import android.os.bundle;
import android.webkit.websettings;
import android.webkit.webview;
public class apkinstaller extends activity {
private webview apkweb;
@override
public void oncreate(bundle savedinstancestate) {
super.oncreate(savedinstancestate);
setcontentview(r.layout.main);
apkweb = (webview)findviewbyid(r.id.apk_web);
websettings websettings = apkweb.getsettings();
websettings.setjavascriptenabled(true);
string apkurl = "";
apkweb.load;
}
}
我相信大家 已经能看出来门道来了吧,hoho~3.用smali.jar编译classout成classes.dex:我们上一步已经将classes.dex反编译成了.smali文件,好了,我们看看smali文件看够了,在偿试把它编译成classes.dex吧,输入如下命令:java -jar smali.jar classout/ -o
我们可以将新生成的classes.dex塞入apkinstaller.apk里覆盖原来的classes.dex文件,这样我们的apk还是一样能用的哦