[Dev][RELEASE][Lib/Java] JDroidLib Java ←|→ Android Communications Library

Search This thread

Beatsleigher

Senior Member
Hey there,

many of you are probably familiar with @regaw_leinad's AndroidLib.
It is a really nicely coded, and easy-to-use .Net class library, which allows real easy communication with Android devices.
regaw_leinad said:
AndroidLib is a .NET assembly written in C# (C-Sharp) that easily handles communication between a connected Android device and your program.

However, it has a downside. That downside being; it only works with .Net languages. .net languages include:
Code:
# Visual Basic
# C#
# F#
# Visual C++
# ASP.Net
As you might have guessed, Java does not belong to the .Net language set.
And as I moved from .Net to Java (allows my projects and libs to become available to a wider audience), I don't have the privilege to use AndroidLib, which is a real bummer.
This is why I have started JDroidLib.

Edit (08.10.2017): JDroidLib is being replaced by JDroidLibv2!

For anyone coming across this thread; this version of JDroidLib, while still available, is considered obsolete and is being replaced by JDroidLibv2!
https://xdaforums.com/android/software-hacking/lib-jdroidlibv2-t3684697

EDIT: 01.03.2014
JDroidLib has undergone some major updates, with loads of kinks fixed, and features revamped.
See the lists below for more info. (Everything has changed, there).

Oh, and the code has a kind of easter egg :eek:

Current features:
Code:
 # Execute any type of ADB command from a single method. 
    (This method always returns output, but you can execute the method, without grabbing it).
 # Execute any fastboot command frmo a single method. (Same returns as above.)
 # Install ADB/fastboot to either fixed, or custom location. (On MAC OS/Linux: Binaries are automatically chmod-ed!)
 # Pull entire build.prop from device to hard drive
 # Get single build properties ([B]!!![/B])
 # Push build.prop back to device.
 # Reboot device (5-way/ADB + fastboot)
 # Get list of devices. (Returned as generic List<String>)
 # Get device information (Battery, SU, BusyBox, CPU - MORE COMING!)
 # Get device state
 # Start ADB server
 # Stop ADB server
 # Restart ADB server.
 # Much, much more. See JavaDocs for more!

Current bugs:
There's a weird bug in the Battery department, where the loaded battery level is 0. Looking into it! Fixed.
Slight bug in reboot methods, device isn't rebooting. Fixed.

Planned features:
Code:
 # Get phone/WiFi/BlueTooth/etc. information
 # And anything else that comes to mind!

License:
Code:
/*
 * Copyright (C) 2013 Simon/Beatsleigher.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301  USA
 */

Source code:
To get a copy of the source code, visit my GitHub
There will be no pre-compiled JARs. To get a JAR, you have to download and compile the source.
The IDE used is NetBeans 8.0 with JDK 7
To download NetBeans, visit http://netbeans.org

JDroidLib Documentation:
http://team-m4gkbeatz.eu

How to Use JDroidLib:
http://www.youtube.com/watch?v=dRSwailf7GI

Thanks:
Thanks to @regaw_leinad for having the original idea!
Thanks to you, XDA, for taking the time and looking at my programs/libs. Much appreciated!
XDA Portal Story 04.12.2013
Newer XDA Portal Story 03.03.2014

Have fun with JDroidLib and don't forget to contribute your own code!
 
Last edited:

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,826
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
You know, you could always contribute to CASUAL. We use Java and NetBeans as well and we are already a few years ahead of you. We could pull out the ADB/fastboot/busybox/Heimdall portions of CASUAL to distribute separately, by making some small changes to our make file and would have what you're going for here.
 

Beatsleigher

Senior Member
You know, you could always contribute to CASUAL. We use Java and NetBeans as well and we are already a few years ahead of you. We could pull out the ADB/fastboot/busybox/Heimdall portions of CASUAL to distribute separately, by making some small changes to our make file and would have what you're going for here.

Wow. Never would have thought you'd reply to or even look at one of my threads!
It's a good idea. I'll have a think about it. I'm going to keep working on this, mainly because someone (or even I) could eventually port it to C/C++ if they need to.
 
  • Like
Reactions: AdamOutler

cybojenix

Retired Forum Mod / Retired Recognized Developer
Apr 7, 2012
801
1,864
Wow. Never would have thought you'd reply to or even look at one of my threads!
It's a good idea. I'll have a think about it. I'm going to keep working on this, mainly because someone (or even I) could eventually port it to C/C++ if they need to.

hey I've just done a draft for a python adb (PyAdb) which removes entirely the dependence of the adb binary. when you get into it, it's actually quite simple to replicate it. I've added reference links in my thread as well, and the python is so simple you can see how it all works

http://xdaforums.com/showthread.php?t=2574326

ping me if you want any help with anything. I'm getting on with my java studies so I may be able to help with porting it over
 

Beatsleigher

Senior Member
hey I've just done a draft for a python adb (PyAdb) which removes entirely the dependence of the adb binary. when you get into it, it's actually quite simple to replicate it. I've added reference links in my thread as well, and the python is so simple you can see how it all works

http://xdaforums.com/showthread.php?t=2574326

ping me if you want any help with anything. I'm getting on with my java studies so I may be able to help with porting it over

The main reason I coded this is for use in my own programs, coded in Java.
I guess the Python wrappers coded by you and the other member, are for use with the Python interpreter.
But I guess I could help port stuff over and you could help with JDroidLib.

Sent from my GT-I9505 using XDA Premium 4 mobile app
 

cybojenix

Retired Forum Mod / Retired Recognized Developer
Apr 7, 2012
801
1,864
The main reason I coded this is for use in my own programs, coded in Java.
I guess the Python wrappers coded by you and the other member, are for use with the Python interpreter.
But I guess I could help port stuff over and you could help with JDroidLib.

Sent from my GT-I9505 using XDA Premium 4 mobile app

Sorry you got the wrong end of the stick. The one by me is an adb client in python, not a wrapper. I was suggesting look at the methods it uses so the same can be done for JDroidLib, without needing a dependence on the adb binary. It's just commands passed via TCP

Sent from my Nexus 7 using Tapatalk
 

Beatsleigher

Senior Member
Sorry you got the wrong end of the stick. The one by me is an adb client in python, not a wrapper. I was suggesting look at the methods it uses so the same can be done for JDroidLib, without needing a dependence on the adb binary. It's just commands passed via TCP

Sent from my Nexus 7 using Tapatalk

Ahhh. I gotcha. Sure. If you want, check out the source and see what you can do. I'll take a look at it as soon as I've finished my Tekkit server and got DetectCPUv3 done.

Sent from my GT-I9505 using XDA Premium 4 mobile app
 

Beatsleigher

Senior Member
JDroidLib is back, and beter than ever!

Hey guys,

I was asked by a few friends and other people, if I had abbandoned JDroidLib, because I wasn't updating it for so long, so I haven't abbandoned it, nor have I abbandoned any other projects of mine, which are currently being ported to Java, it's just time consuming, and I'm looking for jobs at the moment, so I'm not on as much, and I don't have that much time to do things.

But, I have picked up JDroidLib again, and added some new features!
Basically, I've re-written the entire thing in under a day, because the code that was originally in there was real messy and I thought I may as well.

The new features include:
Code:
Device listing
Comand execution (now made really simple and squashed into two-three methods)
Rebooting the device (now one method, and uses internal enums)
I've revamped the installer, so other programs can install the binaries to their desired location, however, for operation, the default location will be used.
And (finally) I've got the Battery class, so developers can easily get battery stats!
Also, I've added a BuildProp class, which allows you to pull the file to a location on the HDD, read individual props and push the file back!

Currently, I'm sorting out the CPU class, which will, similarly to the Battery class, get CPU info, like currently running processes and CPU load.

So, check out the GitHub repo, and watch it to get the latest stuff!
Feel free to add your own code, classes, whatever and I can't wait to release this puppy into the wild! (Metaphorically speaking, that is... :eek: )
 
  • Like
Reactions: ladalgigi

OmarBizreh

Inactive Recognized Developer
Oct 26, 2011
2,109
3,499
Damascus
plus.google.com
Although I'm not a big fan of Java, I prefer C#
Your library made me rethink of porting Droid Manager (Which uses AndroidLib) to Java in-order to make it available for every one.
Let's see what I can do :fingers-crossed:

Thanks for your efforts :highfive:
 

Beatsleigher

Senior Member
Although I'm not a big fan of Java, I prefer C#
Your library made me rethink of porting Droid Manager (Which uses AndroidLib) to Java in-order to make it available for every one.
Let's see what I can do :fingers-crossed:

Thanks for your efforts :highfive:
-- Post deleted --
Reason: Didn't read post correctly and I take back what I said.

Sent from my GT-I9505 using XDA Premium 4 mobile app
 
Last edited:
  • Like
Reactions: OmarBizreh

OmarBizreh

Inactive Recognized Developer
Oct 26, 2011
2,109
3,499
Damascus
plus.google.com
-- Post deleted --
Reason: Didn't read post correctly and I take back what I said.

Sent from my GT-I9505 using XDA Premium 4 mobile app

Although I didn't read what was written before :angel:
I would like to ask you, have you ever written or know something about using Java to write a service that can run on Linux and Mac?!
I only know how to write a windows service using C# Unfortunately
 

Beatsleigher

Senior Member
Although I didn't read what was written before :angel:
I would like to ask you, have you ever written or know something about using Java to write a service that can run on Linux and Mac?!
I only know how to write a windows service using C# Unfortunately

As far as I'm aware, it's just a program that runs in the background. So it shouldn't be difficult to code. Maybe a few threads and things, and it should work. Otherwise, Google is your friend. Personally, I've never written a service in Windows or BSD, so I have no idea how they work. But I can imagine it shouldn't be too difficult.

Sent from my GT-I9505 using XDA Premium 4 mobile app
 

OmarBizreh

Inactive Recognized Developer
Oct 26, 2011
2,109
3,499
Damascus
plus.google.com
As far as I'm aware, it's just a program that runs in the background. So it shouldn't be difficult to code. Maybe a few threads and things, and it should work. Otherwise, Google is your friend. Personally, I've never written a service in Windows or BSD, so I have no idea how they work. But I can imagine it shouldn't be too difficult.

Sent from my GT-I9505 using XDA Premium 4 mobile app

well coding isn't difficult, I suppose I will google it, since writing the core of the service isn't difficult, it's just how I do I do a service written in Java :fingers-crossed:
 

Beatsleigher

Senior Member
well coding isn't difficult, I suppose I will google it, since writing the core of the service isn't difficult, it's just how I do I do a service written in Java :fingers-crossed:

You'll manage, I'm sure :)
If you need any code examples, check out my UniversalAndroidToolkit repo on GitHub. It's all commented and documented, and I think I write pretty clean code, so it shouldn't be too hard to figure out :)

Sent from my GT-I9505 using XDA Premium 4 mobile app
 
  • Like
Reactions: OmarBizreh

OmarBizreh

Inactive Recognized Developer
Oct 26, 2011
2,109
3,499
Damascus
plus.google.com
You'll manage, I'm sure :)
If you need any code examples, check out my UniversalAndroidToolkit repo on GitHub. It's all commented and documented, and I think I write pretty clean code, so it shouldn't be too hard to figure out :)

Sent from my GT-I9505 using XDA Premium 4 mobile app

Thanks a lot I really appreciate your help :)
I will make sure to browse your git repo :highfive:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 14
    Hey there,

    many of you are probably familiar with @regaw_leinad's AndroidLib.
    It is a really nicely coded, and easy-to-use .Net class library, which allows real easy communication with Android devices.
    regaw_leinad said:
    AndroidLib is a .NET assembly written in C# (C-Sharp) that easily handles communication between a connected Android device and your program.

    However, it has a downside. That downside being; it only works with .Net languages. .net languages include:
    Code:
    # Visual Basic
    # C#
    # F#
    # Visual C++
    # ASP.Net
    As you might have guessed, Java does not belong to the .Net language set.
    And as I moved from .Net to Java (allows my projects and libs to become available to a wider audience), I don't have the privilege to use AndroidLib, which is a real bummer.
    This is why I have started JDroidLib.

    Edit (08.10.2017): JDroidLib is being replaced by JDroidLibv2!

    For anyone coming across this thread; this version of JDroidLib, while still available, is considered obsolete and is being replaced by JDroidLibv2!
    https://xdaforums.com/android/software-hacking/lib-jdroidlibv2-t3684697

    EDIT: 01.03.2014
    JDroidLib has undergone some major updates, with loads of kinks fixed, and features revamped.
    See the lists below for more info. (Everything has changed, there).

    Oh, and the code has a kind of easter egg :eek:

    Current features:
    Code:
     # Execute any type of ADB command from a single method. 
        (This method always returns output, but you can execute the method, without grabbing it).
     # Execute any fastboot command frmo a single method. (Same returns as above.)
     # Install ADB/fastboot to either fixed, or custom location. (On MAC OS/Linux: Binaries are automatically chmod-ed!)
     # Pull entire build.prop from device to hard drive
     # Get single build properties ([B]!!![/B])
     # Push build.prop back to device.
     # Reboot device (5-way/ADB + fastboot)
     # Get list of devices. (Returned as generic List<String>)
     # Get device information (Battery, SU, BusyBox, CPU - MORE COMING!)
     # Get device state
     # Start ADB server
     # Stop ADB server
     # Restart ADB server.
     # Much, much more. See JavaDocs for more!

    Current bugs:
    There's a weird bug in the Battery department, where the loaded battery level is 0. Looking into it! Fixed.
    Slight bug in reboot methods, device isn't rebooting. Fixed.

    Planned features:
    Code:
     # Get phone/WiFi/BlueTooth/etc. information
     # And anything else that comes to mind!

    License:
    Code:
    /*
     * Copyright (C) 2013 Simon/Beatsleigher.
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU Lesser General Public
     * License as published by the Free Software Foundation; either
     * version 2.1 of the License, or (at your option) any later version.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     * Lesser General Public License for more details.
     *
     * You should have received a copy of the GNU Lesser General Public
     * License along with this library; if not, write to the Free Software
     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
     * MA 02110-1301  USA
     */

    Source code:
    To get a copy of the source code, visit my GitHub
    There will be no pre-compiled JARs. To get a JAR, you have to download and compile the source.
    The IDE used is NetBeans 8.0 with JDK 7
    To download NetBeans, visit http://netbeans.org

    JDroidLib Documentation:
    http://team-m4gkbeatz.eu

    How to Use JDroidLib:
    http://www.youtube.com/watch?v=dRSwailf7GI

    Thanks:
    Thanks to @regaw_leinad for having the original idea!
    Thanks to you, XDA, for taking the time and looking at my programs/libs. Much appreciated!
    XDA Portal Story 04.12.2013
    Newer XDA Portal Story 03.03.2014

    Have fun with JDroidLib and don't forget to contribute your own code!
    3
    ### Update to JDroidLib ###

    JDroidLib has recieved a new update, adding some code improvements, which should impact speed in a positive way.
    Also, new methods have been added, although I can't remember what they do :D

    Enjoy the update. For build instructions, check out my website (the picture in my description...).
    2
    A quick update on JDroidLib!

    JDroidLib received a major code overhaul. This update WILL break things, but this change is for the better.
    All the major classes' constructors have been made internal and I have implemented singleton-methods

    You can find the full commit here: https://github.com/Beatsleigher/JDroidLib/commit/13241c9c561174ac4ef94eae8adcda2d647e8b7b

    Enjoy!
    2
    Attention all Java developers, using JDroidLib.
    JDroidLib's JavaDoc-documentation has been uploaded to my webserver:
    http://team-m4gkbeatz.eu/javadoc/jdroidlib

    Enjoy!
    2
    Might be just me, but I couldn't find them.
    Is there any way to compile this without netbeans? I'm using eclipse, but I can't import the project, and I don't feel much for compiling it by hand...

    One sec, I'll update the repo and add an eclipse folder.