A Java library implementation of the ADB network protocol
An example project using this library can be found here: https://github.com/cgutman/AdbLibTest
An Android demo can be installed from Google Play.
A Java library implementation of the ADB network protocol
License: BSD 3-Clause "New" or "Revised" License
A Java library implementation of the ADB network protocol
An example project using this library can be found here: https://github.com/cgutman/AdbLibTest
An Android demo can be installed from Google Play.
I know it's possible you have a Ctrl+C send option in the adb app built in, but I was wondering how to send such a command for myself using this library. I can't seem to find out how.
I try to "adb connect" android device with shell command these days and found that some devices could not be connected successful which display "unauthorized". I guess the reason is using "connect" command by shell could not get RSA code which is use to get authority.
So I want to use adblib to connect device. Could you pls provide any demo code to use adblib?
Just want to let you know that I have created a fork of your library:
https://github.com/tananaev/adblib
The main reason is to publish it on maven repository to simplify adding it as a dependency. Had to change package name to match my group id.
Another small thing is addition of an option to provide key pair to crypto class. I use android key store system to generate and store keys, so I needed a way to pass it into adblib.
Thank you very much for open sourcing this project. I started developing some similar first, but then stumbled upon your library and decided to use it.
Hi,
Can we use AdbLib to call command on the same device AdbLib is running?
Thanks
Hi @cgutman,
I would like to run a command "adb root" and not passing through adb shell (which works):
using adb shell: getprop ro.build.version.incremental
it is working:
String getpropCommand = "getprop ro.build.version.incremental";
AdbStream streamGetpropCommand = connection.open("shell:" + getpropCommand);
while (!streamGetpropCommand .isClosed()) {
try {
String result = new String(streamGetpropCommand.read(), StandardCharsets.US_ASCII);
// Print each thing we read from the shell stream
System.out.println("-->step1: getprop result: " + result);
if (!result.isEmpty()) {
streamGetpropCommand.close();
}
} catch (InterruptedException | IOException e) {
e.printStackTrace();
return;
}
}
and when using adb root
does not work:
String rootCommand = "adb root";
AdbStream streamRootCommand = connection.open(rootCommand);
while (!streamRootCommand.isClosed()) {
try {
String result = new String(streamRootCommand.read(), StandardCharsets.US_ASCII);
// Print each thing we read from the shell stream
System.out.println("--> step2: adb root result: " + result);
if (!result.isEmpty()) {
streamRootCommand.close();
}
} catch (InterruptedException | IOException e) {
e.printStackTrace();
return;
}
}
I've seen this on two devices at least, occurs at AdbProtocol.java#L292:
java.lang.OutOfMemoryError: Failed to allocate a 1598575456 byte allocation with 7544583 free bytes and 248MB until OOM, target footprint 15089167, growth limit 268435456
at com.cgutman.adblib.AdbProtocol$AdbMessage.parseAdbMessage (AdbProtocol.java:276)
How can I use this tool to install apk from source (not from destination) like "adb install .apk" when using pc?
Is it even possible.
Thank you very much for open sourcing this project first!!!
It is quite pretty and usefull.
I want to use this lib to implement the function that can send some files from one device to the connected device. It will just like use the PC to send command line "adb push /xxx/xxx/test.txt /xxx/xxx/xxx/test.txt".
Could you please kindly give me some tips ?
Thanks again !!!
public AdbStream open(java.lang.String destination)
throws java.io.UnsupportedEncodingException,
java.io.IOException,
java.lang.InterruptedException
Opens an AdbStream object corresponding to the specified destination. This routine will block until the connection completes.
Parameters:
destination - The destination to open on the target
Returns:
AdbStream object corresponding to the specified destination
Throws:
java.io.UnsupportedEncodingException - If the destination cannot be encoded to UTF-8
java.io.IOException - If the stream fails while sending the packet
java.lang.InterruptedException - If we are unable to wait for the connection to finish
for the parameter destination
There is no indication of what can be filled in.
I only tested "shell:" or "reboot:"
If have other destinations, please tell me
Ex : I run the "pm list packages -3" command . How can i read the result from this command. Hope to get answer soon. Thanks !
Hello @cgutman,
I want to backup some files via my developing application. So, I used "sync" connection and opened stream via "RECV". (I want to pull about 40 files in this stream).
But, sometimes adb pulled these files, sometimes no. When I debug this problem, read() function is not return anything. read() is always waiting.
How can I solve this problem?
(I hope, I can explain my problem.)
Please look at my issue.Thank you very much.
Old issure:
I am using your adblib, thank you very much for being open source.
I met a question and wanted to ask for your help. I use your project on Android, the code as same as your demo, the interface is AdbCrypto.loadAdbKeyPair.However,when I re-open my application, it need to re-prompt to allow USB debugging, but the computer's RSA key as same as last RSA.
Hello
I am a newbie in android.
There are several question about adblib.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.