Start/Stop adb daemon programmatically in android - adb

I want to make an app.which can start and stop adb daemon which i want to run on Google Nexus 7(Android 5.0.1).
I downloaded the nexus 7 source code and created an app. in packages/app folder and built it in system/priv-app.
I am using following code for starting and stoping adb daemon :
Runtime.getRuntime().exec("setprop service.adb.tcp.port 5555");
Runtime.getRuntime().exec("stop adbd");
Runtime.getRuntime().exec("start adbd");
But its not working.
It works fine on an emulator(Android 4.4), but not on the device.
Can any one please suggest if anything more needs to be done for the above code to work on device.
I am having the
whole system code.
Thanks

Related

how to start code server terminal with chroot?

I have a code server that runs on Android with termux, for university reasons, there are times when I must share my vscode environment and I would not like to expose my entire system and personal files through the terminal.
So I was wondering if it was possible to expose a terminal from an alpine distro with chroot (prrot in the case of termux) by default every time code server opens a terminal
After some time reading the vscode config, I realized that you can use the shell option to force it to start inside with alpine and not expose my files, nor my android system with termux
"terminal.integrated.shell.linux":"/data/data/com.termux/files/usr/bin/startalpine"

React Native 0.60 connection to development server

(I'm almost a newbie in React Native development) today I have started a new project in React Native 0.60 (react-native init MyApp).
After that I typed : react-native run-android to check if everything worked.
After the bundle process is finished
I can finally get my welcome screen in my connected devices
But, if I try to reload the app from my devices I get this error:
How could I address this error ?
EDIT: Thank you for your answers, anyway, I have tried all solutions you suggest but I still get the same problem. I also noticed that when i run react-native run-android Metro Bundler (open in a new cli window) seems to start but it suddenly disappear. I think the problem could be with the message 'Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0'
react-native run-android not working in new react-native version
0.60
now you can use
react-native start
OR
npm start
both command is work
Please use the following two commands and then can start the react native again.
- adb reverse tcp:8081 tcp:8081
- killall node
Then you can run the following the command.
react-native start
Now you can run your application again.
Have a good day.
You need to connect your phone to the server, follow the below steps:
[For detailed help follow this https://facebook.github.io/react-native/docs/running-on-device]
1. Open the developer menu on phone.
2. Open 'Debug server host & port for device'.
3. Type in your machine's IP address and the port of the local dev server (eg. 10.0.1.1:8081). If you have connected over wifi then this will be your computers ip address. (If you are running in your computer I think instead of ip address it would be 'localhost:8081')
4. Go back to the Dev menu and select reload.
Hope it would help.
You need to run adb reverse in the Android Studio terminal so your device can connect to the server. Open Android Studio and click on the terminal button at the bottom. In the terminal, and with your device connected to your computer, enter the command adb devices. This will list the name of the connected Android device. Copy that name. Then enter this command adb -s <device name> reverse tcp:8081 tcp:8081. When you run that command replace <device name> with the name of your device you copied from the other command.
Here is a link to an explanation in the React Native documentation

getting error while using logcat for checking logs of an app in linux

I want to know bugs of my android app so i tried to use logcat to see its log and followed these steps:-
You need to use adb server.
1. Connect your android with your laptop/pc
2. Go to developer options and turn on the stay awake and USB debugging options. (Your phone)
3. In your terminal, type "sudo adb kill-server" and then "sudo adb start-server".
4. Type "adb devices" (this should give list of devices connected)
List of devices attached
you_device_name device
5. "cd" to your folder where you have made your build.
6. Type "buildozer android debug deploy run logcat > logcat.txt"
this saves the logs (for the entire process) in a file logcat.txtx in the same folder and also deploys you app on the phone.
Go through it and find your error.
7. keep your phone awake.(do not lock it).
But when i run the 6th step, a time comes it says:-
error: device 'adb' not found
- waiting for device -
i have searched many times on the internet and when finally i am posting here to get solution
I actually initially misread the bulldozer error. It is complaining that a device adb doesn't exist. Which is strange. It should have picked up the device serial instead.
You could theoretically force adb commands to go to your device by executing
export ANDROID_SERIAL= <your device's serial number>
you could now repeat the steps and check if this works.
Also just for completeness just check if there exists an adb binary in the system partitin of your device.
Also make sure you haven't missed out any bulldozer init steps

Daydream View Controller Emulator won't work with Google VR SDK 1.1 and Unity 5.6 beta for Linux

I can't get the controller emulator to work with Google VR SDK 1.1 & Unity 5.6b3 under Arch Linux 64-bit. If I load the GVRDemo scene in Unit and click the play button to enter Play Mode, the console shows the following:
"Android Debug Bridge (adb) command not found.
Verify that the Android SDK is installed and that the directory containing adb is included in your PATH environment variable."
In Windows, you have to add the directory containing the Android Debug Bridge (adb) program to the PATH environment variable in Windows itself (not in the Unity program). Once you do that, the Controller Emulator works fine in Windows. You have to do the same in Linux, evidently, to get Unity to locate adb, and therefore get the Controller Emulator phone working for testing the game.
I've added the following line in my .bashrc and .profile files in my home directory:
"PATH=/home/jesse/Android/Sdk/platform-tools/:$PATH"
This, however, doesn't fix the issue.
I've also added the root directory of the Android SDK to my Unity Preferences > External Tools section.
I don't know how to get Unity and Google VR SDK to recognize the directory containing adb to the PATH environment variable that Unity needs to make the Controller Emulator work.
Is anyone else having this issue? Is there a fix or work-around?
I was able to locate the culprit and modify Google VR SDK scripts to make it work! Turns out there was an issue in the code of the script file titled "EmulatorClientSocket.cs" regarding non-Windows machines. Here's what I changed, and why:
Originally, in line 111 and 112 of this script, it read:
stringprocessFilename="bash";
stringprocessArguments = string.Format(" -l -c \"{0}\"", adbCommand);
The context is that when Windows is not present (forgive my layman's terms -- I've only started learning coding a month ago) the command to process is this: bash -l -c "adb forward tcp:7003 tcp:7003". The problem is when the -l option is used in the command, the command is interpreted as if coming from a login shell, which - I believe - means that bash isn't looking at the custom environment variables set in the user's .bashrc and .profile files in their home directory. Without looking at those files, bash can't locate the adb command (try running the bold command above in a terminal, and the result will be a prompt saying adb command not found).
To fix it, I simply removed the -l option from line 112, and, voila! Everything works like a charm! Lines 111 and 112 now look like this:
stringprocessFilename="bash";
stringprocessArguments = string.Format(" -c \"{0}\"", adbCommand);
The fix will work when running "unity-editor" or "unity-editor-beta" from the Terminal or Xterm, but running it from the application menu will still produce the adb error and Controller Emulator will not work.

Need assistance with adb shell, on non rooted device

I'm confuse with adb shell device login, I'm not able to go in root mode (# mode). I can only access $ mode from adb shell on any non rooted devices such as, Samsung galaxy Note, Galaxy 2 and Samsung galaxy Apollo (2.1), and as well not able to use "su -" command to be super user, and therefore restricted to directories such as /data/data/com.myapp.exmple.
But with root device can get root access with adb shell, and access them so my basic doubt is with non rooted devices can we get the root access with adb shell?
If not, I'm using Andrew Hoog's book "Synergy Android Forensics" which demonstrates adb shell can give you access to root (#mode) on non rooted devices, as well there are few examples on internet and forum which states so. take this video for example.
http://www.youtube.com/watch?v=tVJ7T2oC_Zs
Which is basically demonstrating how to unlock the security pattern lock with adb shell, which gets the root access (# mode) on non rooted device.
And if yes, what is the mistake I'm making? I install the latest JDK, then Android sdk in C:, then from c:android-sdk/platform-tools/ directory tried to access the adb shell.
I am running Cyanogenmod with Android 4.1.2 so this probably does not apply to stock roms. When I enter
adb root
the console returns
root access is disabled by system setting - enable in settings -> development options
in that menu you can disable root access, grant it for apps only, adb only and apps and adb. Select apps and adb and everything should work as expected.
AFAIK adb root or su- wont work on non-rooted android mobiles.
You can Google on how to root your specific model, but beware that you may loose company warranty if you force root your phone.
There is a command for getting root access on Android:
adb root
I don't know if it works on any version of Android. The above command restarts the adb as root.
Tap your device version build number (at the bottom of the info page) 7 times for android 4.2. This will enable the developer's menu.

Resources