运行 Dalvik vm 中的 .dex 文件(用 smali 编写)出现验证错误
Running .dex file (written in smali) in Dalvik vm turns out to have a Verification Error
这个'HelloWorld'将两个数字相加并打印出答案
.class public LHelloWorld;
.super Ljava/lang/Object;
.method public static main([Ljava/lang/String;)V
.registers 5
.parameter
.prologue
const v0, 0x2
const v1, 0x4
add-int/2addr v0, v1
new-instance v3, Ljava/lang/StringBuilder;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, "The result is : "
sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
invoke-virtual {v2, v3}, Ljava/lang/PrintStream;->print(Ljava/lang/String;)V
invoke-virtual {v2, v0}, Ljava/lang/PrintStream;->println(Ljava/lang/Integer;)V
return-void
.end method
当我 运行 我的 Android 设备上的 classes.dex 时,adb shell 给我一个错误信息
Unable to find static main(String[]) in 'HelloWorld'
java.lang.VerifyError: Verifier rejected class HelloWorld due to bad method void HelloWorld.main(java.lang.String[]) (declaration of 'HelloW
orld' appears in /storage/extSdCard/HelloWorld.zip)
真不明白为什么会报错
请帮忙,谢谢。
我发现问题出在哪里:
当打印一个 int 数字(不是 Integer 对象)时,参数类型应该是 'I' 而不是 'Java/lang/Integer'.
这个'HelloWorld'将两个数字相加并打印出答案
.class public LHelloWorld;
.super Ljava/lang/Object;
.method public static main([Ljava/lang/String;)V
.registers 5
.parameter
.prologue
const v0, 0x2
const v1, 0x4
add-int/2addr v0, v1
new-instance v3, Ljava/lang/StringBuilder;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, "The result is : "
sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
invoke-virtual {v2, v3}, Ljava/lang/PrintStream;->print(Ljava/lang/String;)V
invoke-virtual {v2, v0}, Ljava/lang/PrintStream;->println(Ljava/lang/Integer;)V
return-void
.end method
当我 运行 我的 Android 设备上的 classes.dex 时,adb shell 给我一个错误信息
Unable to find static main(String[]) in 'HelloWorld'
java.lang.VerifyError: Verifier rejected class HelloWorld due to bad method void HelloWorld.main(java.lang.String[]) (declaration of 'HelloW
orld' appears in /storage/extSdCard/HelloWorld.zip)
真不明白为什么会报错
请帮忙,谢谢。
我发现问题出在哪里: 当打印一个 int 数字(不是 Integer 对象)时,参数类型应该是 'I' 而不是 'Java/lang/Integer'.