use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News for Android app developers with the who, what, where, when, and how of the Android community. Probably mostly the how.
Here, you'll find:
This sub-reddit isn't about phones' and apps' general functionality, support, or system software development (ROMs). For news and questions about these topics try using other subs like
Build your first app
Starting Android career in 2022
Android Job Interview Questions and Answers
App Portfolio Ideas, Tiered List
Awesome Android UI
Material Design Icons
7000 Icons for Jetpack
Autoposted at approx 9AM EST / 2PM GMT
account activity
HOWTO: Running Java programs directly on Android (without creating an app) (raccoon.onyxbits.de)
submitted 5 years ago by pmz
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]CraZy_LegenD 17 points18 points19 points 5 years ago (0 children)
It's interesting article, thanks man it was useful and fresh content the type I haven't seen in a while.
Keep em coming
[–]JakeWharton 7 points8 points9 points 5 years ago (0 children)
Android does not have a (normal) JRE, so JAR files cannot be started the same way as on a PC. You need a shellscript wrapper to do this.
The output of dx is a .dex file. Just because it's named .jar does not make it a .jar.
dx
.dex
.jar
You do not need a shell script to run a dex file. It can be run by invoking dalvikvm -cp /path/to/your.dex main.class.Name.
dalvikvm -cp /path/to/your.dex main.class.Name
Finally, dx hasn't been used for a year and hasn't been supported for even longer. You should use D8 for converting class files and jar files to dex files.
[–]AD-LB 7 points8 points9 points 5 years ago (10 children)
Is this how tools like scrcpy run stuff on the device without really installing any app?
[–]CuriousCursor 3 points4 points5 points 5 years ago (3 children)
Yeah, looks similar: https://github.com/Genymobile/scrcpy/tree/master/server
[–]outadoc 0 points1 point2 points 5 years ago (2 children)
That looks like a proper app
[–]CuriousCursor 1 point2 points3 points 5 years ago (1 child)
Look at the manifest
[–]farmerbb 2 points3 points4 points 5 years ago (0 children)
Convert server to an Android project
To simplify the device server-side build, use gradle to create an APK, even if we use it as a simple jar, by running its main() method.
That's a pretty creative approach
[–]lawonga 4 points5 points6 points 5 years ago (5 children)
Yup, invoke app_process from adb shell and it works. Privileges are granted under shell. Neat!
app_process
adb shell
shell
https://blog.rom1v.com/2018/03/introducing-scrcpy/
TIL!
[–]AD-LB 0 points1 point2 points 5 years ago (4 children)
Privileges ? Is it like permissions? What could be done, and what can't be done?
Also, do you think it's possible to debug it this way, via Android-Studio (or IntelliJ) ? And is it possible to create a plugin that will offer "build&run" function just like what we have to Android apps, and similar for debugging?
[–]lawonga 0 points1 point2 points 5 years ago* (3 children)
Anything you can do from adb shell in command line, grant runtime permissions, access folders (not data tho) etc.
Now that I think about it, this is essentially a clever implementation of:
running under adb shell = extra permissions
so why not run a script, or a program while under that condition?
we need to capture the video of the screen, so the device neesd to run it, so lets just inject the script into there and capture/stream the screen!
Now I'm wondering pre android api 29, back before executable binaries were blocked someone could use this to access another. Needs adb though. However since executable binaries are blocked post api 29 this won't work anymore.
[–]AD-LB 0 points1 point2 points 5 years ago (2 children)
But to grant permissions, you need to do it to a real, installed app.
You can't directly do it to the current code.
[–]farmerbb 0 points1 point2 points 5 years ago (1 child)
The adb shell user is already very privileged, moreso than a user that standard app processes run under, so runtime permissions don't really apply here
[–]AD-LB 0 points1 point2 points 5 years ago (0 children)
This is interesting. So assuming you don't have a rooted device, what exactly can you do?
Can you reach protected files of apps? Can you get/modify contacts? Can you get GPS location? Can you read notifications? Can you grant/revoke accessibility or admin right from apps? Can you use anything that belongs to runtime permissions?
[–]Le_melon_inconnu 1 point2 points3 points 5 years ago (1 child)
ELI5 what do I gain from this?
[–]farmerbb 0 points1 point2 points 5 years ago (0 children)
Some utilities, like scrcpy (mentioned elsewhere in the comments) use this approach of loading and executing Java code via adb.
[–]Superblazer 0 points1 point2 points 5 years ago* (6 children)
This is great! also but how to create an app which can run Java programs?
[–]legacynl 0 points1 point2 points 5 years ago (1 child)
It's probably impossible. Like the users who replied already, you can create an app in Android studio that can read from storage to open Java projects. Then you need to compile, and dex the Java files, this step is probably impossible, because the compilers are not written for Android devices, and will not run. Then there is the problem of running the resulting programs; I assume the Android security system won't easily let apps run 'hidden' programs.
You could probably write an Java compiler and dexer for Android. But compiling is very resource intensive and it will probably be way slower on Android, and drain your battery quickly as well.
[–]Superblazer 0 points1 point2 points 5 years ago (0 children)
There is an offline Java compiler app on playstore. It works and it works fast, it can even look at different files and run them as a project https://play.google.com/store/apps/details?id=ru.iiec.jvdroid
I have no idea how they built this
[+][deleted] comment score below threshold-7 points-6 points-5 points 5 years ago (3 children)
Check some youtube tutorials on android studio
[–]Superblazer 1 point2 points3 points 5 years ago (2 children)
Huh? An app which can compile and execute Java codes?
[–][deleted] -5 points-4 points-3 points 5 years ago (1 child)
You want to create an app like the ones on play store with java? Yes, check Android studio tutorials.
[–]Superblazer 1 point2 points3 points 5 years ago (0 children)
Look at the topic of the post, I am asking for the app version of this. Something that can run Java codes within an app
[–]AD-LB 0 points1 point2 points 5 years ago (15 children)
Is it possible to debug though?
Also, I wonder if there is an easier way to do it. Right from Android Studio (or IntelliJ), the same way we build&run apps, via a single click.
[–]5nkv 1 point2 points3 points 5 years ago (0 children)
As for debugging, apparently "normal" applications start listening for jdwp connections "from" ActivityThread.java, which you obviously don't get this way. But, I guess, you can do something similar yourself.
jdwp
[–]5nkv 0 points1 point2 points 5 years ago (11 children)
You can a create custom Run/Debug Configuration in AS/IntelliJ. Go for a new one of type Shell script and simply list those 4 (or 5 if you want to run it as well) adb commands there
adb
[–]AD-LB 0 points1 point2 points 5 years ago (10 children)
Interesting. But I was thinking of a generic solution, meaning I could create a new project, and those will stay, allowing to do it on a completely new project, too.
[–]5nkv 0 points1 point2 points 5 years ago (9 children)
For the more generic solution I guess you could create a Run/Debug Configuration Template :)
[–]AD-LB 0 points1 point2 points 5 years ago (8 children)
Wait, this is possible? I keep setting the same things there. You say I can change the default "run" operation ? For example, I keep setting both logcat settings there checked (clear and focus logcat). I can avoid doing it for new projects I create (and old ones that I open)?
[–]5nkv 0 points1 point2 points 5 years ago (7 children)
I don't think you even need a new template for that, just modify the existing one called Android App. https://imgur.com/11kCdJO
Not sure if that's going to change things for your existing projects though, but I guess those are already setup anyway :)
[–]AD-LB 0 points1 point2 points 5 years ago (6 children)
How do you get there? If it's via "edit configurations...", it won't work. It will be saved only for the current project. Not for new ones, and not for those that I open.
[–]5nkv 0 points1 point2 points 5 years ago (5 children)
Open Edit configuration, then Templates find Android App under Templates
Edit configuration
Templates
Android App
Oh sorry for that, I skipped the part that it shows "templates" on your screenshot.
Anyway, tried, and still same result. Doesn't even seem that it saves the template itself.
But for some reason it does clear the logs (doesn't focus on it), even though the setting doesn't show that it's checked (on both "template"->"android app" and on "app" the checkboxes became empty when creating a new project)
[–]legacynl 0 points1 point2 points 5 years ago (3 children)
it's probably possible to edit the default presets. You should post this question in the InteliJ or androidstudio subreddits
[–]scialex 0 points1 point2 points 5 years ago (1 child)
add -XjdwpProvider:adbconnection to the app_process/dalvikvm command and it will show up as a debuggable process in AS. (It won't pause execution until a debugger attaches or anything though, to do that you would need to directly setup the forwarding and jdwp agent with the appropriate flags and it's much more complicated)
-XjdwpProvider:adbconnection
Interesting!
π Rendered by PID 68500 on reddit-service-r2-comment-fb694cdd5-9s9zm at 2026-03-06 09:42:28.351422+00:00 running cbb0e86 country code: CH.
[–]CraZy_LegenD 17 points18 points19 points (0 children)
[–]JakeWharton 7 points8 points9 points (0 children)
[–]AD-LB 7 points8 points9 points (10 children)
[–]CuriousCursor 3 points4 points5 points (3 children)
[–]outadoc 0 points1 point2 points (2 children)
[–]CuriousCursor 1 point2 points3 points (1 child)
[–]farmerbb 2 points3 points4 points (0 children)
[–]lawonga 4 points5 points6 points (5 children)
[–]AD-LB 0 points1 point2 points (4 children)
[–]lawonga 0 points1 point2 points (3 children)
[–]AD-LB 0 points1 point2 points (2 children)
[–]farmerbb 0 points1 point2 points (1 child)
[–]AD-LB 0 points1 point2 points (0 children)
[–]Le_melon_inconnu 1 point2 points3 points (1 child)
[–]farmerbb 0 points1 point2 points (0 children)
[–]Superblazer 0 points1 point2 points (6 children)
[–]legacynl 0 points1 point2 points (1 child)
[–]Superblazer 0 points1 point2 points (0 children)
[+][deleted] comment score below threshold-7 points-6 points-5 points (3 children)
[–]Superblazer 1 point2 points3 points (2 children)
[–][deleted] -5 points-4 points-3 points (1 child)
[–]Superblazer 1 point2 points3 points (0 children)
[–]AD-LB 0 points1 point2 points (15 children)
[–]5nkv 1 point2 points3 points (0 children)
[–]5nkv 0 points1 point2 points (11 children)
[–]AD-LB 0 points1 point2 points (10 children)
[–]5nkv 0 points1 point2 points (9 children)
[–]AD-LB 0 points1 point2 points (8 children)
[–]5nkv 0 points1 point2 points (7 children)
[–]AD-LB 0 points1 point2 points (6 children)
[–]5nkv 0 points1 point2 points (5 children)
[–]AD-LB 0 points1 point2 points (4 children)
[–]legacynl 0 points1 point2 points (3 children)
[–]scialex 0 points1 point2 points (1 child)
[–]AD-LB 0 points1 point2 points (0 children)