Android Studio Adb Transfer Protocol Error - android-studio

I've just started using Android Studio. I've got an HTC one (m7) running rooted Lollipop. I'm trying to run the test app I've created on this physical device. When I go to run it I get "Adb Transfer Protocol Error: Permission Denied". The device shows up in android studio when I go to run the app, and I have verified root access. Any help is appreciated.
EDIT: I just tried to install a .apk file using the command adb install and I'm getting permission denied. This is a rooted phone. However, I've always had root access on this phone, and before upgrading to android 5.0 Lollipop I could run this command and instantly install a .apk without having to do adb shell. If this is the problem, how do I tell android studio to run adb shell before trying to install and run the app?

Well, I solved it. The folder \data\local\tmp did not have full read write execute permissions. Once I did a quick chmod 777 on it Android Studio allowed the installation and run of the app. You can also do this procedure through a file explorer that has root capabilities.

You can also do this in Terminal Emulator. Download the app from this link:
https://play.google.com/store/apps/details?id=jackpal.androidterm&hl=pl
Of course you need to have root.
Open it and enter:
su
cd /data/local
chmod 777 tmp
And try run app now

Related

Expo/GenyMotion throws "ADB server didn't ACK" when running project

I'm trying to set up a React Native project using GenyMotion and Expo on Ubuntu. However, when I click the 'Device' button in Expo to package the app onto the emulator, I get the following error in the Expo console:
I initially tried to use React Native through Android Studio, with the inbuilt Android emulator, so I thought the issue might that my computer hasmultiple ADB versions (when I ran $ adb --start-server from the terminal, it'd run the Android Studio binary, not the GenyMotion one). So I:
Removed everything Android Studio related that I could find, including the SDK at Android/Sdk/ and now $ adb --start-server
Ran $ sudo apt-get remove adb android-tools-adb
Set the filepath for the Android SDK in GenyMotion to my GenyMotion Android SDK. But I'm guessing is the same as the default setting, so I don't know if I needed to do this?
Removed all path variables related to Android Studio from my .bashrc file, including $ANDROID_HOME. (should I instead set $ANDROID_HOME to point to the GenyMotion Android SDK?
After doing the above, $ ps -aux | grep 5037 outputs the following:
even after quitting GenyMotion and Expo, so it looks like there is still a forked ADB daemon running. If I cd to my GenyMotion SDK and run $ ./adb kill-server (after quitting GM and Expo) that process doesn't show up in the output of ps anymore. However, interestingly, if I run $ ./adb start-server I get this:
But I don't know how to udpate the GenyMotion version of ADB. This also seems to indicate there are different ADB server and client programs. Is this correct? I have only ever interacted with the adb binary in the SDK folders.
UPDATE: I tried starting ADB from the terminal again, and cannot recreate the conflicting version error. The server starts perfectly now.
I was also having trouble with tunneling not working in Expo, so I've changed the host to localhost. It works, but I'm not sure exactly what the implications of this change are:
Obviously, I'm pretty new to Android development, and GenyMotion/Expo in particular. But I think I've been pretty thorough in my troubleshooting. What else can I try?
The solution, at least for me, was that I needed to add export PATH="/home/darik/projects/android/genymotion/tools:$PATH" to my .bashrc file. I'm guessing the reason the ADB server wasn't ACKing was that Expo couldn't find the ADB server in my path env variable.
The solution for me, was that I have multiple adb installed on the system.
And the adb version on my system is different from the adb version on the android sdk platform-tools.
I just add on PATH the right folder C:\\Ragnulf\AppData\Local\Android\Sdk\platform-tools
Ensure you have only one adb version added to your path, the one you need to use.
For me I removed the old ADB that I had installed, then I setup android sdk tools for Genymotion, read this article from their site Genymotion: Setup sdk tools with or without android studio
After installation of the tools:
For windows add to your environment path, the path to platform-tools
C:\<username>\path\to\android\sdk\platform-tools
For Linux or MacOS just add the following to your .bashrc or .zshrc or whaterver file is read by your terminal on initialization like:
export PATH="/path/to/android-sdk/platform-tools":$PATH
Platform tools is a subfolder within the Andorid SDK tools target installation folder, target folder looks like:
android-sdk
├── build-tools
├── emulator
├── licenses
├── patcher
├── platform-tools
└── tools

Android Studio 3.0 - No server to serve request

After clean install of Android Studio I always get the error
Error:java.util.concurrent.ExecutionException:
java.lang.RuntimeException: No server to serve request. Check logs for
details.
and
Error:Execution failed for task ':Application:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: No server to serve request. Check logs for details.
Java is up to date and the path is set.
I am new to Android Studio, what should I try?
We ran into the same issue, and have been able to find the root cause: The error message means that Gradle cannot connect to some worker processes. In our case, the process was for 'aapt2'. Running 'ldd aapt2' indicated that some shared libraries were missing (mainly GLIBC). Since we're using Docker based on Alpine Linux, it comes with a reduced GLIBC (glibc-musl). The solution was to simply install glibc in the Docker container.
I suggest you run ldd build-tools/{version}/aapt2
to see which libraries are missing from the OS. You did not mention your OS, are you also using Docker and AlpineLinux ?
In my case, I did not need to re-download the sdk. I closed Android Studio and ran the following command in the Terminal:
sudo chmod 777 -R ~/Desktop/AndroidStudio
...where, ~/Desktop/AndroidStudio was the folder structure after Root which I needed to mention in order to provide permission to read all the SDK packages and perform required operation as and when necessary by the Android Studio, because my Sdk folder was inside "~/Desktop/AndroidStudio".
I am running Android Studio 3.0.1 on Ubuntu 16.04 LTS. This worked for me perfectly :-)
This error occurred because you might have accidentally remove the executable flag from aapt2 which is located in $ANDROID_HOME/build-tools/27.0.2.
Try this:
Re-download the sdk (recommended)
followed by-
sudo chmod 777 -R $ANDROID_HOME
Note:
$ANDROID_HOME is the location where I put android sdk
Hope this helps !!
Had to uninstall Android studio and delete the following
SDK folder in AppData folder
Delete .gradle folder
delete .AndroidStudio Projects folder
and did a fresh install which solved .
I had this problem on lubuntu-16 32bit (and also some other problems too). all of the problems were solved when I updated my system to lubuntu-16 64-bit.
Here how I fixed this Issue:
1.Deleted .gradle folder.
2.Closed android studio and run as administrator.
On Start android studio will rebuild the folder you deleted.
sudo chmod 777 -R $ANDROID_HOME
Note: $ANDROID_HOME is the location where you put android sdk
Hope this helps !!
If it is possible for you, please delete the build folder of project and test building android project with any other version of build-tools.
in my case, build-tools version: 26.0.2 had problem, I tested with 27.0.3 and it solved my problem unbelievably :)
I ran into the same problem, and it turned out I had messed up the file permissions inside the android-sdk folder (more specifically android-sdk/build-tools/{version}), and some binaries were missing execution permissions.
In my case, I simply gave x permissions to the relevant files in that directory, but if you're not sure, I suggest you uninstall the android sdk, completely remove its directory and then reinstall it again.
So after investigating the issue for long , I have a concrete solution .
Let`s look into it.
Go to Android Studio -> Help -> Show Log In Files
In the subsequent folder that opens, open idea.log
This would present you with a log file which contains logs of processes right from when the studio started. Now in this file, you have to search for the possible issue. For some the issue might be due to
java.io.IOException: Cannot run program "/home/mmt/Android-Sdk/android-sdk-linux_x86/emulator/emulator-check": error=13, Permission denied
For some others, it may be some other. The point is that this file contains lot of irrelevant logs and you have to identify the one that is causing this issue. For me , after discovering the above issue, I granted permission to that particular folder using the below commands
cd $ANDROID_HOME/sudo chmod -R 777 emulator/
After this, rebuild your project and tadaaa.. problem resolved.
for me it was a virus that corrupted my files from the "build tools" folder. so I uninstalled everything and made a new installation of android studio, SDK and build tools.
For me, this is the side effect of another issue that I haven't root caused yet. Every once in a while, I get aapt2 failures because some file /tmp/ld-linux-x86-64.so.2 is "busy", with the following error message.
AAPT err(Facade for 1745790725): cp: cannot create regular file '/tmp/ld-linux-x86-64.so.2': Text file busy
Slave 1745790725 failed to start java.lang.RuntimeException: AAPT slave failed to start. Please make sure the current build tools (located at ~/.../android-sdk-linux/build-tools/27.0.3/aapt2) are not corrupted.
When this happens I just rm that file and everything starts working again. I suspect this might be caused by me actually having two installs of adb (one through ubuntu via apt and one from Android studio) but I haven't had time to dive deeper.
I already had latest version of build-tool installed, so I just had to give permission to Android_home:
chmod 777 -R $ANDROID_HOME
and build again. This worked for me.
If you are on Windows 10 (sigh), close android studio and then right click on android studio icon and select 'Run as Administrator' from 'more' menu.
Build again.
You can run Android Studio as Admin.
I hope it will help you.
To Do So :
Right click
choose Run as Administrator
Best regards,

Android Studio DDMS can't open /data folder in an emulator phone

I recently created an Emulator device with Android Studio,but only to find that I can't open the /data/data folder to get the sqlite db file.The folder just can't open,I have tried to use shell scirpt to chmod the /data directory,but it says the su command not found.
The Emulator
Can't open!
Is there anyone has the same problem? Or I have to root the Emulator?
But it's an Emulator! I just think it's kind of inconvenient to root a Emulator!
Update
Can't remember whether it's from Android Studio 3.0 or later but if you have downloaded AS 3.3+, you'll find the tab on bottom right corner called Device File Explorer, which lets you to see and easily get the data of your app without rooting.
Opening as Administrator didn't help but rooting the phone did worked, and no I'm not lowering my SDK version.
Open cmd and go to C:\Users\{User}\AppData\Local\Android\Sdk\platform-tools or to the folder location and type cmd at the address bar.
Whether you're super user or not can be determined by $:
C:\{User}\...\platform-tools>adb shell
generic_x86:/ $ exit
To have su/root privileges type adb root and exit:
C:\{User}\...\platform-tools>adb root
generic_x86:/ # exit
Next run the Android Device Monitor to extract the data.
To turn off root type adb unroot.
Even after running Android Studio as administrator if you can't access data/data folder, try using API 23 or lower for you emulator device.
Using Android Studio 3.1.2 and DDMS is no longer available under the Tool options. Instead Android Studio has the "Device File Explorer" tab available on the bottom right (I know why put it there).
Click on the "Device File Explorer" tab and select the Android Device you want to explore. To actually access the files, make sure USB Debugging is turned on in the AVD.
If that doesn't work, you'll need to use Terminal panel.
Change the folder permission through adb shell (using chmod command)
Pull the file using
"adb pull". See example:
C:\Users\B\AppData\Local\Android\sdk\platform-tools> adb pull /data/data/com.example.b.expensewatcher/databases/myexpenses.db
/data/data/com.example.b.expensewatcher/databases/myexpenses.db: 1 file pulled. 3.3 MB/s (24576 bytes in 0.007s)
For more details on changing folder permissions see: https://www.dev2qa.com/android-device-monitor-cannot-open-data-folder-resolve-method/
open DDMS with administrator previlledges. Had same issue and it solved it.
Fastest means to doing this is opening android studio with administrator previledges and opening DDMS from there.
otherwise, have a look at this link Android device monitor
Instead of rooting your android phone, you can access the data folder from android studio by opening 'device file explorer' which is to the bottom right corner of your IDE.
Open 'data>data>packagename>databases' you can save the database files but this will be in the encrypted form. You can directly access it from the file explorer on your PC.
Install DB Browser for SQLite and select option 'open database.'
Connect your android device and enable 'File Transfer'. Go to the directory where your android studio has been installed i.e., in my case documents. Then,
C:\Users\prana\Documents\AndroidStudio\DeviceExplorer\xiaomi-redmi_note_4-164594b\data\data\com.android.packagename\databases
You can find your databases here.
Hope it helps!
Use adb to root the emulator device. Once that is done, you will have permission to access the data\data folder
adb shell
su
The adb tool will be present in Users\\AppData\Local\Android\sdk1\platform-tools
Open cmd, change directory to above folder and enter the above code
Restart Android device monitor (if needed)

Android app is not launched in emulator in Android studio

I created an app in Android studio. It builds and runs on my phone but, When i run emulator it runs and shows the phone.
The output:
emulator: WARNING: Crash service did not start
qemu-system-i386.exe: -drive if=none,index=1,id=cache,file=C:\Users\one\.android\avd\Nexus_5_API_23_new.avd/cache.img: could not open disk image C:\Users\one\.android\avd\Nexus_5_API_23_new.avd/cache.img: Could not open 'C:\Users\one\.android\avd\Nexus_5_API_23_new.avd/cache.img': Invalid argument
How to fix this?
It may be bad, but it´s working for me:
First, go to your SDK folder (i.e. %localappdata%\android\sdk)
Open the "tools" folder.
There you find an "emulator-crash-service.exe" file. Copy it to the same folder and rename it to "emulator64-crash-service.exe".
Go back to the SDK Folder and go to the subfolders "extras\intel\Hardware_Accelerated_Execution_Manager\" and launch the "intelhaxm-android.exe" to install the HAXM driver manually.
Now create a new AVD and it should start.
I solved this problem by:
- redownloading Android x86 image (64bits/api23/google_apis in my case)
- creating a new virtual device and choosing Nexus 5 instead of Nexus 4
I'm not sure if all steps are required.

Sign Application in Android Studio

I am a web developer and I recently decided to learn how to build apps in Android, using the first-party IDE Android Studio.
I spent a few days designing a tutorial app, which I managed to run in an emulator, and then I've been programming and designing the layout for my own app.
However, I've been running into a problem when I try to test the app.
Waiting for device.
Target device: emulator-5556 (Nexus7_2) Uploading file
local path: C:\{file_path}\{app}-release-unsigned.apk
remote path: /data/local/tmp/{app_name}
Installing {app_name}
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/{app_name}"
pkg: /data/local/tmp/{app_name}
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
By looking up this error online, I've figured out that I need to sign my app, but I haven't figure out a way for this to work in the case of Android Studio. Modifying the ant build.xml file doesn't work and other methods of signing don't seem to work either.
There is an option to Generate a Signed APK, and I exported an app that was signed. However, I cannot seem to put that apk into my emulator.
If there is anyone more knowledgeable about how to use Android Studio, I would appreciate the assistance in how to sign my apk with the software. Thanks.
Output from Tutorial App
I copied all the code that wasn't included with the new project. This application does work in the emulator.
Waiting for device.
Target device: emulator-5556 (Nexus7_2)
Uploading file
local path: C:\{file_path}\QuoteReader-debug-unaligned.apk
remote path: /data/local/tmp/{app_name}
Installing {app_name}
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/{app_name}"
pkg: /data/local/tmp/{app_name}
Success
Launching application: ...quotereader.MainActivity.
DEVICE SHELL COMMAND: am start -n "...quotereader.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat= [android.intent.category.LAUNCHER] cmp={app_name}/.MainActivity }
I have found that if you delete the app on your phone then it should work when you run it again.

Resources