反编译android中的xml文件
2016-05-09 22:52
225 查看
一、前言:
大家好,今天给大家分享一下Android中的拿来主义,我们时常会碰到一个自己觉得很漂亮很帅气的应用(apk),所以我们会尝试用WinRAR等之类工具查看,而一般的应用程序打包后的目录通常是这样的如下图:
![](http://hi.csdn.net/attachment/201007/6/0_1278422814OtL8.gif)
当然res里的图片是可以拿来就用的(笔者的好多应用的图片都是从别人的apk里扣出来的),而诸如layout里的布局及权限文件(AndroidManifest.xml)已经是一堆乱码了,完全看不懂,想看看别人是怎么布局的都不容易。还有源代码都被编译成了classes.dex,完全看不出什么线索。基于以上的困惑,笔者给大家分享一下Android中的拿来主义。
二、所需工具(点击各自连接进入下载页面):
1.AXMLPrinter2.jar
2.baksmali.jar
3.smali.jar
三、准备工作
为了方便起见,作者把AXMLPrinter2.jar,还有baksmali.jar,还有smali.jar(下下来为了方便重命名),放在Android SDK tools文件夹中如下图所示:
![](http://hi.csdn.net/attachment/201007/6/0_1278422814OtL8.gif)
为了便于大家更容易程序比对,作者写了一个简单的应用(叫APKInstaller)目录结构如下图所示:
![](http://hi.csdn.net/attachment/201007/6/0_1278423065QDw8.gif)
四、开始拿来主义
1.用AXMLPrinter2.jar查看apk中的布局xml文件:
将ApkInstaller应用生成的ApkInstaller.apk(为了方便起见放到tools目录里)用WinRAR等工具打开,将res/layout/main.xml解压出来(也还是放在tools目录里哦)
打开main.xml文件,内容如下(一堆天文):
![](http://hi.csdn.net/attachment/201007/6/0_12784234694nns.gif)
这时候AXMLPrinter2.jar派上用场了,打开cmd终端,一直进入到tools目录下,输入如下命令:
Java -jar AXMLPrinter2.jar main.xml > main.txt. (如下图所示)
![](http://hi.csdn.net/attachment/201007/6/0_12784239040J8s.gif)
打开main.txt代码如下(是不是有个123了呵呵~):
[html] view
plain copy
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="1"
android:layout_width="-1"
android:layout_height="-1"
>
<WebView
android:id="@7F050000"
android:layout_width="-1"
android:layout_height="-2"
>
</WebView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="1"
android:layout_width="-1"
android:layout_height="-1"
>
<WebView
android:id="@7F050000"
android:layout_width="-1"
android:layout_height="-2"
>
</WebView>
</LinearLayout>
为了比对打开源程序中的main.xml代码如下(大家比对一下吧):
[html] view
plain copy
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView
android:id="@+id/apk_web"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
</LinearLayout>
注意:本文是转载!
大家好,今天给大家分享一下Android中的拿来主义,我们时常会碰到一个自己觉得很漂亮很帅气的应用(apk),所以我们会尝试用WinRAR等之类工具查看,而一般的应用程序打包后的目录通常是这样的如下图:
![](http://hi.csdn.net/attachment/201007/6/0_1278422814OtL8.gif)
当然res里的图片是可以拿来就用的(笔者的好多应用的图片都是从别人的apk里扣出来的),而诸如layout里的布局及权限文件(AndroidManifest.xml)已经是一堆乱码了,完全看不懂,想看看别人是怎么布局的都不容易。还有源代码都被编译成了classes.dex,完全看不出什么线索。基于以上的困惑,笔者给大家分享一下Android中的拿来主义。
二、所需工具(点击各自连接进入下载页面):
1.AXMLPrinter2.jar
2.baksmali.jar
3.smali.jar
三、准备工作
为了方便起见,作者把AXMLPrinter2.jar,还有baksmali.jar,还有smali.jar(下下来为了方便重命名),放在Android SDK tools文件夹中如下图所示:
![](http://hi.csdn.net/attachment/201007/6/0_1278422814OtL8.gif)
为了便于大家更容易程序比对,作者写了一个简单的应用(叫APKInstaller)目录结构如下图所示:
![](http://hi.csdn.net/attachment/201007/6/0_1278423065QDw8.gif)
四、开始拿来主义
1.用AXMLPrinter2.jar查看apk中的布局xml文件:
将ApkInstaller应用生成的ApkInstaller.apk(为了方便起见放到tools目录里)用WinRAR等工具打开,将res/layout/main.xml解压出来(也还是放在tools目录里哦)
打开main.xml文件,内容如下(一堆天文):
![](http://hi.csdn.net/attachment/201007/6/0_12784234694nns.gif)
这时候AXMLPrinter2.jar派上用场了,打开cmd终端,一直进入到tools目录下,输入如下命令:
Java -jar AXMLPrinter2.jar main.xml > main.txt. (如下图所示)
![](http://hi.csdn.net/attachment/201007/6/0_12784239040J8s.gif)
打开main.txt代码如下(是不是有个123了呵呵~):
[html] view
plain copy
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="1"
android:layout_width="-1"
android:layout_height="-1"
>
<WebView
android:id="@7F050000"
android:layout_width="-1"
android:layout_height="-2"
>
</WebView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="1"
android:layout_width="-1"
android:layout_height="-1"
>
<WebView
android:id="@7F050000"
android:layout_width="-1"
android:layout_height="-2"
>
</WebView>
</LinearLayout>
为了比对打开源程序中的main.xml代码如下(大家比对一下吧):
[html] view
plain copy
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView
android:id="@+id/apk_web"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
</LinearLayout>
注意:本文是转载!
相关文章推荐
- Android开发艺术探索(研读笔记)——03-Android中的IPC机制(一)
- Android事件总线分发库EventBus3.0的简单讲解与实践
- Android事件总线分发库EventBus3.0的简单讲解与实践
- 可能是史上最全的Android Studio入门级文档
- 【Android】更换头像的实现
- Android自定义控件之实现一个球赛比分条
- android之interpolator的用法详解
- Android应用内多进程的使用及注意事项
- Xml序列化器
- Android文本框振动效果的实现
- 【Android】自定义状态栏通知
- Android SparseArray的用法
- 在android中用eventBus.2.4.jar中出现的问题
- Android开发——ListView的运用
- Android studio 图片显示过大 RadioButton
- android源码网
- E/AndroidRuntime: FATAL EXCEPTION: main
- Android 开发绕不过的坑:你的 Bitmap 究竟占多大内存?
- Android自定义控件实现一个带文本与数字的圆形进度条
- Android Studio: Missing 32 bit compatbility library