diff --git a/APKtoJava.au3 b/APKtoJava.au3
index de9cba5..9cc15ce 100644
--- a/APKtoJava.au3
+++ b/APKtoJava.au3
@@ -45,43 +45,43 @@ Next
FixConfig()
;Check for files
-If Not FileExists("tools") Then
+If Not FileExists(@ScriptDir & "\tools") Then
MsgBox(16, "APK to Java", "Missing tools folder, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\7za.exe") Then
+If Not FileExists(@ScriptDir & "\tools\7za.exe") Then
MsgBox(16, "APK to Java", "Missing 7za.exe, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\aapt.exe") Then
+If Not FileExists(@ScriptDir & "\tools\aapt.exe") Then
MsgBox(16, "APK to Java", "Missing aapt.exe, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\apktool.jar") Then
+If Not FileExists(@ScriptDir & "\tools\apktool.jar") Then
MsgBox(16, "APK to Java", "Missing apktool.jar, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\baksmali-2.0.3.jar") Then
+If Not FileExists(@ScriptDir & "\tools\baksmali-2.0.3.jar") Then
MsgBox(16, "APK to Java", "Missing baksmali-2.0.3.jar, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\jd-gui.exe") Then
+If Not FileExists(@ScriptDir & "\tools\jd-gui.exe") Then
MsgBox(16, "APK to Java", "Missing jd-gui.exe, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\lib") Then
+If Not FileExists(@ScriptDir & "\tools\lib") Then
MsgBox(16, "APK to Java", "Missing tools\lib folder, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\dex2jar.bat") Then
+If Not FileExists(@ScriptDir & "\tools\dex2jar.bat") Then
MsgBox(16, "APK to Java", "Missing dex2jar.bat, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\setclasspath.bat") Then
+If Not FileExists(@ScriptDir & "\tools\setclasspath.bat") Then
MsgBox(16, "APK to Java", "Missing setclasspath.bat, please reinstall the application and try again!")
Exit
EndIf
-If Not FileExists("tools\jad.exe") Then
+If Not FileExists(@ScriptDir & "\tools\jad.exe") Then
MsgBox(16, "APK to Java", "Missing jad.exe, please reinstall the application and try again!")
Exit
EndIf
@@ -290,7 +290,7 @@ Func _MakeEclipse()
If FileExists($getpath_outputdir & "\eclipseproject") Then DirRemove($getpath_outputdir & "\eclipseproject", 1)
_AddLog("- Extracting Example Project..")
- RunWait(@ComSpec & " /c " & "7za.exe x -y eclipseproject.zip -o" & $getpath_outputdir & "\eclipseproject", @ScriptDir & "\tools", @SW_HIDE)
+ RunWait(@ComSpec & " /c " & "7za.exe x -y " & @ScriptDir & "\tools\eclipseproject.zip -o" & $getpath_outputdir & "\eclipseproject", @ScriptDir & "\tools", @SW_HIDE)
_AddLog("- Importing AndroidManifest.xml...")
FileCopy($getpath_outputdir & "\resource\AndroidManifest.xml", $getpath_outputdir & "\eclipseproject\AndroidManifest.xml", 1)
@@ -308,9 +308,9 @@ Func _MakeEclipse()
ConsoleWrite($namearray)
;If package name has been found, continue normal procedure
- If $namearray <> "" Then
- _FileWriteToLine($getpath_outputdir & "\eclipseproject\.project", 3, " " & $namearray & "")
- ElseIf $namearray = "" Then
+ If UBound($namearray) > 0 And $namearray[0] <> "" Then
+ _FileWriteToLine($getpath_outputdir & "\eclipseproject\.project", 3, " " & $namearray[0] & "")
+ Else
;In case no package name has been found (very unlikely) use apk name
$lenstring = StringLen(_GetExtProperty($getpath_apkjar, 0))
$nameapk = StringLeft(_GetExtProperty($getpath_apkjar, 0), $lenstring - 3)
@@ -319,11 +319,16 @@ Func _MakeEclipse()
_AddLog("- Setting Target SDK...")
- Local $tarsdkarray
+ Local $tarsdk
;In case no target sdk version has been found, set to API 17 (4.2.2)
$tarsdkarray = StringRegExp(_StringSearchInFile($getpath_outputdir & "\eclipseproject\AndroidManifest.xml", "android:targetSdkVersion"), "android:targetSdkVersion=" & Chr(34) & "(.*?)" & Chr(34), 1, 1)
- If $tarsdkarray = "0" Then $tarsdkarray = "17"
- _FileWriteToLine($getpath_outputdir & "\eclipseproject\project.properties", 14, "target=android-" & $tarsdkarray, 1)
+ If UBound($tarsdkarray) == 0 Or $tarsdkarray[0] == "" Then
+ $tarsdk = "17"
+ Else
+ $tarsdk = $tarsdkarray[0]
+ EndIf
+
+ _FileWriteToLine($getpath_outputdir & "\eclipseproject\project.properties", 14, "target=android-" & $tarsdk, 1)
_AddLog("- Importing Java Sources...")
DirCopy($getpath_outputdir & "\javacode\com", $getpath_outputdir & "\eclipseproject\src\com", 1)
_AddLog("- Making Eclipse Project Done!")
@@ -347,6 +352,11 @@ EndFunc ;==>Restart
+;This version of Apk2Java is used without GUI only with command line parameters.
+;It works only with apks and creates eclipse projects.
+;param1 - apk to decompile
+;param2 - output path
+;The progress is stored in the output directory in the Progress.txt file.
$gui = GUICreate("APK to Java Release Candidate 3 - by broodplank", 550, 490)
$filemenu = GUICtrlCreateMenu("&File")
@@ -395,90 +405,62 @@ GUICtrlCreateLabel("Additional options:", 15, 350)
$decompile_eclipse = GUICtrlCreateCheckbox("Convert output to an Eclipse project", 15, 370)
$decompile_zip = GUICtrlCreateCheckbox("Make zip archive of output files", 15, 390)
-$start_process = GUICtrlCreateButton("Start Decompilation Process!", 5, 420, 290, 25)
-
$copyright = GUICtrlCreateLabel("�2014 broodplank.net - All Rights Reserved", 5, 453)
GUICtrlSetStyle($copyright, $WS_DISABLED)
GUISetState()
-While 1
-
- $msg = GUIGetMsg()
-
- Select
-
- Case $msg = $gui_event_close Or $msg = $filemenu_exit
- Exit
-
- Case $msg = $filebrowse
- $getpath_apkjar = FileOpenDialog("APK to Java, please select an apk/jar file", "", "APK Files (*.apk)|JAR Files (*.jar)", 1, "")
- If $getpath_apkjar = "" Then
- ;
- Else
- If StringInStr(_GetExtProperty($getpath_apkjar, 0), Chr(32), 0, 1) Then
- Dim $msgboxfile
- $msgboxfile = MsgBox(51, "APK To Java Error", "A space has been found in your apk name" & @CRLF & "This can lead to an invalid output and/or errors" & @CRLF & "The main reason is that DOS doesn't allow you to use spaces" & @CRLF & @CRLF & "Do you want to continue?" & @CRLF & @CRLF & "Press 'Yes' to auto remove the spaces from your apk file name and continue the operation" & @CRLF & "Press 'No' to keep the spaces in the apk name (you will regret it)" & @CRLF & "Press 'Cancel' to cancel operation and set apk field blank.")
- If $msgboxfile = 7 Then
- GUICtrlSetData($file, _GetExtProperty($getpath_apkjar, 0))
- ElseIf $msgboxfile = 2 Then
- GUICtrlSetData($file, "")
- ElseIf $msgboxfile = 6 Then
-
- $apknospace = StringStripWS(_GetExtProperty($getpath_apkjar, 0), 8)
+;Refer to the following about the use of command line parameters:
+;http://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine
+$getpath_apkjar = $CmdLine[1]
+If $getpath_apkjar = "" Then
+ ;
+Else
+ If StringInStr(_GetExtProperty($getpath_apkjar, 0), Chr(32), 0, 1) Then
+ Dim $msgboxfile
+ $msgboxfile = MsgBox(51, "APK To Java Error", "A space has been found in your apk name" & @CRLF & "This can lead to an invalid output and/or errors" & @CRLF & "The main reason is that DOS doesn't allow you to use spaces" & @CRLF & @CRLF & "Do you want to continue?" & @CRLF & @CRLF & "Press 'Yes' to auto remove the spaces from your apk file name and continue the operation" & @CRLF & "Press 'No' to keep the spaces in the apk name (you will regret it)" & @CRLF & "Press 'Cancel' to cancel operation and set apk field blank.")
+ If $msgboxfile = 7 Then
+ GUICtrlSetData($file, _GetExtProperty($getpath_apkjar, 0))
+ ElseIf $msgboxfile = 2 Then
+ GUICtrlSetData($file, "")
+ ElseIf $msgboxfile = 6 Then
- FileMove($getpath_apkjar, GetDir($getpath_apkjar) & $apknospace)
- GUICtrlSetData($file, $apknospace, 0)
+ $apknospace = StringStripWS(_GetExtProperty($getpath_apkjar, 0), 8)
- $getpath_apkjar = GetDir($getpath_apkjar) & $apknospace
+ FileMove($getpath_apkjar, GetDir($getpath_apkjar) & $apknospace)
+ GUICtrlSetData($file, $apknospace, 0)
- EndIf
- Else
- GUICtrlSetData($file, _GetExtProperty($getpath_apkjar, 0))
- EndIf
-
- If GUICtrlRead($filedex) <> "" Then GUICtrlSetData($filedex, "")
- EndIf
+ $getpath_apkjar = GetDir($getpath_apkjar) & $apknospace
- Case $msg = $filebrowsedex
- $getpath_classes = FileOpenDialog("APK to Java, please select a classes.dex file", "", "DEX Files (*.dex)", 1, "classes.dex")
- If $getpath_classes = "" Then
- ;
- Else
- GUICtrlSetData($filedex, _GetExtProperty($getpath_classes, 0))
- If GUICtrlRead($file) <> "" Then GUICtrlSetData($file, "")
- EndIf
-
- Case $msg = $destdirbrowse
- $getpath_outputdir = FileSelectFolder("APK to Java, please select the output directory", "", 7, "")
- If $getpath_outputdir = "" Then
- GUICtrlSetData($destination, "")
- Else
- GUICtrlSetData($destination, $getpath_outputdir)
- If StringInStr($getpath_outputdir, Chr(32), 1) Then
- Dim $msgbox
- $msgbox = MsgBox(49, "APK To Java Warning", "A space has been found in your destination directory." & @CRLF & "This can lead to an invalid output." & @CRLF & "Do you want to continue?")
- If $msgbox = 1 Then
- GUICtrlSetData($destination, $getpath_outputdir)
- ElseIf $msgbox = 2 Then
- GUICtrlSetData($destination, "")
- EndIf
- EndIf
- EndIf
+ EndIf
+ Else
+ GUICtrlSetData($file, _GetExtProperty($getpath_apkjar, 0))
+ EndIf
- Case $msg = $decompile_eclipse And BitAND(GUICtrlRead($decompile_eclipse), $GUI_CHECKED) = $GUI_CHECKED
- GUICtrlSetState($decompile_resource, $GUI_CHECKED)
- GUICtrlSetState($decompile_resource, $GUI_DISABLE)
- GUICtrlSetState($decompile_source_java, $GUI_CHECKED)
- GUICtrlSetState($decompile_source_java, $GUI_DISABLE)
+ If GUICtrlRead($filedex) <> "" Then GUICtrlSetData($filedex, "")
+EndIf
- Case $msg = $decompile_eclipse And BitAND(GUICtrlRead($decompile_eclipse), $GUI_UnChecked) = $GUI_UnChecked
- GUICtrlSetState($decompile_resource, $GUI_UnChecked)
- GUICtrlSetState($decompile_resource, $GUI_ENABLE)
- GUICtrlSetState($decompile_source_java, $GUI_UnChecked)
- GUICtrlSetState($decompile_source_java, $GUI_ENABLE)
+$getpath_outputdir = $CmdLine[2]
+If $getpath_outputdir = "" Then
+ GUICtrlSetData($destination, "")
+Else
+ GUICtrlSetData($destination, $getpath_outputdir)
+ If StringInStr($getpath_outputdir, Chr(32), 1) Then
+ Dim $msgbox
+ $msgbox = MsgBox(49, "APK To Java Warning", "A space has been found in your destination directory." & @CRLF & "This can lead to an invalid output." & @CRLF & "Do you want to continue?")
+ If $msgbox = 1 Then
+ GUICtrlSetData($destination, $getpath_outputdir)
+ ElseIf $msgbox = 2 Then
+ GUICtrlSetData($destination, "")
+ EndIf
+ EndIf
+EndIf
- Case $msg = $start_process
+GUICtrlSetState($decompile_eclipse, $GUI_CHECKED)
+GUICtrlSetState($decompile_resource, $GUI_CHECKED)
+GUICtrlSetState($decompile_resource, $GUI_DISABLE)
+GUICtrlSetState($decompile_source_java, $GUI_CHECKED)
+GUICtrlSetState($decompile_source_java, $GUI_DISABLE)
If GUICtrlRead($file) = "" Then
If GUICtrlRead($filedex) = "" Then
@@ -519,30 +501,17 @@ While 1
EndIf
-
- Case $msg = $helpmenu_help
- _RunDos("start " & @ScriptDir & "\help.chm")
-
- Case $msg = $helpmenu_about
- MsgBox(0, "APK to Java -- About", "About APK to Java" & @CRLF & @CRLF & "APK to Java" & @CRLF & "Version: RC3" & @CRLF & "Author: broodplank(1337)" & @CRLF & "Site: www.broodplank.net")
-
- Case $msg = $helpmenu_donate
- _RunDos("start http://forum.xda-developers.com/donatetome.php?u=4354408")
-
- Case $msg = $optionsmenu_preferences
- _PreferencesMenu()
-
- Case $msg = $filemenu_restart
- If ProcessExists("APKtoJava.exe") Then
- OnAutoItExitRegister("Restart")
- Exit
- EndIf
-
-
-
- EndSelect
-
-WEnd
+;While 1
+; $msg2 = GUIGetMsg()
+;
+; Select
+;
+; Case $msg2 = $gui_event_close
+; Exit
+; EndSelect
+;WEnd
+
+;Exit
; #FUNCTION# ======================================================================================================
diff --git a/APKtoJava.exe b/APKtoJava.exe
index 5184882..20c5a0a 100755
Binary files a/APKtoJava.exe and b/APKtoJava.exe differ
diff --git a/tools/jd-gui.cfg b/tools/jd-gui.cfg
index ee8e04f..197c955 100644
--- a/tools/jd-gui.cfg
+++ b/tools/jd-gui.cfg
@@ -1,9 +1,9 @@
[RecentDirectories]
-LoadPath=Z:\\home\\broodplank\\APKtoJava\\tools\\
-SavePath=Z:\\home\\broodplank\\APKtoJava\\tools\\
+LoadPath=D:\\Workspaces\\SsSDK\\contest_dev\\APKtoJava\\tools\\
+SavePath=D:\\Workspaces\\SsSDK\\contest_dev\\APKtoJava\\tools\\
[Manifest]
Version=2
[Update]
CurrentVersion=0.3.6
[RecentFiles]
-Path0=Z:\\home\\broodplank\\APKtoJava\\tools\\classes_dex2jar.jar
+Path0=D:\\Workspaces\\SsSDK\\contest_dev\\APKtoJava\\tools\\classes_dex2jar.jar