APK to Java Beta
Description:
Since I'm into making Android Apps nowadays, I thought of making this tool to save me (and you) time. So I started coding it and it worked out pretty well so far. The tool can decompiles your selected apk to Java code, to learn from it, so as an educational purpose.
Additionally it also can decompile to smali code and it can decompile the resources of the app. It's currently a very early beta but it works successfully (at least at my computer)
Used External Tools:
- 7za
- apktool
- baksmali-1.4.0
- jd-gui
- dex2jar
Requirements:
- JRE 6/7 (I think that's all, but maybe android-sdk is needed, I guess not)
Screenshots:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Added very basic help file, various code fixes (no errors should occur on decompiling java/smali/resource. the Eclipse projects are still bugged though)
Download:
Version 0.9 beta (check github for changelog):
Mirror #1: broodplank.net
Mirror #2: Mediafire.com
Version 0.8 beta (check github for changelog):
Mirror #1: broodplank.net
Mirror #2: Mediafire.com
Version 0.7 beta (check github for changelog):
Mirror #1: broodplank.net
Mirror #2: Mediafire.com
Version 0.6 beta (check github for changelog):
Mirror #1: broodplank.net
Mirror #2: Mediafire.com
Version 0.5 beta:
Mirror #1: broodplank.net
Mirror #2: Mediafire.com
Github Sources:
https://github.com/broodplank/APKtoJava
Please let me know how it runs!
Thanks! Was looking for a tool like this. I need to learn a lot about developing android apps. Will download this as soon as i get on my PC this evening.
Sent from my GT-S5360 using xda premium
anasdcool71 said:
Thanks! Was looking for a tool like this. I need to learn a lot about developing android apps. Will download this as soon as i get on my PC this evening.
Sent from my GT-S5360 using xda premium
Click to expand...
Click to collapse
You're welcome! Please let me know your experience with the app, it still needs a lot of testing!
Alright, so i tested the 0.6 beta. I chose my app from eclipse, as i already knew its source code. Decompiling into resources and smali files are working totally fine, but it is not able to generate the java code. I got that message :-
I went to jd-gui and did what i was told, but nothing happened. After clicking OK, an error message came that the input file was invalid. After that the tool won't close. I had to open the task manager to end it.
anasdcool71 said:
Alright, so i tested the 0.6 beta. I chose my app from eclipse, as i already knew its source code. Decompiling into resources and smali files are working totally fine, but it is not able to generate the java code. I got that message :-
I went to jd-gui and did what i was told, but nothing happened. After clicking OK, an error message came that the input file was invalid. After that the tool won't close. I had to open the task manager to end it.
Click to expand...
Click to collapse
Thanks for your feedback, I had the same error once, it seems there is a problem with this file "dex2jar.bat". somehow I just doesn't get executed the right way, the strange thing is that it's executed the same way as the other batch files, and if I do it manually: "dex2jar.bat classes.dex" then it also works..
So I though maybe the working directory needs to be set.
edit:
Code:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit
Press any key to continue . . .
so that's the problem . Will lower the heap ^^
Open the /tools/dex2jar.bat file and paste this contents into it:
Code:
@echo off
cd /d %~dp0
REM
REM dex2jar - Tools to work with android .dex and java .class files
REM Copyright (c) 2009-2012 Panxiaobo
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.
REM
set CLASSPATH=
FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" %%i
java -Xms512m -cp "%CLASSPATH%" "com.googlecode.dex2jar.tools.Dex2jarCmd" %*
new version released! the option to convert to an Eclipse project is now available (still beta though)
See changes here
Btw i forgot a critical fix. Check latest commit for fix
Awesome apk.
tapatalked² from cowsquadGnex®
cowsquad said:
Awesome apk.
tapatalked² from cowsquadGnex®
Click to expand...
Click to collapse
Thanks.
btw, V0.8 released!
Changes: 1 2 3
It's becoming much more stable luckily
Alright bro, i've to yet try the 0.8 version (using the 0.6). Your solution worked. My source was decompiled to the java files. But i see there were some changes :-
1) I saw that the 'this' keyword was used before almost every variable even if i hadn't included it (but that's not much of a problem, though).
2) I had used that tag R.id.editText1, R.id.radioButton1, etc. to use my views from the res folder. But in place of those, there were some numbers.. I really find it hard to work with them.
anasdcool71 said:
Alright bro, i've to yet try the 0.8 version (using the 0.6). Your solution worked. My source was decompiled to the java files. But i see there were some changes :-
1) I saw that the 'this' keyword was used before almost every variable even if i hadn't included it (but that's not much of a problem, though).
2) I had used that tag R.id.editText1, R.id.radioButton1, etc. to use my views from the res folder. But in place of those, there were some numbers.. I really find it hard to work with them.
Click to expand...
Click to collapse
Hmm the random numbers as variables kinda sucks, I know, but that's just the way the program (jd-gui) works unfortunately, it makes things a lot harder to read but at least it's a working java source. Unfortunately jd-gui doesn't have any commandline tool with several switches. (I saw some other jar to java decompilers, but they gave a source code even more strange, so I think jd-gui is the best solution for now, of course I will update it if possible)
Looking forward to more updates for this great tool!
emd2009 said:
Looking forward to more updates for this great tool!
Click to expand...
Click to collapse
v0.9 released
Changes: 1 2 3
With all versions of your tool, including v9, I get an error whenever I export as an Eclipse project:
Line 4503 in APKtoJava.exe
Error: Subscript used with non-Array variable
emd2009 said:
With all versions of your tool, including v9, I get an error whenever I export as an Eclipse project:
Line 4503 in APKtoJava.exe
Error: Subscript used with non-Array variable
Click to expand...
Click to collapse
Thanks for letting me know. Ill take a look at it ^-^
I think i know what to change
Attached a screenshot of the error when trying to get an eclipse project (happens after the JD-GUI thing)
Jonny said:
Attached a screenshot of the error when trying to get an eclipse project (happens after the JD-GUI thing)
Click to expand...
Click to collapse
Thanks, more people reported that problem, I think changing this: "$namearray[0]" to "$namearray" and "$tarsdkarray[0]" to "$tarsdkarray" will do the trick, but I'm not sure since it always works at my computer no matter if I put [0] or nothing.
Ill upload new version soon
Related
Hello everybody,
Here is the unyaffs tool for Windows including the latest cygwin1.dll to get it working without having to install Cygwin !
This tool can extract *.img (YAFFS) android files.
This is a command-line utility.
Usage: open cmd, go to unyaffs.exe folder and type: unyaffs image_file_name
DOWNLOAD on Mediafire
Over 900 downloads !
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Sources : unyaffs project, Cygwin
adridu59 said:
Hello everybody,
Here is the unyaffs tool for Windows including the latest cygwin1.dll to get it working without having to install Cygwin !
This tool can extract *.img (YAFFS) android files.
This is a command-line utility.
Usage: open cmd, go to unyaffs.exe folder and type unyaffs image_file_name
DOWNLOAD on Mediafire
PLEASE CLICK ON THE THANKS BUTTON IF THAT HELPED.
Click to expand...
Click to collapse
What did you use to compile it on Windows?
Droidzone said:
What did you use to compile it on Windows?
Click to expand...
Click to collapse
I didn't compile it, just downloaded unyaffs binaries and grabbed Cygwin dll from cygwin binaries.
Very simple stuff but I'm not sure everyone will think to do it. Installing Cygwin is a pain, this way is much more simpler.
Cant get this to work get a STATUS_ACCESS_VIOLATION at eip=004010B0 error,have tried various tutorials/sources and just cannot get it to work
EDIT I am too stupid to get this to work,managed to get what I needed extracted by using ext2explore.
adridu59 said:
I didn't compile it, just downloaded latest unyaffs binaries and grabbed Cygwin dll from cygwin binaries.
Very simple stuff but I'm not sure everyone will think to do it. Installing Cygwin is a pain, this way is much more simpler.
Click to expand...
Click to collapse
a) Well if you didn't compile it, where did you get the binaries from? (And who compiled them, what version etc.??) Give us a link!
b) Cygwin is generally a piece of cake to install! But it doesn't contain any YAFFS binaries or sources!
So what have you been doing dude, and why should we trust your stuff??
To everyone: I would NOT run any exe from this guy, unless he can show his sources and what he did.
E:V:A said:
a) Well if you didn't compile it, where did you get the binaries from? (And who compiled them, what version etc.??) Give us a link!
b) Cygwin is generally a piece of cake to install! But it doesn't contain any YAFFS binaries or sources!
So what have you been doing dude, and why should we trust your stuff??
To everyone: I would NOT run any exe from this guy, unless he can show his sources and what he did.
Click to expand...
Click to collapse
Are you one of those purists who only run selfcompiled code ?
Unyaffs tool needs Cygwin dll to run on Windows.
"What version" --> There is only one release from Dec 2008 if you took some time for looking at project page.
Now next time be less aggresive and stop calling me "this guy", thanks in advance.
if you dont trust him why u even post on this thread about his work?
bs828 said:
if you dont trust him why u even post on this thread about his work?
Click to expand...
Click to collapse
I think he wanted to get thanked. Ridiculous.
Give me a verification post and this will be my img recompile tool.!
I don't believe in bashing anyone, I think he is trying to make a name for himself like everyone else, credits to you dude, but I'm gonna hold back trying this out until I get just a little more info on it. Great work ahead of time though dude.!
Sent from my PG86100 using XDA App
He judged my exe too....
ognimnella said:
Give me a verification post and this will be my img recompile tool.!
Click to expand...
Click to collapse
What do you mean ?
Download official unyaffs and official Cygwin if you are afraid.
Sent from my MT15i
This is great! It worked when unpacking a system.img from SDK but not my system.img I made with Fruit Cake Maker
Here is the stackdump I got when trying
Any help is appreciated thank you
adridu59 said:
What do you mean ?
Download official unyaffs and official Cygwin if you are afraid.
Sent from my MT15i
Click to expand...
Click to collapse
I mean gimme a post saying it works.!
Sent from my HTC EVO 3D using XDA App
fergie716 said:
This is great! It worked when unpacking a system.img from SDK but not my system.img I made with Fruit Cake Maker
Here is the stackdump I got when trying
Click to expand...
Click to collapse
I do not provide support, sorry.
Slight bump.
Is not necessary to install Cygwin. It's enough Cygwin.dll.
There are some new structure for YAFFS file iamge (ex. 8192 bytes /segment and 448 bytes /spare)
The new utility (unyaffs) can support it, but if you want to recompile it should be encessary also makeyaffs (and it should be run under Linux - not under Windows)
Some link about other utils
Unyaffs /ehlers) - source: https://github.com/ehlers/unyaffs
To compile under Windows it's quite simple.
Install Cygwinwin (downlaod http://cygwin.com/setup.exe and run it).
As modules select: "gcc", "gdb" and "make".
Create a folder under "/Cygwin/home/@username" and put here the program source.
Run Cygwin. Go to the source directory. Run "make". You will have the .exe file compiled.
Copy the compiled .exe file plus CYGWIN.DLL (available in \CYGWIN) and in other folder and you can run utility.
Other usefull tools: http://code.google.com/p/yaffs2utils/
I tried to unyaff the system.img from the HTC Desire C RUU. This is the error it gave me, and I don't know why.
Exception: STATUS_ACCESS_VIOLATION at eip=004010B0
eax=00010000 ebx=00000001 ecx=FFFFFFFD edx=00AB13FA esi=0040130E edi=610E21A0
ebp=0028EE88 esp=0028EE50 program=C:\Users\Andu\Desktop\unyaffs\unyaffs.exe, pid 6012, thread main
cs=0023 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame Function Args
0028EE88 004010B0 (0028EEE9, 00000000, 00000000, 00401333)
0028EEB8 004013AF (00000002, 00AB0190, 00AB0090, 610A5E22)
0028EFA8 61004DD2 (0028EFC0, FFFFFFFF, 007DA588, 007B00C4)
0028FF58 6100594F (00000000, 00000000, 00000000, 00000000)
End of stack trace
I tried running cmd as Admin, same error.
abaaaabbbb63 said:
I tried to unyaff the system.img from the HTC Desire C RUU. This is the error it gave me, and I don't know why.
Exception: STATUS_ACCESS_VIOLATION at eip=004010B0
eax=00010000 ebx=00000001 ecx=FFFFFFFD edx=00AB13FA esi=0040130E edi=610E21A0
ebp=0028EE88 esp=0028EE50 program=C:\Users\Andu\Desktop\unyaffs\unyaffs.exe, pid 6012, thread main
cs=0023 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame Function Args
0028EE88 004010B0 (0028EEE9, 00000000, 00000000, 00401333)
0028EEB8 004013AF (00000002, 00AB0190, 00AB0090, 610A5E22)
0028EFA8 61004DD2 (0028EFC0, FFFFFFFF, 007DA588, 007B00C4)
0028FF58 6100594F (00000000, 00000000, 00000000, 00000000)
End of stack trace
I tried running cmd as Admin, same error.
Click to expand...
Click to collapse
I too got an error like this
???
ROM>unyaffs system.img
140 [main] unyaffs 1192 handle_exceptions: Exception: STATUS_ACCESS_VIOLATIO
N
1064 [main] unyaffs 1192 open_stackdumpfile: Dumping stack trace to unyaffs.e
xe.stackdump
????
plz help
Yea...you got that because system.img is an ext type file, not a yaffs. Search for an ext explorer.
Sent from my toaster
This utility acts weird when I have ran it first time.
- It has hidden all processes in my task manager and procexplorer (systernals),
- ProcMon (systernals) was showing that process is hooked to system32/wow64 and registry
- it raised 6 (out of 44) cores of my CPU to 100%
- I couldn't exit nor kill command windows. As I run windows server 2016 which is very reliable I find strange that one can't kill a command window.
After reboot:
- I moved this into vmware to analyze with olidbg but then it behaved as it should.
- olydbg shows that exe imports kernel dlls which is unusuall since cygwin provides integration with the OS.
My feeling:
- I would not use this exe again.
- When I see communication between member who provided it and others, I trust it less.
Android Multitool
Hello,
I´m glad to present my Android Multitool wich makes it easier to decompile/recompile applications + jar framework files. You can also sign your apk by easily clicking a button.
Requirements:
Winows OS XP / 7 / 8 / 8.1 / 10
Installed Java on Windows
Installed Microsoft Powerpacks
Installed .NET framework
- Easy handling: Select your apk and push the "decompile" button!
- This tool makes modding much faster and easier, no cmd handling any more.
- You can read the log which is integrated in the tool to find your mistake in the error.
- ADB inside: Push files into your file system with a few clicks
It looks like this so far:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
How to use this tool?
Follow this small how to!
Here you go..
Well, first extract the AndroidMultitool folder to C:\. Otherwise it probably won´t work
-copy your framework-res.apk in the Framework-Files folder and other files you want to mod in the "Files" folder (this folder is for all your files you want to mod, don't pick files from any other location)
-Next you have to start AndroidMultitool.exe
-select your framework-res.apk and push the "install" button (check log for errors)
Decompiling and recompiling apk files:
-select the apk you want to mod/decompile and push the "decompile" button (check log for errors)
Note: You can check the "use baksmali" checkbox, then e.g. the useless .line text will be removed
-your decompiled apk will be located in C:\AndroidMultitool\Decompiled_apk"apkname" as a folder
-if you want to compile your apk again, select your decompiled folder, check the "apk" radio button and compile it again (check log for errors)
-your recompiled apk will be located in C:\AndroidMultitool\Compiled_apk"apkname"
Decompiling and recompiling jar files:
-select in the combobox ".jar" (check the "use baksmali" checkbox for deleting the useless .line comments)
-select the ".jar" file you want to mod
-push the "decompile" button
-your decompiled jar file will be locaten in C:\AndroidMultitool\Decompiled_jar"jarname"
-for recompiling you have to check the "jar" radiobutton and select the folder within your decompiled ".jar" file
-push the compile button
-your compiled jar file will be located in C:\AndroidMultitool\Compiled_jar"jarname"\classes.dex
-delete the "classes.dex" file in your ".jar" file
-copy the new "classes.dex" file you compiled in the ".jar" file
Signing apk files:
-select the ".apk" you want to sign
-push the "sign" button
-the signed apk file is located in C:\AndroidMultitool\Signed_apk"apkname_signed"
Using tags:
You want to decompile many files from different devices or different android versions / frameworks? Tagging makes it possible!
- before installing your framework type in any tag (like "hero")
- then install your framework and work normally
Android Debug Bridge
You want to push files with adb to your device? Follow these instructions:
Please klick on the "advanced" register in the tool
-push "check" to control if your device is ready
-if the device is not ready please follow the instructions, which are listed in the tool (device offline, no device...)
-if the device is ready, choose a file you want to push
-choose a path on the device, where the file should be placed later
-push the "push" Button
-alternately: press "Reboot device" to reboot your device and to let changes take effect
If there are any questions or bugs, please post them in the thread.
Follow me on Google+ : Daniel Huber
[DOWNLOAD] see next post #2
Enjoy easier apk handling!
Having issues with the program?
Try the batch version developed by @bovirus (it's also in the AndroidMultitool folder)
Questions and answers:
Q: The programm does not start, it crashes.
A: Please install Powerpacks, this one: http://go.microsoft.com/fwlink/?LinkID=145727&clcid=0x804
Q: What do you mean exactly with "!!!NOTE!!! After compiling you have to copy the AndroidManifest.xml and the META-INF folder from your old apk to your newly compiled one!! Otherwise you´ll get bootloop! " .. I don't understand.
A: You have to open your old apk (this one you selected for decompiling in the folder /files) and copy from that apk the AndroidManifest.xml and the META-INF folder to the apk you just decompiled and recompiled.
Q: I followed all steps in the startpost but I'm still getting this error: "apktool is not recognized as internal or external command"
What can I do?
A: Please refer to this post by @LasVegasRomeo: http://forum.xda-developers.com/showpost.php?p=51017662&postcount=681
Credits:
Developers (brut.all, iBotPeaches) of the base Apktool
mike_galaxy_s for his help on testing
@bovirus for batch development
------------------------------------------------------
Changelog:
v3.5.9:
updated build tools and platform-tools (aapt, adb and needed dll's)
updated 7za, apktool, smali and baksmali to latest version
added bovirus's batch version to the main directory (users can choose between gui and batch now)
added a folder (Framework-Files) for the framework-res.apk (only use this folder for the framework files from now on)
added a Help folder with all commands
v3.5.8:
updated build tools and platform-tools (aapt, adb and needed dll's)
updated apktool, smali and baksmali to latest version
v3.5.7:
updated build tools and platform-tools (aapt, adb and needed dll's)
updated apktool, smali and baksmali to latest version
v3.5.6:
fix progressbar not disappearing after decompiling
fix loop after/while compiling
save compiling path and jump into it when he starts folder browsing
update user interface
v3.5.5:
fix infinite loop on compiling when errors appeared
folderbrowserdialog (compiling): jump into /decompiled_apk default
update build tools and platform-tools (aapt, adb and needed dll's)
v3.5.4:
add option to copy AndroidManifest.xml automatically into the apk after compiling
layout cleanup
force overwrite already compiled or decompiled files when new compiling/decompiling thread started
update to apktool rc3 (mainly lollipop support)
v3.5.3:
copy AndroidManifest.xml and META-INF folder automatically into the apk after compiling
added some links
code cleanup
v3.5.2:
add more detailed log
fix decompiling/compiling/signing/installing framework multiple times sometimes
add batch decompiling (preview)
fix donation image not fitting center
add txt files with descriptions for all tools inside (thanks to @bovirus)
v3.5.1:
update all files
v3.5:
code rework
fix UI freezing on long tasks
add progress bar
many other small fixes
v3.4:
access files from all locations of the pc (you're not limeted to the /Files folder)
add version number to the tool
v3.3:
add tag support (tagging allows multiple framework support)
rework interface
small additions and fixes
support for Win7 / 8 / 8.1 (no extra versions)
v3.2.1:
add apktool b9
v3.2:
add different apktool, aapt and batch files
should solve some problems on de - and recompiling
v3.1:
Fixes for adb push
button to reboot device
many other fixes and code rework
v3.0:
SlimBean apktool ((de)compiling also with inverted folders from trds)
ADB (AndroidDebugBridge for pushing files to your device)
Some Links in the tool for support and donation
v2.2 Beta1:
apktool 2.0.0
Details:
Details
v1.5.x -> v2.0.0
Java JRE 1.7 is required!
Update apktool to v2.0.0
aapt is now included inside the apktool binary. Its not required to maintain your own aapt install under $PATH. (However, features like -a / --aapt are still used and can override the internal aapt).
Remove framework $HOME/apktool/framework/1.apk or manually update via (FrameworkFiles)
Eagle eye users will notice resources are now decoded before sources now. This is because we need to know the API version via the manifest for decoding the sources.
Parameter Changes
Smali/baksmali 2.0 are included. This is a big change from 1.4.2. Please read the smali updates here for more information.
-o / --output is now used for the output of apk/directory.
-t / --tag is required for tagging framework files
-advance / --advanced will launch advance parameters and information on the usage output.
-m / --match-original is a new feature for apk analysis. This retains the apk is nearly original format, but will make rebuild more than likely not work due to ignoring the changes that newer aapt requires.
After [d]ecode, there will be new folders (original / unknown) in the decoded apk folder.
original/ = META-INF folder / AndroidManifest.xml, which are needed to retain the signature of APKs to prevent resigning. Used with -c / --copy-original on uild.
unknown/ = Files / folders that are not part of the standard AOSP build procedure. These files will be injected back into the rebuilt APK.
apktool.yml collects more information than before
SdkInfo = Used to re-populate the sdk information in AndroidManifest.xml since aapt requires it to be passed at runtime.
packageInfo = Used to help support Android 4.2 due to renamed manifest packages. Automatically detects difference between manifest and resources and performs automatic --rename-manifest-package on uild.
versionInfo = Used to re-populate the version information in the AndroidManifest.xml since aapt requires it to be passed at runtime.
compressionType = Used to determine the compression that resources.arsc had on the original apk to duplicate on uild.
unknownFiles = Used to record the name/location/compression type of non-standard files in Apk.
v2.1:
fixed freezes
bigger UI for better overview
option to save log to a text file
other small fixes
v2.0:
complete code rework
folder structure for a better overview
decompiled, recompiled, signed files will be located in their own folder
no more messy file handling
added radio buttons for choosing jar or apk
some graphical changes
added info button in the "installing framework" section
V1.2:
Added ability to decompile and recompile ".jar" files
Added baksmali
FolderBrowserDialog: If you push the "browse" button you are in the right directory now and needn't to scroll and search the "AndroidApktool" folder
other small fixes
V1.1:
Added ability to sign .apk
Changed comboboxes to browse buttons
bigger log - screen
Initial Release
- Latest mod version
Latest version is: 3.5.9 (23.10.2018) updated by bovirus
This version is based on original v. 3.5.9 by Flextrick plus with these updates
- apktool (by iBotPeaches) v. 2.3.4 stable
- apktool commands list
- baksmali/smali (by JesusFreke) v. 2.2.5 stable
- baksmali/smali command list
- Android Build Tools (by Google) v. 28.0.3 stable
- Android Build Tools commands list
- Android Platform Tools (by Google) v. 28.0.1 stable
- Android Platform Tools commands list
- 7zip (by Igor Pavlov) v. 18.05
- DOS batch updated (now support file names with spaces)
With the DOS batch (file AMT.BAT) you can
- install framework file
- select application
- decompile application
- compile application
- sign application
Android Multitool v. 3.5.9 (updated) - Download
- Android Multitool previous version
Library of previous version (Google Drive)
Note: Please take care that v. 3.5.9 (stock) included in the Google Drive repository DON'T include all updates reported before.
- Use always updated framework-res.apk
If you get error during decompilation/compilation of the apk, please check if you are using and updated version of framework.res.apk.
Please try to search, find and download an updated version of framework.-res.apk
Note: I suggest to rename the framework downloaded file name (without spaces) adding some info about it (like brand-model of device and Android version), like
framework-Samsung-S8-Android-7.1.2.apk
put the file in it in Framework-Files sub-folder of Android Multitool and install it in Android Multitool.
Then try again to decompile/recompile the application.
- External references
- apktool by iBotpeaches
apktool by iBotPeaches - XDA thread
apktool by iBotPeaches - XDA thread
- baksmali/smaly by JesusFreke
baksmali/smaly by JesusFreke - Download (bitbucket.org)
baksmali/smaly - XDA discussion thread
baksmali/smaly by JesusFreke - Source (Github)
- 7zip by Igor Pavlov
7zip by Igor Pavlov - Tool to decompress/compress files
- Android Platform Tools by Google
Android Platform Tools by Google - latest Windows version
..
Very nice tool!
One feature request, could you have a checkbox for say the -b command so that we can get rid of the useless .linexx and .prologue lines? That would make this tool perfect
Another feature is adding the twframework-res.apk as a framework file? Thats essential for modding samsung system apk's. I usually have to install both twframework-res.apk and framework-res.apk before decompiling. Maybe adding 2 slots for the framework in the tool?
Thanks again!!
Good work bro....
Very nice..
Sent from my GT-S6312 using xda app-developers app
clark44 said:
Very nice tool!
One feature request, could you have a checkbox for say the -b command so that we can get rid of the useless .linexx and .parameterxx lines? That would make this tool perfect
Another feature is adding the twframework-res.apk as a framework file? Thats essential for modding samsung system apk's. I usually have to install both twframework-res.apk and framework-res.apk before decompiling. Maybe adding 2 slots for the framework in the tool?
Thanks again!!
Click to expand...
Click to collapse
Sure, adding a second slot will be no problem!
But I don't know what you mean with this checkbox, could you explain me exactly what you mean?
~ via Nexus
Flextrick said:
Sure, adding a second slot will be no problem!
But I don't know what you mean with this checkbox, could you explain me exactly what you mean?
~ via Nexus
Click to expand...
Click to collapse
When I decompile using baksmali this is the command I run...
Code:
java -jar baksmali.jar -b -o c:/smali c:/smali/classes.dex
The -b command prompts baksmali to remove all .line type code from the smali.
Here is an example .smali file before and after the -b command...
BEFORE: http://pastebin.com/gYKQ90cW
AFTER: http://pastebin.com/17i8k1X2
This method of decompiling smali makes it much much simpler to compare to other code.
Thanks!! :highfive:
Ah, I'm understanding. Yes, I think that's possible as well!
~ via Nexus
Flextrick said:
Ah, I'm understanding. Yes, I think that's possible as well!
~ via Nexus
Click to expand...
Click to collapse
Cool. Cant wait
One more thing, will you be adding the ability to decompile more then one apk/jar?
At once? Would work, I think.
Two possibilities:
The first apk decompiles, and then the second one
Or: Both are decompiling at the same time, but in two different processes.
~ via Nexus
Flextrick said:
At once? Would work, I think.
Two possibilities:
The first apk decompiles, and then the second one
Or: Both are decompiling at the same time, but in two different processes.
~ via Nexus
Click to expand...
Click to collapse
One then the second and so on would save the most memory and prevent crashes on weaker machines
androidapktool.exe does not open on my win 7 32 bin in admin mode.... i have java 7u25 installed.
need java 6?
Flextrick said:
ANDROID APKTOOL
exe crashed on my PC
Win 7 x64, Java 7 w/ update 21 (64-bit) installed.
(AMD FX-8120, 16Gb ram)
Just try with java 6
Click to expand...
Click to collapse
fvadym said:
Flextrick said:
ANDROID APKTOOL
exe crashed on my PC
Win 7 x64, Java 7 w/ update 21 (64-bit) installed.
(AMD FX-8120, 16Gb ram)
Just try with java 6
Click to expand...
Click to collapse
AndroidApktool.exe won't start, neither with 6u45 nor with 7u25 (latest versions)
whats wrong... ?
i have copied framework-res.apk into C:\AndroidApktool from my samsung galaxy s3 i9300, FW XXEMD3 / 4.1.2 jelly bean.
i tried to run it as normal and as an adminstrator... nothing happened at all.
Click to expand...
Click to collapse
yeah not running on windows 8 either
is there something we have to install, too?
Hello, there can be a lot of things.
Maybe you are missing the .NET framework, or some dll´s.
I also uploaded a new .exe just for testing. New is the progressbar.
Download: http://www.mediafire.com/?6y7qi0x8h9q6pt7
Cheers
Flextrick said:
Hello, there can be a lot of things.
Maybe you are missing the .NET framework, or some dll´s.
I also uploaded a new .exe just for testing. New is the progressbar.
Download: http://www.mediafire.com/?6y7qi0x8h9q6pt7
Cheers
Click to expand...
Click to collapse
Test new .exe......
best regards "D"
Could anybody test trying to install .NET Framework?
Hopefully I get a solution for this problem, otherwise I'll make an Installer.
~ via Nexus
@Flextrick
I have NET Framework 4.5, Java 7 Update 25 and Java SE Development Kit 7 Update 25.
Edit:
You've got a Private Message
"D"
Ok. For starting the Tool is no Java necessary.
I think the dll's are missing, hopefully I get it working as far as possible.
~ via Nexus
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
This software will ask for sudo permissions in your machine to download and install all required tools for this program to run correctly, also, it'll execute chmod and chown to this program files and ~/.megarc (if exists) for the correct functioning of all the code, I'm not responsable if this program breaks your Machine (which it shouldn't be able by no ways). When you run for the first time this program, it will proceed to his first run configuration after the user authorization.
Welcome, I've been developing this program a long time ago with my free time after college, this is my first project made in Bash, the main purpose of all this software is to make a lot easier the process of building a Kernel, no matter which device you're building to (excluding MTK and those without source). This program will automatically download all required tools for Kernel building (~1.5GB), including the CrossCompiler (GCC arm/arm64) and other misc tools. You don't need a lot of knowledge to build your kernel with this software and it has all the tools for automatically build everything in just one command!
Requeriments:
A machine with Linux
Git
This program
Once you've downloaded the program to your Machine, you have to cd with Terminal to where you downloaded all the files and execute "core.sh" (bash core.sh or . core.sh) (Like this Example), this is indispensable every time you want to run the program, because it sets the program paths (Otherwise it'll not work)
Now, How it works?
Once you run the program, if it's for the first time then it'll automatically download all required tools and install them, after this it's time to setup your environment. You'll see a folder named "source", you have to put there the folder with the Kernel source contents like this and another folder named "templates" where you can set your AnyKernel (only AnyKernel for now) templates for different devices (Or just use the local one).
That's all, this program only needs you to set the Kernel source, now you've to run again core.sh and it'll prompt to you all the data needed for that session, like the name of the kernel, target android, version, kernel source folder, etc... When you've to select the architecture of your device, arm or arm64 and it'll download the correspondent CrossCompiler (GCC 4.9), after this, it'll promt to you how to set Kernel Installer template, the first option is to extract the local AnyKernel source into "./out/ak_template/" (Thanks to @osm0sis), second option is for select a user template from "./templates/" folder and the third option requires you to set manually the installer template inside "./out/ak_template/" similar or like this (Remember to configure it).
When it promt to you the variant, you've to put preferably the codename of your device (For example: Oneplus One codename is "bacon") and then select a defconfig for that device (For example: For Oneplus One it would be "lineageos_bacon_defconfig"), now that the program knows for which device It's going to compile, (You can add more variants) then, you can enable the KernelDebug option to enable the creation of the Device tree image (Applies for arm devices only) and allow the kernel source cleaning on every compiling process...
Now, let's get into the commands:
Command: "essentials <flag>": Here is where you start once you finish setting all the configs, 'essentials' is the main command of this program, but it only works with flags, otherwise it'll display the flags information that I'm gonna show right now:
Flags:
--kernel (Start the process of compiling your kernel)
--dtb (Generates the device tree image, applies to arm devices only)
--anykernel (Builds a installer for your kernel based on Anykernel by @osm0sis)
--upload (Uploads your Kernel installer to the root of your MEGA storage)
--all (This flag does all processes mentioned above)
You can combine all the flags except for "--all", because this one already does everything, also, no matter in which order, all the functions are going to be done in order to prevent an error (For example: 'essentials --anykernel --kernel' will build the kernel and then build the installer).
Also, after the first run, theres a file named: "defaultsettings.sh", it has a variable inside named "DSENABLED", if you set it to 1, the program instead of prompt you for information when you run "core.sh", it'll take all the config directly from that file, just make sure you've configured it first. :good:
Command: "auto <device> <flag>": This command allows you to make pre-configured files for a specified device, it requires that you have executed the program core.sh for the first time because it stores some config in your ~/.bashrc file, then, you can turn on or restart your machine and this command will still be available for it's use.
When you run 'auto' and next to it you specify the device (for example: auto oneplus), if the device (oneplus) doesn't exist in the device database (./resources/devices/) then, it'll promt to you all the data required for kernel, dtb (if applies), anykernel and upload process.
Once you have configured your device it'll be stored and when you run again the command 'auto' followed by the device name you configured before, (for example: auto oneplus) it'll load that device config file and build everything automatically (Kernel, dtb if applies, anykernel and upload if its enabled).
The Flags for this commands are:
--edit (Opens you the <device> config file for editing with nano)
--remove (Simply removes the <device> config file)
For more information I highly recommend to read the README.md in this program source on Github (It contains a more datailed and complete information).
This program has been tested and used on the following Linux distributions:
Ubuntu
Debian
I will really appreciate any feedback about how it performs on other Linux distributions
You can contact me with a PM (private message) here or in my Telegram group! (I'm @ArtxDev)
Me, @Stayn (Artx)
@osm0sis for his AnyKernel
This project on Github is open to pull requests, I will not hesitate to dedicate you a space here if you contribute for this project :good:
I'll be updating this program fixing bugs and bringing new features :good:
If you like it and want to do a small donation it for sure is gonna help me a lot and keep me motivated! :laugh:
Thank you and enjoy it!
XDA:DevDB Information
Kernel Building - Essentials, Tool/Utility for all devices (see above for details)
Contributors
Stayn
Source Code: https://github.com/KB-E
Version Information
Status: Stable
Current Stable Version: 1.0
Stable Release Date: 2018-07-30
Created 2018-07-09
Last Updated 2018-07-30
In progress...
Mini Guides for absolutely newbies in progress...
Thanks
I just tried it and I get an error:
./core.sh: line 125: .: defaultsettings.sh: file not found
This file exists in Kernelbuilding-essentials directory though.
EDIT:
I tried to change ". defaultsettings.sh" with the full path of this file in line 125 and then I get another error on line 126
err: unary operator expected
dancer_69 said:
I just tried it and I get an error:
./core.sh: line 125: .: defaultsettings.sh: file not found
This file exists in Kernelbuilding-essentials directory though.
EDIT:
I tried to change ". defaultsettings.sh" with the full path of this file in line 125 and then I get another error on line 126
err: unary operator expected
Click to expand...
Click to collapse
Don't use sh to execute core.sh, use ". core.sh" or "bash core.sh"
Stayn said:
Don't use sh to execute core.sh, use ". core.sh" or "bash core.sh"
Click to expand...
Click to collapse
Thanks, I'm using arch linux and zsh as default. With "bash core.sh" the script runs fine.
dancer_69 said:
Thanks, I'm using arch linux and zsh as default. With "bash core.sh" the script runs fine.
Click to expand...
Click to collapse
Thanks for the feedback! If you have any other problem tell me
Cool project! You should specify bash in the shebang (normally the first line of a shell script) to fix issues where bash isn't default:
Code:
#!/bin/bash
osm0sis said:
Cool project! You should specify bash in the shebang (normally the first line of a shell script) to fix issues where bash isn't default:
Code:
#!/bin/bash
Click to expand...
Click to collapse
Done! Thanks
Hey guys, now Kernel Building - Essentials it's stable!
I've been working on fixing a lot of bugs and updating the program structure, now that the structure is totally defined and I don't need to change it anymore, I'll upload the first release at GitHub, version 1.0 and the next versions will be coming with a file to update your old version on KB-E (In this way there's no need to clone the repo again and again and merging your devices or configuration...)
There is all the updates and changes:
- Added a folder for Multiple Installers Templates: I've been thinking that anyone could have various kernel projects for different devices, so this means, that the templates for the installers needs to be different, so, now you can trow all the templates you want inside "templates" folder and the program will prompt to you which one you'll use for the current session (using core.sh "essentials" command) or a pre-configured device (using auto.sh "auto" command)
- Replaced option 2 in the program installer template config method, removed the ability to download the template from your MEGA Cloud and replaced by a selection of user templates inside "./templates/" folder
- Changed the "setuptools.sh" file name to "programtools.sh" because, all program misc functions are going to be stored there and "programtools" makes more sense
- Fixed a bug that happened when you didn't gave to the program the device variant (or codename) and then, "essentials" and "auto" command were not working, now the program forces you to set it (You can set your device name as device variant but it's preferably the device codename)
- Now when the program downloads the correspondent crosscompiler, it shows you the process
- Added the package "device-tree-compiler" into the download list of the function "installtools" (Executed when you run the program for the first time), this package is necessary for some arm64 sources to build device tree
- Fixed a annoying bug that cd's you to your "~/" directory instead of the current directory you were after executing "essentials" or "auto" command
- Now core.sh doesn't change the whole file permissions of your sources (sorry for this)
- Added a boost functionality for "auto" command that sums 2 threads to the compiling jobs when compiling the kernel (Recommended for machines with more than 2 real cores)
- Updated README.md
I would really apreciate some feedback guys, if you have any problems or you need help, feel free to contact me via my Telegram Group, enjoy!
Hi, it looks good so far...I have an MT6580 that I play around with but it's been stuck on kernel 3.10 for a long time. I've spent weeks trying port kernel from other MT6580 devices but haven't gotten any success yet. I got through the core.sh part. Is the essentials commands next ? I don't see it anywhere in the program.
Now I know how you automatically upload kernel to Mega Drive using code.. Unfortunately my G3 was Died...:crying:
Anyone know how to remove unwanted feature from a cooked/compiled kernel?
Excuse me, does this work on Ubuntu that runs on Windows Subsystem for linux?
By the way, thank you for the amazing artx-powered TWRP on my G3.
Like being able to do quick cycles of `fastboot boot out/arch/arm64/boot/Image.lz4-dtb`, but annoyed by the lack of root this way? Well this atrocious idea might be the thing for you!
Git repo: https://git.zx2c4.com/kernel-assisted-superuser/about/
Instructions:
1. cd into your kernel tree.
2. Run this command:
curl -LsS "https://git.zx2c4.com/kernel-assisted-superuser/plain/fetch-and-patch.sh" | bash -
3. Enable CONFIG_ASSISTED_SUPERUSER=y in your config.
4. Gain root by running su.
For so many reasons, this is an awful idea and totally insecure. Don't ship kernels to your users with this enabled! I've tested this on the Pixel 3.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
XDA:DevDB Information
KernelSU - Kernel-Assisted Superuser for Android Root Shell, Kernel for all devices (see above for details)
Contributors
zx2c4
Source Code: https://git.zx2c4.com/kernel-assisted-superuser/about/
Kernel Special Features:
Version Information
Status: Snapshot
Created 2018-11-22
Last Updated 2018-11-23
Good stuff! Keep it up
Great, actually amazing, work on this,. I'm sure Google will be having a meeting of angry "security specialists" sometime soon crying about the future of Android.
Also can't wait for the first idiot to put this in their production kernel.
A really amazing idea that needs to improve it's implementation. Kinda curious to see how this will connect with an userland "Manager" app to allow or deny root permissions to specific apps.
Best of luck
Can't get the patch to apply.
[+] Downloading
Please run this from the top level of your kernel tree.
janjan said:
Can't get the patch to apply.
[+] Downloading
Please run this from the top level of your kernel tree.
Click to expand...
Click to collapse
I'm having the same problem, not really tripping on it tho since it's still a new thing.
Question though, would this theoretically become a solution/work-around having a locked bootloader? Or does the OEM toggle still need to be a thing?
Brilliant. Compiled and used successfully!
Awesome stuff. Can't wait to see more development on it! Keep it up
Enviado do meu SM-N950F através do Tapatalk
interesting:good:
This is really cool. Keep up the great work !
janjan said:
Can't get the patch to apply.
[+] Downloading
Please run this from the top level of your kernel tree.
Click to expand...
Click to collapse
Could you give me a link to the github for your kernel source?
Super cool works, awesome!
Keep up the good work :good:
Sent from my Redmi Note 5 using Tapatalk
freeza said:
Brilliant. Compiled and used successfully!
Click to expand...
Click to collapse
Do u mind to share your secret? How did u apply the patch?
---------- Post added at 12:17 PM ---------- Previous post was at 12:13 PM ----------
zx2c4 said:
Could you give me a link to the github for your kernel source?
Click to expand...
Click to collapse
Here you go. I tired with this kernel source. Theoretically it should work with every kernel source or?
https://android.googlesource.com/kernel/msm.git/+/android-wear-8.0.0_r0.51
Thank you for your time.
Great concept. Thanks for developing it.
It's working like a charm here on an engineering build of APGK, although a lot of apps (e.g. AdGuard and Titanium Backup) don't recognise the availability of root via this mechanism.
This is a really interesting way of getting root access. this combined with an application to direct it would be amazing!, great work !
Cant wait to implement it in my test kernels. reflashing root every build is annoying :laugh:
For arm64 only?? I tried it in 3.4 kernel, arm device and it gives error when compiling with this patch..
janjan said:
Here you go. I tired with this kernel source. Theoretically it should work with every kernel source or?
https://android.googlesource.com/kernel/msm.git/+/android-wear-8.0.0_r0.51
Thank you for your time.
Click to expand...
Click to collapse
Works for me:
Code:
[email protected] /tmp $ git clone --depth=1 -b android-wear-8.0.0_r0.51 https://android.googlesource.com/kernel/msm.git
Cloning into 'msm'...
remote: Counting objects: 54085, done
remote: Finding sources: 100% (54085/54085)
remote: Total 54085 (delta 1547), reused 16213 (delta 1547)
Receiving objects: 100% (54085/54085), 150.50 MiB | 4.91 MiB/s, done.
Resolving deltas: 100% (1547/1547), done.
Note: checking out 'd168a1c746673da2b858fd8be7e09553a9dd87a2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
Checking out files: 100% (51192/51192), done.
[email protected] /tmp $ cd msm
[email protected] /tmp/msm $ curl -LsS "https://git.zx2c4.com/kernel-assisted-superuser/plain/fetch-and-patch.sh" | bash -
[+] Downloading
[+] Patching
[+] Committing
[detached HEAD faebd9fb] android: Add superuser driver
3 files changed, 153 insertions(+)
create mode 100644 drivers/base/superuser.c
[+] Done!
[*] Remember to enable CONFIG_ASSISTED_SUPERUSER=y for this to work. Then simply use `su` for root.
jprimero15 said:
For arm64 only?? I tried it in 3.4 kernel, arm device and it gives error when compiling with this patch..
Click to expand...
Click to collapse
Right now, yes. Feel free to send me a patch if you want it to work on arm. Shouldn't be too hard to do.
zx2c4 said:
Works for me:
Code:
[email protected] /tmp $ git clone --depth=1 -b android-wear-8.0.0_r0.51 https://android.googlesource.com/kernel/msm.git
Cloning into 'msm'...
remote: Counting objects: 54085, done
remote: Finding sources: 100% (54085/54085)
remote: Total 54085 (delta 1547), reused 16213 (delta 1547)
Receiving objects: 100% (54085/54085), 150.50 MiB | 4.91 MiB/s, done.
Resolving deltas: 100% (1547/1547), done.
Note: checking out 'd168a1c746673da2b858fd8be7e09553a9dd87a2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
Checking out files: 100% (51192/51192), done.
[email protected] /tmp $ cd msm
[email protected] /tmp/msm $ curl -LsS "https://git.zx2c4.com/kernel-assisted-superuser/plain/fetch-and-patch.sh" | bash -
[+] Downloading
[+] Patching
[+] Committing
[detached HEAD faebd9fb] android: Add superuser driver
3 files changed, 153 insertions(+)
create mode 100644 drivers/base/superuser.c
[+] Done!
[*] Remember to enable CONFIG_ASSISTED_SUPERUSER=y for this to work. Then simply use `su` for root.
Click to expand...
Click to collapse
Yes. It works now. It works when I use "git clone --depth=1 -b".
It patched successfully and I also compiled without any issue. I will test the kernel later tonight and see if it works for arm. It is very useful for Android Wear/wear os. No need to use supersu and magisk. I will let u know later. Thanks again for your effort to bring this. keep it up.
UPDATE: I just tried to use it with the following kernel source.
https://android.googlesource.com/kernel/msm/+/android-wear-p-preview_r0.5
It applied successfully but it give me error when I try to compile.
Code:
CC fs/debugfs/file.o
../drivers/base/superuser.c: In function 'superuser_init':
../drivers/base/superuser.c:120:39: error: '__NR_newfstatat' undeclared (first use in this function)
read_syscall((void **)&old_ ## name, __NR_ ## name); \
^
../drivers/base/superuser.c:133:2: note: in expansion of macro 'read_and_replace_syscall'
read_and_replace_syscall(newfstatat);
^
../drivers/base/superuser.c:120:39: note: each undeclared identifier is reported only once for each function it appears in
read_syscall((void **)&old_ ## name, __NR_ ## name); \
^
../drivers/base/superuser.c:133:2: note: in expansion of macro 'read_and_replace_syscall'
read_and_replace_syscall(newfstatat);
^
../scripts/Makefile.build:257: recipe for target 'drivers/base/superuser.o' failed
make[3]: *** [drivers/base/superuser.o] Error 1
../scripts/Makefile.build:402: recipe for target 'drivers/base' failed
make[2]: *** [drivers/base] Error 2
make[2]: *** Waiting for unfinished jobs....
CC fs/devpts/inode.o
It is kinda strange. It applied and let me compiled successfully with source "android-wear-8.0.0_r0.51" but failed to compile with "android-wear-p-preview_r0.5". It gives me the above error.
Good job!
Kind of works as intended for me... Though, when I run 'su' in terminal I get:
"You are now root.
Killed".
However. I do have 'su' access in terminal without running it, so I guess it's kind of working as it should?
Only Root explorer has managed, so far, to work using your kernel su.
Titanium Backup complains about su not being found (It does look in /system/bin/su, so it should work I guess).
Edit: This is on a Mate 10 Pro using Pie.
I cant seem to find an example of a simple "Hello World" terminal / shell application, in Java. All the simple examples on the web I find are for a simple "Hello World" GUI app. I wish to write some small utility apps to extend the shell with stuff I can easily do in Java, but not directly in the shell with ASH (ie android BASH).
Because it should be very tiny, I would like to write multiple tiny single use ones using a text editor, once I have a template up.
I guess that is a programming tool question? C++ or C? No clue what you're asking, but I am sure you're not asking about a simple Terminal emulator because it's you
alecxs said:
I guess that is a programming tool question? C++ or C? No clue what you're asking, but I am sure you're not asking about a simple Terminal emulator because it's you
Click to expand...
Click to collapse
Its written in Java. It could of been written in C++, but thats not what I want. And its not writing the terminal itself, but a java app with no GUI, but access to the android API.
Most examples I have seen are just too complex. For example. sqlite2 shell binary is one, but it does so much. If you look in /system/bin there are many of them, but I would guess a lot are written in C++. I have thought about checking the ROM source to see how these are coded, but I really suspect many are C++ and with the size of code for a ROM, it would take time, and many are more complex than an "hello world".
I had an idea for some more search terms, and came across the following; and similar. But none show how to compile it down to a standalone executable. All the examples I found require you to run it interpreted.
Hello World
introcs.cs.princeton.edu
Maybe now is a trim e too try and integrate what I see in SQLite3 make file and the above link
EDITY: Arggghhh SQLite3 source would be C/C++ not java
I don't know if you can compile standalone executable. have a look into cat /system/bin/sm
alecxs said:
I don't know if you can compile standalone executable. have a look into cat /system/bin/sm
Click to expand...
Click to collapse
I think I have may of found something.... its getting late and it can wait.
Command line Java on DalvikVM
Command line Java on DalvikVM. GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
AND
Android: Compiling and running a Java command-line utility
Im getting close, but have to move onto other things.
Had to download SDK etc and modified the build scripts to newer methods/modules. I have the dex, next to compile that to static executable
just looks like downloading a dependency. Or maybe a path as that error looks familiar
Code:
[email protected]:~/android/helloworld$ dalvik.sh HelloWorld.java
** Compiling java file...
** Creating temporary jar...
added manifest
adding: HelloWorld.java(in = 170) (out= 141)(deflated 17%)
adding: diamondjohn/(in = 0) (out= 0)(stored 0%)
adding: diamondjohn/android/(in = 0) (out= 0)(stored 0%)
adding: diamondjohn/android/utility/(in = 0) (out= 0)(stored 0%)
adding: diamondjohn/android/utility/HelloWorld.class(in = 590) (out= 356)(deflated 39%)
** Creating DEX file...
** Creating Android compatible file...
<-=ERROR=->
aapt: error while loading shared libraries: /lib/x86_64-linux-gnu/libc++.so: file too short
one step closer!
I can now
write a simple java class with a single method using a text editor
Code:
package diamondjohn.android.utility;
public class HelloWorld {
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
compile it to a dex on Ubuntu (a couple of steps I need to clean up)
zip the dex (actually did this step on windows using the GUI )
Copied the files to and run the class using the following in an android shell over ADB WiFi.
dalvikvm -cp /data/local/tmp/HelloWorld.zip diamondjohn.android.utility.HelloWorld
and the output is as expected
Hello World!
two things before I am actually there
1. Its still not a standalone executable, but, if need be, I can write a shell script wrapper to handle the execution using the dalvikvm. What it does show is that I can write shell executable code using Java (Instead of C/C++). And, it looks like it *should* only be a small step to make it executable in itself. At absolute worst, I could write a simple C++ executable to wrap my java executable that calls dalvikvm, if I didnt want to use the shell at all.
2. The next thing to try is to actually use an include of an android specific API and get that to compile on ubuntu and run.
for example
Code:
import android.util.Log;
public static void logInfo(String logText) {
Log.i(TAG, logText );
return;
}
In ye olde days all the Android commands like am, pm, etc used a shell script that called /system/bin/app_process.
Now those use the /system/bin/cmd executable.
Usually I go the other direction. I avoid running things in Java.
You can just have a regular ELF executable.
If you need to interact with Android (Java) you can directly use Binder. (I have.)
Renate said:
In ye olde days all the Android commands like am, pm, etc used a shell script that called /system/bin/app_process.
Now those use the /system/bin/cmd executable.
Usually I go the other direction. I avoid running things in Java.
You can just have a regular ELF executable.
If you need to interact with Android (Java) you can directly use Binder. (I have.)
Click to expand...
Click to collapse
Do you have an example of creating Java code run via this technique? I searched the web and all I found looked very similar to in practicality to what I have done above, but maybe cached.
How to run Java programs directly on Android (without creating an APK)
A step by step instruction for compiling a Java program into an Android executable and using ADB to run it.
raccoon.onyxbits.de
I note that example uses "dx" to DEX the file, but its now "d8". The example also includes includes that I dont think are part of Android AOSP
DiamondJohn said:
Do you have an example of creating Java code run via this technique?
Click to expand...
Click to collapse
No, but it's basically all the same. You need an ELF (like dalvikvm or app_process) to load a jar/apk and a method for it to start with.
I didn't know about dalvikvm.
The way that app_process works is that the ELF uses libbinder.so to ask zygote[32][64] to fork itself, load some classes and start somewhere.
Try this:
Code:
time dalvikvm -cp /data/local/tmp/HelloWorld.zip diamondjohn.android.utility.HelloWorld
You'll see that this is comparatively slow (certainly over a plain C program).
DiamondJohn said:
I note that example uses "dx" to DEX the file, but its now "d8".
Click to expand...
Click to collapse
dx is still around and it might be less trouble.
d8 has wacky new Java features.
DiamondJohn said:
The example also includes includes that I dont think are part of Android AOSP
Click to expand...
Click to collapse
Do you mean include or import? Which ones?
Renate said:
No, but it's basically all the same. You need an ELF (like dalvikvm or app_process) to load a jar/apk and a method for it to start with.
Click to expand...
Click to collapse
No GUI/Activity, so no APK.. As for ELF, from what I read now, it appears to be similar to OAT files, pre-compiled for native execution?
I havent looked into it, but maybe an extra step to call dex2oat and then run that (ie the OAT), may work. I will look into it later, as Its a pretty easy process to get to the DEX. Now that I know an example of the method.
The thing to remember, I want to be able to call these methods from the shell, not from another Java app.
Renate said:
I didn't know about dalvikvm.
Click to expand...
Click to collapse
Yeah, you an me both!
Renate said:
Try this:
Code:
time dalvikvm -cp /data/local/tmp/HelloWorld.zip diamondjohn.android.utility.HelloWorld
You'll see that this is comparatively slow (certainly over a plain C program).
Click to expand...
Click to collapse
Speed is not of concern at this stage. Functionality is first. I do not expect to be calling these in hard loops. And if I did, I would put the hard loop in the compiled Java code.
Renate said:
dx is still around and it might be less trouble.
d8 has wacky new Java features.
Click to expand...
Click to collapse
My original findings were using dx but when I downloaded the latest A13 SDK, there was no dx but there was a d8 so i guessed and it worked. I am not expecting to write huge programs, most of the functionality will be in the shell, with calls out to these tiny utilities for what cant be done in the shell i.e in exceptional cases. For example, in prior android versions, one could media scan a specific single file. Now, you can make the same call in the shell, no error is returned, but no file is scanned. i.e. it is ignored and you are not informed that it was ignored. I havent checked the logcat.
Renate said:
Do you mean include or import? Which ones?
Click to expand...
Click to collapse
My bad, I mean import
Code:
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
These names do not look like AOSP available imports.
DiamondJohn said:
These names do not look like AOSP available imports.
Click to expand...
Click to collapse
They look like some Apache libraries for their idea of what you need to interact with command lines.
There's no reason that you have to use them.
If you did you'd have to get (or make) a jar (with classes, not dexes) to compile against.
You haven't given us any hint of what you are trying to do with this all.
You might be better off with a standard app with a service that can be commanded by a pipe or socket from the command line.
Code:
$ time input keyevent 4
0m00.82s real 0m00.21s user 0m00.16s system
$ time ./lgtest unix.txt 55>/dev/null
0m00.04s real 0m00.02s user 0m00.01s system
This is just a comparison between the system input and a random non-Java utility of mine.
And this is what is inside the input shell script.
Code:
#!/system/bin/sh
export CLASSPATH=/system/framework/input.jar
exec app_process /system/bin com.android.commands.input.Input "[email protected]"
So you see that it has to spin up a VM just to do trivial things.
As I said, I very much tend the other direction, avoiding Java for utilities (of course I use it for apps).
The advantage is not only faster operation but that it can work when the Android subsystem is stopped or in recovery.
In any case, our interests are diverging here.
It's possible to run it in recovery though.
https://forum.xda-developers.com/t/2934449/page-22
Renate said:
They look like some Apache libraries for their idea of what you need to interact with command lines.
There's no reason that you have to use them.
If you did you'd have to get (or make) a jar (with classes, not dexes) to compile against.
You haven't given us any hint of what you are trying to do with this all.
You might be better off with a standard app with a service that can be commanded by a pipe or socket from the command line.
Code:
$ time input keyevent 4
0m00.82s real 0m00.21s user 0m00.16s system
$ time ./lgtest unix.txt 55>/dev/null
0m00.04s real 0m00.02s user 0m00.01s system
This is just a comparison between the system input and a random non-Java utility of mine.
And this is what is inside the input shell script.
Code:
#!/system/bin/sh
export CLASSPATH=/system/framework/input.jar
exec app_process /system/bin com.android.commands.input.Input "[email protected]"
So you see that it has to spin up a VM just to do trivial things.
As I said, I very much tend the other direction, avoiding Java for utilities (of course I use it for apps).
The advantage is not only faster operation but that it can work when the Android subsystem is stopped or in recovery.
In any case, our interests are diverging here.
Click to expand...
Click to collapse
Wait... what...um... WT..
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I think you may of just inadvertently just resolved the majority of my need/wishes!
The whole reason I was looking into all the above was to be able to access the Android base API from the shell. The following code you just posted appears to be doing exactly that, without needing to be compiled. Ironically you chose as your example a JAVA call to a method that is available in the shell
Code:
#!/system/bin/sh
export CLASSPATH=/system/framework/input.jar
exec app_process /system/bin com.android.commands.input.Input "[email protected]"
I havent tested it yet for myself.
Sure, there will be some interfaces that will be practically unusable directly from the shell (due to data types/object refs, activity contexts etc etc etc_) but I think you just gave me an "out"
As for "what" I wanted to do with it, nothing at this exact moment, it was more of something I keep repeatedly hitting but never got around to solving. I had work arounds for some. For example, the app in my sig is basically a GUI menu system as an entry point into shell commands/scripts. However, I have a small number of items I did outside of this concept to meet my personal needs when I could not find shell solutions (apart from the App GUI of course). This original post was a few weeks back now, and the idea was from a few years back, not a specific need right now, just randomly got around to finally asking the question.
On my way out now, but I am interested to be testing this sooner than later.
THANKS!
alecxs said:
It's possible to run it in recovery though.
https://forum.xda-developers.com/t/2934449/page-22
Click to expand...
Click to collapse
I didn't read the whole thread, but basically the concept is the same, except the methods created there would be specific to install apps. For example, there probably isnt a method to scan a media file into the media dB. So it would have 100 different methods I dont need, yet missing the one i do need. And even if it did have the one above, next week there will be something it does not do, that I wish it to do.