Last active
December 16, 2015 16:58
-
-
Save oa414/5466586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
# A script help to convert Android Application APK file to Jar file | |
# You need to install dex2jar https://code.google.com/p/dex2jar/ and replace the DEX2JAR constant to your dex2jar.sh path | |
# TODO: | |
# - add apktool | |
# - create a better command line prompt | |
# USAGE: | |
# cp the script to your apk file path | |
# ruby apk2jar.rb | |
# creator: Lin Xiangyu | |
# e-mail: lxyweb@gmail.com | |
require "fileutils" | |
require "Shellwords" | |
DEX2JAR = "~/program/dex2jar-0.0.9.13/dex2jar.sh " | |
def escape(str) | |
Shellwords.escape(str) | |
end | |
def path(str) | |
File.expand_path str | |
end | |
def unzip(path) | |
`unzip #{escape(path)}` | |
end | |
def apk2jar(file) | |
if file.end_with?(".apk") | |
puts file | |
unzip file | |
system(DEX2JAR + "classes.dex") | |
jar_name = file[0..-4] + "jar" | |
FileUtils.mv("classes_dex2jar.jar", jar_name) | |
path(jar_name) | |
FileUtils.rm ("classes.dex") | |
end | |
end | |
Dir.foreach(".") do |file| | |
apk2jar file | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment