Sign Application in Android Studio - 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.

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

React Native Could not create ADB Bridge Error

JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Download https://jcenter.bintray.com/com/facebook/react/react-native/0.20.1/react-native-0.20.1.pom
....# a bunch of downloads here
:app:assembleDebug
:app:installDebug
05:13:20 E/adb: Unable to obtain result of 'adb version'
:app:installDebug FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:installDebug'.
com.android.builder.testing.api.DeviceException: Could not create ADB Bridge. ADB location: D:\Android\sdk\platform-tools\adb.exe
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I'm using Windows machine and the android studio and have followed the tutorial over at
https://facebook.github.io/react-native/docs/getting-started.html
I'm stuck at this as i cannot run the 'react-native run-android' on command prompt
Also, running adb version gives
Android Debug Bridge version 1.0.32
Revision eac51f2bb6a8-android
I have solved this problem ..if you are using emulator then follow React-Native, Android, Genymotion: ADB server didn't ACK... if you are using your device over usb for development then it is an error of your adb path.. set the path to D:\Android\sdk\platform-tools... in pc properties->advanced settings->environment variables->system variables..it worked for me.
I have another solution, If you are using emulator then make sure its running before you start you react native app. Some time you may need to close the application(like skype) those are using same port:8081(default used by react native application) before running react native app.

The APK file /Users/...../app/build/outputs/apk/app-debug.apk does not exist on disk

When I'm trying to test my android application on my android phone I get an error saying:
The APK file /Users/..../app/build/outputs/apk/app-debug.apk does not exist on disk.
Error while Installing APK
Also my Event logs are:
3:21:33 AM Gradle build finished in 57s 37ms
3:21:33 AM Session 'app': Error Installing APK
But I can clearly see the file /Users/..../app/build/outputs/apk/app-debug.apk after run and also my device is successfully connected in usb debugging mode on.
I'm using android studio 2.2
I have tried The APK file does not exist on disk all these methods too but it doesn't help me out in my case.
Also if I choose installDebug in Gradle properties (:app-->install-->installDebug) while running then app automatically get installed on my device, in that case my Event logs are:
3:25:02 AM Executing tasks: [installDebug]
3:25:12 AM Gradle build finished in 10s 70ms
Desperately looking for help, thanks.
I personally am not familiar with Android Studio, but did you try refreshing the page and trying to build the APK again? You could also maybe double-check if the file saved to a different folder.

Android Studio Adb Transfer Protocol Error

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

Android Studio Application doesn't start

I switched from Eclipse to Android. After a whole time all works. But:
If I'm click on RUN, the app won't start. I test with a real device. If I'm removing the App from the device and click on run, the app will be installed, but that was all. I have to click on it to open it.
I added a Android Application in my Run/Debug Configurations.
What I'm doing wrong?
EDIT:
Here is my Console-Output:
Waiting for device.
Target device: samsung-gt_i9100-000e3cc647f8cf
Uploading file
local path: myApkPath
remote path: remotePath
Installing application
DEVICE SHELL COMMAND: pm install -r "remotePath"
Make sure that in your build configuration, under 'General'->'Activity' you have selected Default Activity.
If you want to run a non-default Activity, it will have to be marked exported=true in AndroidManifest.xml.

Resources