前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于反编译的搜索

-------------- \ ^__^ \ (**)\__$__$__ (__)\ )\/\ U ||------| || || --> 反编译百度地图和谷歌地图APK,分析两者intent-filter隐式启动方式 - 推酷 推酷 文章 微博 主题 站点 活动 应用 周刊 编程狂人 设计匠艺 登录 × --> 反编译百度地图和谷歌地图APK,分析两者intent-filter隐式启动方式 时间 2013-04-15 16:31:00 博客园-首页原创精华区 相似文章 (0) 原文 http://www.cnblogs.com/xilinch/archive/2013/04/15/3017128.html 添加到推刊 收藏到你的推刊 创建推刊 反编译百度地图和谷歌地图APK,分析两者intent-filter隐式启动方式 选择推刊 收藏 取消 已收藏到推刊! 创建推刊 × Modal header --> 请填写推刊名 描述不能大于100个字符! 权限设置: 公开 仅自己可见 创建 取消 由于工作原因,大家都可能需要反编译一些apk去学习别人优秀的界面设计或者代码实现,那么网上的关于androd APK反编译的贴已经很多了,大家肯定都非常清楚,有些贴子还非常 贴心的给出了反编译工具的下载链接,非常温馨,对于像我这样下载的反编译工具有时找不见,然后又去翻帖子,可以很快的获得整套工具实现反编译,非常感谢他们!! 同时在看帖子的同时发现有个小小的问题,就是这些帖子给出的托管在服务器上链接下载地址,有时帖子写的比较早,下载的反编译工具版本低,就无法反编译比较新的apk,同时许多 人下载以后并没有看看官网,这工具来源和版本,了解更多一些东西,当然这只是针对于android开发职业的要求,俗话说蛋好吃,无须或者是那只鸡下的蛋,但是如果你是专业下蛋的,那 还是得了解下好哇。 背景交代完毕,下面给介绍一下反编译APK流程,同时附上最新的反编译工具下载地址以及谷歌官网下载链接地址,做专业下蛋。 工具列表: jd-gui,用来查看反编译源码的代码工具,版本比较稳定,一般来说不需要更新 官网地址为 http://java.decompiler.free.fr/?q=jdgui , 下载地址为: http://jd.benow.ca/jd-gui/downloads/jd-gui-0.3.5.windows.zip apktools, 用来反编译源代码和图片、XML配置、语言资源等文件 ,反编译出来的源代码都是一些无法看的文件,这个工具主要用来反编译界面上配置,或者是用来汉化软件。 官网地址: http://code.google.com/p/android-apktool/ 托管地址 : https://code.google.com/p/android-apktool/downloads/list 注意最新的版本为1.5.2,2013.2.2更新的,低于这个版本需要更新。 1.5.2 下载链接 : https://android-apktool.googlecode.com/files/apktool1.5.2.tar.bz2 dex2jar ,用来反编译源码的工具,由谷歌提供,版本在不断更新,反编译版本比编译版本低,就会发生无法反编译成功的意外。 这个工具理解上就是讲dex文件反编译成jar包,而jar我们可以通过jd_gui来查看源码,当然,这里反编译的代码是经过谷歌官方的混淆的。 官网地址: http://code.google.com/p/dex2jar/ 托管地址: http://code.google.com/p/dex2jar/downloads/list 注意最新版本为 dex2jar-0.0.9.11 , 2012.10.25更新的,低于这个版本需要更新。 0.0.9.11 下载地址 : http://dex2jar.googlecode.com/files/dex2jar-0.0.9.13.zip 注意:经过一段时间版本可能会更新,如果大家按照正常的方式提示编译不成功的话,大家则去到官网查看最新版本,是否需要升级 。 以下部分为新手反编译准备,也欢迎大家指正错误,谢谢。 下面是反编译百度地图的步骤: 1.工具准备 ---百度地图 apk+dex2jar+apktools+jd-jui 2.反编译代码 首先将apk文件后缀改为zip并解压,得到其中的classes.dex,它就是java文件编译再通过dx工具打包而成的,将classes.dex复制到dex2jar.bat所在目录 dex2jar-0.0.9.13 文件夹。 在命令行下定位到dex2jar.bat所在目录,运行 1 D:\360Downloads\Apk\dex2jar-0.0.9.13>dex2jar.bat classes.dex 2 this cmd is deprecated, use the d2j-dex2jar if possible 3 dex2jar version: translator-0.0.9.13 4 dex2jar classes.dex -> classes_dex2jar.jar 5 Done. 使用jd-gui打开,如图: 3. 使用apktools,反编译如下: C:\Users\Administrator>d: D:\360Downloads\Apk\apktool1.5.2>apktool.bat d -f baidumap.apk baidu Input file (baidumap.apk) was not found or was not readable. D:\360Downloads\Apk\apktool1.5.2>apktool.bat d -f D:\360Downloads\Apk\baidumap.a pk D:\360Downloads\Apk\baidumap I: Baksmaling... I: Loading resource table... I: Loaded. I: Decoding AndroidManifest.xml with resources... I: Loading resource table from file: C:\Users\Administrator\apktool\framework\1. apk I: Loaded. I: Regular manifest package... I: Decoding file-resources... I: Decoding values */* XMLs... I: Done. I: Copying assets and libs... D:\360Downloads\Apk\apktool1.5.2> 接下来看下反编译出来的东西 代码都是smali,所以你是很难看懂的啦。 通过看assert里面文件夹,其实发现百度地图加载页面其实本地已经有了,服务器传输一些数据过来显示即可,这好像很多程序都是这样做的, 但是注意了,百度的是放在assert里面不是res中,为什么呢?大家想想。 我这次主要就是想看看manifest文件, 我现在关注manifest中,启动百度地图的方式和原理是神马,大家请看下面: 百度manifest文件: 谷歌manifest文件: 百度intent-filter全部如下: View Code 1 <intent-filter> 2 <action android:name="android.intent.action.VIEW" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <data android:mimeType="vnd.android.cursor.item/postal-address_v2" /> 5 </intent-filter> 6 <intent-filter> 7 <action android:name="android.intent.action.CREATE_SHORTCUT" /> 8 </intent-filter> 9 <intent-filter> 10 <action android:name="android.intent.action.VIEW" /> 11 <category android:name="android.intent.category.DEFAULT" /> 12 <data android:mimeType="vnd.android.cursor.item/postal-address" /> 13 </intent-filter> 14 <intent-filter> 15 <action android:name="android.intent.action.VIEW" /> 16 <category android:name="android.intent.category.DEFAULT" /> 17 <data android:scheme="geo" /> 18 </intent-filter> 19 <intent-filter> 20 <action android:name="android.intent.action.VIEW" /> 21 <category android:name="android.intent.category.DEFAULT" /> 22 <data android:scheme="http" android:host="j.map.baidu.com" /> 23 </intent-filter> 24 <intent-filter> 25 <action android:name="android.intent.action.VIEW" /> 26 <category android:name="android.intent.category.DEFAULT" /> 27 <category android:name="android.intent.category.BROWSABLE" /> 28 <data android:scheme="bdapp" android:host="map" /> 29 </intent-filter> 30 <intent-filter> 31 <action android:name="android.intent.action.VIEW" /> 32 <category android:name="android.intent.category.DEFAULT" /> 33 <data android:scheme="http" android:host="api.map.baidu.com" /> 34 </intent-filter> 接下来分析一下intent-filter, 1.通过 发送联系人地址 启动百度地图 APP 在这个intent-filter中,开始的两行说 当你想查看 联系人地址 时,使用地图直接帮你定位到地图中,非常人性化吧, 但是为什么这里给了两个intent-filter呢? postal-address_v2 以及 postal-address,你懂的,android版本差异咯。 对比谷歌的查看联系人地址信息intent-filter 1 <intent-filter android:label="@string/MAPS_APP_NAME"> 2 <action android:name="android.intent.action.VIEW" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <data android:mimeType="vnd.android.cursor.item/postal-address" /> 5 </intent-filter> 6 <intent-filter android:label="@string/MAPS_APP_NAME"> 7 <action android:name="android.intent.action.VIEW" /> 8 <category android:name="android.intent.category.DEFAULT" /> 9 <data android:mimeType="vnd.android.cursor.item/postal-address_v2" /> 10 </intent-filter> 2.通过 geo,启动百度地图APP intent发送geo方式, 百度的 1 <intent-filter> 2 <action android:name="android.intent.action.VIEW" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <data android:scheme="geo" /> 5 </intent-filter> 这个意思就是视同intent.action.view,方式来查看某个地址,而且很巧的是这个地址的开头是geo,那么就通过百度地图APP来打开 谷歌的 1 <intent-filter android:label="@string/MAPS_APP_NAME"> 2 <action android:name="android.intent.action.VIEW" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <category android:name="android.intent.category.BROWSABLE" /> 5 <data android:scheme="geo" /> 6 </intent-filter> 这个意思就是说通过浏览器打开一个地址,而且很巧的是这个地址的开头是geo,那么就通过百度地图APP来打开 3.http打开百度地图 百度 View Code 1 <intent-filter> 2 <action android:name="android.intent.action.VIEW" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <data android:scheme="http" android:host="j.map.baidu.com" /> 5 </intent-filter> 6 <intent-filter> 7 <action android:name="android.intent.action.VIEW" /> 8 <category android:name="android.intent.category.DEFAULT" /> 9 <categoryandroid:name="android.intent.category.BROWSABLE" /> 10 <data android:scheme="bdapp" android:host="map" /> 11 </intent-filter> 12 <intent-filter> 13 <action android:name="android.intent.action.VIEW" /> 14 <category android:name="android.intent.category.DEFAULT" /> 15 <dataandroid:scheme="http"android:host="api.map.baidu.com" /> 16 </intent-filter> 这个意思是说,使用intent-filter-view,启动一个activity,intent中带的数据sceme = http 或者bdapp,且 host= j.baidu.com或者是api.map.baidu.com 的时候,那么就启动百度地图APP 谷歌的 View Code 1 <intent-filter> 2 <action android:name="android.intent.action.VIEW" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <category android:name="android.intent.category.BROWSABLE" /> 5 <data android:scheme="http" /> 6 <data android:scheme="https" /> 7 <data android:host="maps.google.com.br" android:path="/" /> 8 </intent-filter> 9 <intent-filter> 10 <action android:name="android.intent.action.VIEW" /> 11 <category android:name="android.intent.category.DEFAULT" /> 12 <category android:name="android.intent.category.BROWSABLE" /> 13 <data android:scheme="http" /> 14 <data android:scheme="https" /> 15 <data android:host="maps.google.com.br" android:pathPrefix="/maps" /> 16 </intent-filter> 意思是使用intent-filter-view,启动一个activity,intent中带的数据sceme = http,且 host= j.baidu.com 的时候,那么就启动谷歌地图APP, 那么这里有个地方 host,谷歌给很多国家都对应一个host 比如英国:maps.google.com.br 法国:maps.google.fr 等等。 4.谷歌地图有的但是百度地图没有的启动方式 a) 通过nfc近场通讯 谷歌的: 1 <intent-filter> 2 <action android:name="android.nfc.action.NDEF_DISCOVERED" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <data android:scheme="http" /> 5 <data android:scheme="https" /> 6 <data android:host="maps.google.com.br" android:path="/" /> 7 </intent-filter> 8 <intent-filter> 9 <action android:name="android.nfc.action.NDEF_DISCOVERED" /> 10 <category android:name="android.intent.category.DEFAULT" /> 11 <data android:scheme="http" /> 12 <data android:scheme="https" /> 13 <data android:host="maps.google.com.br" android:pathPrefix="/maps" /> 14 </intent-filter> b)通过search来 启动 1 <intent-filter> 2 <action android:name="android.intent.action.SEARCH" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 </intent-filter> c) 通过设置 网络来启动 1 <intent-filter android:label="@string/MAPS_APP_NAME"> 2 <action android:name="android.intent.action.MANAGE_NETWORK_USAGE" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 </intent-filter> 5 <intent-filter android:label="@string/MAPS_APP_NAME"> 6 <action android:name="com.google.android.apps.maps.LOCATION_SETTINGS" /> 7 <category android:name="android.intent.category.DEFAULT" /> 8 </intent-filter> d)通过 全景图 来启动 1 <intent-filter android:label="@string/MAPS_APP_NAME"> 2 <action android:name="android.intent.action.SEND" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <data android:mimeType="application/vnd.google.panorama360+jpg" /> 5 </intent-filter> 这里大家可能不清楚 application/vnd.google.panorama360+jpg 这是个什么玩意,其实这个是谷歌应用市场上的一个付费app。具体大家可以看到 https://play.google.com/store/apps/details?id=com.occipital.panorama e) 这个我也不知道是用来干嘛的 lol 。。。。 1 <intent-filter android:label="@string/MAPS_APP_NAME"> 2 <action android:name="android.intent.action.VIEW" /> 3 <category android:name="android.intent.category.DEFAULT" /> 4 <data android:scheme="google.layeritemdetails" /> 5 </intent-filter> 有什么不对,请大家指正。谢谢 如果你感兴趣 --> 喜 欢 收 藏 分享该文章 分享到 印象笔记 人人网 Facebook Twitter Linkedin Google + E-Mail 有一些书要送给你 > --> 相关微博 共有()条 请登录后评论 已发表评论数() 评论加载中 没有更多评论了^^ 所有评论--> 更多评论 评论加载失败,重新加载 &times; 文章纠错 邮箱 错误类型 正文不准确 排版有问题 没有分页内容 视频无法显示 图片无法显示 补充信息 提交 &times; 用户登陆 邮箱 密码 登 陆 关于 应用 反馈 讨论 友链 推创 &times; 有一些书要送给你[第一季] -->