Java to Android - Android Software/Hacking General [Developers Only]

I'm looking into getting jar files running. Does anyone know how to do that, or know the release date of J2Android to make conversions?
Thanks

The following got me started with how to pack, sign, and run java code in a .jar from the Android command-line:
davanum.wordpress.com/2007/12/04/command-line-java-on-dalvikvm​
(There is a comment on the page that it didnt work, but I followed the steps and it worked OK for me).

jonnyguitar said:
I'm looking into getting jar files running. Does anyone know how to do that, or know the release date of J2Android to make conversions?
Thanks
Click to expand...
Click to collapse
Just use "dx" command from Android SDK. It converts Java class files to form runnable on Android.
I think you must be more specific about what you wanna do.

Related

Project: apk2

hi folks!
i'm not a developer but sometimes i do some scripting.Now i'm working on a project that called "APK2",and i think that could be useful!
Some months ago, I thought "why don't create a package manager and a package system to install real linux packages, and not just apps? I may want to install some command-line tools to run with terminal emulator" then I wrote this script, named apk2.sh, that installs some particular packages (I wrote another script to easily create this type of packages): he simply does the apt-like un-tar in /, but it installs a config directory too, to remove the installed packages.
It supports the preinst, postinst, prerm, postrm scripts too.
Tell me if it could be interesting, and I'll put it here.
If so, I need testers
If not, simply tell me, and I give up.
so could you be able to run like air crack through debian with this or?
olvap377 said:
so could you be able to run like air crack through debian with this or?
Click to expand...
Click to collapse
I could be able to run it on Android if someone can port all the libs to armv5e
I know, you have to do the porting in order to run it, but for example if there is the package for debian armv5 I think it should work if you take all the deps from the repo (may need some repacking, just to remove the CONTROL folder, and maybe to add the file needed to uninstall and various preinst, postinst etc. ).
And you don't need to run a debian or an ubuntu on Android, that's not really fast.
What do you think?
i think that this sounds really good and if it worked fully it would be a major addition to android development im hoping youll continue with this
olvap377 said:
i think that this sounds really good and if it worked fully it would be a major addition to android development im hoping youll continue with this
Click to expand...
Click to collapse
Thank you!
Any tester? I attach the scripts to now how apk2 works, just run it without any parameter, and it will show you
The other script it's simple to use, you just have to run it once to create in your home the basilar directory tree, you have to complete it and put the files in it, then you just have to put your preinst-postinst-prerm-postrm scripts in the ~/yourpackage/system/etc/apk2 directory, if you have some.
Then run the script again, insert the same package name, and here we are! The package is build! It's in the packagename directory in your home, in .apk2 and in .tar.gz, if you have to edit something do it on the tar.gz, and then change the extension in .apk2
PS: rename the files *.sh.txt into *.sh, because this forum doesn't allow .sh attachments...
xela92 said:
Thank you!
Any tester? I attach the scripts to now how apk2 works, just run it without any parameter, and it will show you
The other script it's simple to use, you just have to run it once to create in your home the basilar directory tree, you have to complete it and put the files in it, then you just have to put your preinst-postinst-prerm-postrm scripts in the ~/yourpackage/system/etc/apk2 directory, if you have some.
Then run the script again, insert the same package name, and here we are! The package is build! It's in the packagename directory in your home, in .apk2 and in .tar.gz, if you have to edit something do it on the tar.gz, and then change the extension in .apk2
PS: rename the files *.sh.txt into *.sh, because this forum doesn't allow .sh attachments...
Click to expand...
Click to collapse
in non-linux speak (layman's terms), what could i do with this...my interest is peaked
what are some "real linux packages" that one might want
tnpapadakos said:
in non-linux speak (layman's terms), what could i do with this...my interest is peaked
what are some "real linux packages" that one might want
Click to expand...
Click to collapse
i.e., the one olvap377 mentioned: air crack (I think it's possible).
or, we can run every app that does not need X server.
I created some demo packages (containing 2 scripts), one is SwapTools, and lets you enable/disable swap with 2 simple cmds (swap-enable and swap-disable); at the first run it collects some info, like the swappiness and the swap partition, then it saves the conf in a file (using swap-disable with --remove-conf will remove the conf file).
Another one I created is remount: you can remount your /system partition rw or ro just by typing on a terminal emulator
Code:
remount rw
or
Code:
remount ro
But you can try to use other appz compiled for armv5 processors, like all the debian apps, except for the one with GUI (we run on framebuffer, no X server :/ )
PS: I attach the pkgs, I added the .zip extension, just rename it in pkgname.apk2
Honest question: Why reinvent the wheel? Other embedded Linux projects have used ipkg to good effect, or its close relative opkg (refs from same link) which is used by Openmoko. A port of this to Android systems which have uClibc should be nearly trivial.
xela92 said:
i.e., the one olvap377 mentioned: air crack (I think it's possible).
or, we can run every app that does not need X server.
I created some demo packages (containing 2 scripts), one is SwapTools, and lets you enable/disable swap with 2 simple cmds (swap-enable and swap-disable); at the first run it collects some info, like the swappiness and the swap partition, then it saves the conf in a file (using swap-disable with --remove-conf will remove the conf file).
Another one I created is remount: you can remount your /system partition rw or ro just by typing on a terminal emulator
Code:
remount rw
or
Code:
remount ro
But you can try to use other appz compiled for armv5 processors, like all the debian apps, except for the one with GUI (we run on framebuffer, no X server :/ )
PS: I attach the pkgs, I added the .zip extension, just rename it in pkgname.apk2
Click to expand...
Click to collapse
thanks dude
olearyp said:
Honest question: Why reinvent the wheel? Other embedded Linux projects have used ipkg to good effect, or its close relative opkg (refs from same link) which is used by Openmoko. A port of this to Android systems which have uClibc should be nearly trivial.
Click to expand...
Click to collapse
I have also an Openmoko phone
I know very well ipkg/opkg, it could be interesting a porting, but I thought it was better to create a little lighter script to do it, because 1. a script that uses sh is usable in every system, you can either to install armv5e pkgs, or any armv* pkg, you have just to change some little things; 2. I don't know how to port, and I'm not able to do programming.
If you are interested and know how to do a porting, it could be very useful, because opkg has really lots of functions...
I just did what I could
xela92 said:
I have also an Openmoko phone
I know very well ipkg/opkg, it could be interesting a porting, but I thought it was better to create a little lighter script to do it, because 1. a script that uses sh is usable in every system, you can either to install armv5e pkgs, or any armv* pkg, you have just to change some little things; 2. I don't know how to port, and I'm not able to do programming.
If you are interested and know how to do a porting, it could be very useful, because opkg has really lots of functions...
I just did what I could
Click to expand...
Click to collapse
Ahh, okay, I see what you mean. Fair enough; I haven't seen your work so far, I was just concerned you were doing unneeded work. 'Course sometimes it's good to do that for the learning experience.
I don't have a full build setup for Android, so I can't recompile (I do have a full build setup for building Optware packages, but that's not quite the same), but I believe most custom ROMs ship uClibc. I'm not familiar enough with uClibc to know if you need to build against an exact version, though you could copy opkg from your Openmoko phone for the heck of it and see if it runs
olearyp said:
Ahh, okay, I see what you mean. Fair enough; I haven't seen your work so far, I was just concerned you were doing unneeded work. 'Course sometimes it's good to do that for the learning experience.
I don't have a full build setup for Android, so I can't recompile (I do have a full build setup for building Optware packages, but that's not quite the same), but I believe most custom ROMs ship uClibc. I'm not familiar enough with uClibc to know if you need to build against an exact version, though you could copy opkg from your Openmoko phone for the heck of it and see if it runs
Click to expand...
Click to collapse
Ya mean, copy the binary??? If so, it won't work of course, because the architecture of the openmoko processor is armv4t, it wouldn't see my binary
Nethertheless, if someone is interested
PS: please, could someone test my scripts? Thank you dudes
xela92 said:
Ya mean, copy the binary??? If so, it won't work of course, because the architecture of the openmoko processor is armv4t, it wouldn't see my binary
Nethertheless, if someone is interested
PS: please, could someone test my scripts? Thank you dudes
Click to expand...
Click to collapse
Heh, oh, older ARM core. Not paying attention. I will now stop hijacking your thread
olearyp said:
Heh, oh, older ARM core. Not paying attention. I will now stop hijacking your thread
Click to expand...
Click to collapse
No problem, man
No testers?
Please give me a feedback. If u want, I can make some apk2 by debs for armv5... Then I accept hints like "howto manage dependencies", 'cause I've no ideas...
"Tester"
xela92 said:
Please give me a feedback. If u want, I can make some apk2 by debs for armv5... Then I accept hints like "howto manage dependencies", 'cause I've no ideas...
Click to expand...
Click to collapse
Hi I have and HTC Hero from Sprint, I'm not a linux power user but I spent lots of time in my computer running Ubuntu just for 2 big reasons 1 freeware and 2 it has the best an simplest packet manager... I love deb files that installs like any .exe win programs I love that! I'm son not a coder and have little to no skills under Linux shell I use my sudo nautilus commands and so because I need it but I hate to untar or tar gz crap... for me that it old and useless some linux power user may get offended by that comment but hi times changes we love GUI... if you manage to post prints screens or a word open office or PDF documentation dummy proof I'm very up to be a Happy tester... the other thing I'm a Digital Graphic Designer if you need some design for a GUI and can try to help you in making and eye candy app...
Here it the way I will love to see grow this project... finding a way to installed it as an apk file like others in the android market so users can install the app easy then...in top of that a simple GUI to browse to the SD card in order to get the apk2 file... you where talking about not being able to run programs that has GUI that it is sad but still interesting but a lot of work to do without a good community because that means that all GUI may need to be re-design to the different resolution on the phones and be touch friendly...
I'm not sure if I'm helping at all but I love the big picture behind your project...
I'm porting opkg on Android, but i'm can't tell that's a trivial task )))
i also wrote simple howto "building and porting linux apps for android from scratch", but on russian. If needed i can do some translating and put here too.
Also may be we can open project for buildroot-like framework for android and opkg's repository. In my how-to i'm use crosstool-ng + gcc + uClibc.
XVilka said:
I'm porting opkg on Android, but i'm can't tell that's a trivial task )))
i also wrote simple howto "building and porting linux apps for android from scratch", but on russian. If needed i can do some translating and put here too.
Also may be we can open project for buildroot-like framework for android and opkg's repository. In my how-to i'm use crosstool-ng + gcc + uClibc.
Click to expand...
Click to collapse
Wow! Please do some translating!
But, when you finish the porting, how will you manage to port the packages?
Will you use the debian pkgs changing the extension? Would it work?
Thanks a lot!
No, we want to create only android repository of packages, based on opkg (ipkg)
for arm, mips and others platfofms.

[Q] Any way to compile java programs in android ?

Is there a way to compile .java file to .class file and execute it
I wanted to compile c/c++/java programs, not for my phone but in my phone...
I searched but did not find an easy way for it.
At last I found out a real easy way to compile c/c++ by using adosbox for android.
I copied the turbo c 'tc' folder from my pc to my sdcard and used adosbox like command promt to go to 'bin' folder in tc and start tc.exe...
Then I could easily write and compile programs just like i did on the pc
But still no luck for java programs...
I copied the reqired java folder and then used adosbox to run the command "javac file.java" but it said "This Program Cannot Be Run in DOS Mode"
So if there is any other way to compile java programs in my phone
please help
Thanx in advance
Try looking at Eclipse, although Eclipse is a large desktop IDE, it includes its own Java compiler written in Java (in the part called "JDT core"), and if (as I hope) that Java compiler is not copyrighted by Sun/Oracle, you (or someone else already maybe) may be able to compile that part of Eclipse into a "native" Dalvik/Android App.
Googling the issue, I see that others have been asking for an Android port of Eclipse too, so maybe there will be some momentum going for this soon.

Editing APK files

Hi i have read a few posts about editing apk files but most are only about editing the image files. i need to edit the classes.dex file inside the apk i have done this but when i try and install the apk it doesnt work is this possible to do? thanks
this is not to do anything illegal it is simply to make an android app i use equal to the iphone equivalent (there are less servers for the android app) so i basically want to change the url from the apk to the iphone url)
Cheers
morgs640 said:
Hi i have read a few posts about editing apk files but most are only about editing the image files. i need to edit the classes.dex file inside the apk i have done this but when i try and install the apk it doesnt work is this possible to do? thanks
this is not to do anything illegal it is simply to make an android app i use equal to the iphone equivalent (there are less servers for the android app) so i basically want to change the url from the apk to the iphone url)
Cheers
Click to expand...
Click to collapse
Tried signing the file after modding it?
Sent from my GT-S5360 using xda premium
Hi thanks for your reply, yes i have and it still doesnt work unfortunately
Use apktool to extract the APK, you'll get .smali files instead of classes.dex (this is the decompiled version). Edit these files appropriately, then repack the APK with apktool and sign it. Should work.
Does apktool require command line? if so it is too complicated for me
Yes, it does. If command line is too difficult, it's probably unlikely you'll be able to get this working I'm afraid. You could try this: http://forum.xda-developers.com/showthread.php?t=1619473
It's an IDE for editing APKs, might help. But honestly, the command line part is the easy bit
Just never had any luck with any command line stuff for android never works for me and i hate all the extra crap you have to install to use it. Thanks anyway ill see how i go.
morgs640 said:
Just never had any luck with any command line stuff for android never works for me and i hate all the extra crap you have to install to use it. Thanks anyway ill see how i go.
Click to expand...
Click to collapse
If you wanna do basic stuff wid apktool then its a reaaly easy tool.. The commands are really very small!
Apktool d xxxx.apk for decompile
Apktool b xxxx for compiling n ur done!
Even the complex ones arent difficult! Only the installing of apktool takes time and its the hardest thing in the whole procedure
Sent from my GT-S5360 using XDA
in theory apktool is faily simple. but if you compile for android 4.0 better prepare yourself for huge headaches and a couple of white hairs as this thing wont work. i know two solutions, one consists of a really stupid juggling with two versions, one old which you can barely find, and one new, decompile with the old one, compile with the new one. some guy made a mod though and it finally ends the trouble, but i haven't seen it officially pronounced, which made it so damn hard to find it, hidden in some internet forums. another problem was that aapt needs to be present in the same directory, error codes will just spew out a bunch of gibbersish and you will never know whats wrong so all thats left is trying. but once you got it working it is as easy as pie.
molesarecoming said:
some guy made a mod though and it finally ends the trouble, but i haven't seen it officially pronounced, which made it so damn hard to find it, hidden in some internet forums. but once you got it working it is as easy as pie.
Click to expand...
Click to collapse
You mean this: http://forum.xda-developers.com/showthread.php?t=1551236 ? (It was about two threads below this one at the time I posted this )
nice! i made myself little batch files for this. i just go "apkd skype" to decompile skype.apk and apkb skype for building it, zipping it, signing it. didnt even know theres a guy out there now.
SifJar said:
Yes, it does. If command line is too difficult, it's probably unlikely you'll be able to get this working I'm afraid. You could try this: http://forum.xda-developers.com/showthread.php?t=1619473
It's an IDE for editing APKs, might help. But honestly, the command line part is the easy bit
Click to expand...
Click to collapse
This program worked perfectly thank you so much

Possibly Close To Solving Java on Windows RT?

Alright I've searched for a while to find a way to get my Surface 2 to run .java files as I have Notepad++ on here. I've seen that there is a Java version for ARM architecture but it's for the Raspberry Pi.
What I've done so far, and I'm hoping that someone else will be able to take it further as it will be a very valuable tool, is;
-Download the Java file 'Linux ARM 32 Hard Float ABI' from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
-Extracted the .tar.gz file using 7Zip, then extracted the .tar file the same way.
-Moved the jdk folder into C:\Program Files\Java (where it would go if being installed on a normal Windows computer)
-I then used an elevated Command Prompt to open Environment Variables and added JAVA_HOME to the system variables with the value 'C:\Program Files\Java\jdk1.8.0_73'. I also edited the Path variable to include 'C:\Program Files\Java\jdk1.8.0_73\bin'
Now as far as I know surely that's half the job done? But if I try and do anything in cmd that starts with 'java' it says it's not recognised.
Have I done the Paths wrong? Another thing I noticed is that on a Windows 10 PC there are also Java files in 'C:\ProgramData\Oracle\Java\javapath' but this is the only difference between Java on my laptop and Surface.
The problem is these files are compiled for x86 or x64 architectures and won't do anything on my Surface.
Considering the files in ProgramData are now the only Java differences between my laptop and my surface and I've been told it's possible to install Java without using the installer and just copying files across a system, would it be possible for anyone to find a way to have those files on an ARM system or a way to run it without those?
Bear in mind this is the first time I've properly tried to do anything like this so if it's a bad idea please let me know nicely lol. I just haven't seen anyone go down this route, maybe there's a reason but it intrigued me so I thought I'd ask.
Thank you
You can't run Linux binaries on Windows. So downloading the Linux version of JAVA will not work.
EDIT: It's an interesting concept. It should be theoretically possible to compile OpenJDK to work on RT.
abtekk said:
You can't run Linux binaries on Windows. So downloading the Linux version of JAVA will not work.
EDIT: It's an interesting concept. It should be theoretically possible to compile OpenJDK to work on RT.
Click to expand...
Click to collapse
Oh I see, yeah I wasn't sure how far it could go but I thought I'd put it out there. I have absolutely no idea how to go about compiling that so I'm hoping someone sees this and does everyone a favour as this would be an extremely useful tool to have!

Need help modifying an APK

Hello! Sorry if this is the wrong place to post this I just registered to the forum!
To keep it short I am a frequent player of the game 'Idle Heroes' and I got the idea to take the APK, modify it (for private use of course) and give me resources in the game so I can try out different heroes etc etc.
So I read up on the APKtool and all that but I am having some trouble, I can't find the framework I need.. I am just getting errors when trying to decompile and I can't find any framwork in my phone or online to download..
Any help is appreciated! Thanks!
If it's any help I have a Galaxy S9 (not rooted)
For apk tool you need to write it in the following format in command prompt... (assuming you are using apk tool 2.2.4)
Java –jar apktool_2.2.4.jar d C:\<path to apk file>
But this would give you stuff like the android manifest. If you want the raw source code itself, you would need to use something such as dex2jar. Format is below.
d2j-dex2jar.bat C:\<path to apk file>
mohhaxs said:
For apk tool you need to write it in the following format in command prompt... (assuming you are using apk tool 2.2.4)
Java –jar apktool_2.2.4.jar d C:\<path to apk file>
But this would give you stuff like the android manifest. If you want the raw source code itself, you would need to use something such as dex2jar. Format is below.
d2j-dex2jar.bat C:\<path to apk file>
Click to expand...
Click to collapse
Thanks for your reply! Unfortunately I'm still struggling.. As you said it's the source code I am after. If you haven't played the game I'll try to explain what I am after.
Every day you get daily missions you can do, I'd like to simply change the rewards from let's say 1 summoning scroll to 1000 so that each day I can get 1000 scrolls, and I also want to change the other rewards to give me a couple of thousand gems instead of the 20 I get each day, that will give me enough to get the heroes I am after!
Would you care to help me a little more specifically on how to achieve this? Right now I have put the .apk in "C:\android\apktool" along with the apktool itself (apktool.jar).
But I don't have a .bat file, what kind of .bat file do I want to create? Also I don't have any other folders or such. And yes I have the newest version of Apktool!
No matter what I write in CMD it gives me an error, I don't have any framework files etc and I don't know where to get them.. I did also use the code you gave me (java -jar etc etc) but it also gave me errors .. If you'd like me to try something else and/or post the errors here I'd gladly do so!
Sorry for being such a noob but I have never done anything like this before, I recently started learning C++ but it's mainly simple games (for PC) in UE4 and stuff like that, but nothing for mobile.
Thanks a lot for your time!

Categories

Resources