When I want to compile a released version of my app, I sign it and rename the apk file to include a version number in the filename. To launch the app on my device I use adb. Is there a way this can be done in Eclipse?
Another related issue: If I press Run (Ctrl-F11), Eclipse will compile my apk and run it on the device. If my project is called "My App", the file "My App.apk" gets generated. It would be nice if I could get Eclipse to generate a filename that has the same filename as my released version and then maybe Eclipse would also install it with the Run command. Is this possible?
You could achieve all that is mentioned in your question using Ant. You can also run an Ant command from Eclipse.
The following resources would be helpful:
Using Ant to automate building Android applications
Building and running from the command line
This not currently customizable in Eclipse. If you need to automate it, use Ant. You can then start Ant tasks from Eclipse as needed.
A suggestion to make the command line option easier...
Create a top level directory. Copy adb.exe, AdbWinApi.dll and AdbWinUsbApi.dll into this, plus .apk. Then you can do this...
C:\Users\your_username>CD top
C:\Users\your_username\top>adb -d install yourapp.apk
Related
The docs at https://facebook.github.io/react-native/docs/running-on-device.html make no mention of installing the android sdk. It simply states I should get the adb which I got from developer.android.com/studio/releases/platform-tools.html. now when I try this:
C:\Users\username\Documents\host\Node\worship_app>adb install com.app_name PACKAGE
I get the error "adb: usage: need APK file on command line". So I try the react native route instead with
react-native start
which outputs one message forever: "Loading dependency graph, done."
So I go to another cli window and enter
react-native run-android
After saving the file local.properties in the android subfolder. That's when I get the error " The SDK directory 'C:\Users\nmeri17\AppData\Local\Android\sdk' does not exist.", which in all fairness does not exist. I guess it should be there if I've got android sdk installed but since it's not in the docs, I'm guessing there's another way to go about it. I've squandered all my bandwidth on this folder they downloaded when I ran react-native run-android the 1st time; I was redirected to http://services.gradle.org/distributions/. The folder is still there along with the unpacked zip, along with the thousands of dependencies they also downloaded when I ran create-react-native-app AwesomeProject. I realized what was happening to my bandwidth very late and shut it down but most of the files are still there. Can they be of any use to me? I just want to package the snippets from https://reactnavigation.org/docs/intro/quick-start, setup, see what it looks like and start my personal project based on what I've studied. Is there no way to achieve this without installing the gigantic sdk (which i can't even afford)? Many thanks.
Install Android SDK, it is better to install Android studio it will install all required tool, like ADB, google services etc.
then make sure android studio and java is set to environment path.
then setup all keys and run
react-native run-android --variant=release
My question is when i click on run button it runs gradle command to check change files and build class and then dex to create apk.
If i know there is no change in my files still gradle runs to check.
As i have many libraries attached to my app module to reduce run time. if anyone knows to install apk in device from android studio without running gradle.
Note : I want to install on device which is connected to my system not to emulator,etc.
Note : I want to install from android studio not by using any other software.
One more solution is using terminal to install apk on devices.
Once you have built your APK using the File>Build APK, it shows you the path in which new apk is present.
Just go to the path on terminal like below
generated apk path on my system -$cd /Android_App_Code/UpdatedCodeForCheckOut/Projects/IMS/source/apps/Android/flowtalk/app/build/outputs/apk
and type -$ adb install -r app-debug.apk
this command just installs the build on your connected device.
and now every time when there is no change in code, just run install command on terminal. It's super fast you will see.
You can't skip a Gradle build unless you want a constant APK that has no changes.
Go to File>Build APK. Then, Gradle will build once. After that, a bubble at the top-right corner will appear indicating a successful APK generation.
Click "Show in explorer", copy the generated APK and move it to your connected device. Then, go on your device>Your File Manager>The APK you just moved. Click it and install the application. There you have it.
There is no way for you to run without a Gradle build, and you're not the only one who thinks it is utterly STUPID for a force rebuild every time you want to build an APK or run an app with no changes since the last build.
I use this method to install the generated APK to the device using bash script since I'm working on Linux(didn't try this on windows or os x).
When you run the app in the android studio the run tab will print out the commands which android studio uses to install the app on the device.
I just copy these commands into a file and save it as run.sh
run.sh
#!/bin/sh
adb push /home/gautam/sample/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/com.example.sample.sample
adb shell pm install -t -r "/data/local/tmp/com.example.sample.sample"
adb shell am start -n "com.example.sample.sample/com.example.sample.sample.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
save the file in you project directory(although you can keep it any where).also add it to you gitignore if you need. Then open you terminal in android studio and run the script file to install the APK.
chmod a+x run.sh
./run.sh
This will install the apk to the connected device. If more then one device are connected the script will throw error in which case you will have to provide the device id refer this.
Hope this helps.
Generate apk (gradle build)
Select generated apk in the project tree
Right-click to .apk -> install APK
via plugin: install apk
Actually you can.
Just create a new Run/Debug configuration (Edit configuration on the drop down list on the left of the "Run" arrow). Then remove "Gradle-aware Make" in the "Before launch" section of your configuration.
To run this configuration you need to have an existing APK generated otherwise it doesn't work, as this new configuration will just install the existing one.)
For people who use Flutter, Do as the following instruction.
Connect your Android device to your computer with a USB cable.
Enter cd where is your application directory.
Run flutter install.
Flutter: Install an APK on a device
There's a much easier way now.
Windows:
To install an App that you you have the APK file for:
Start the Device Emulator.
Drag the .apk file onto the emulator.
EOL
In Android Studio 2.2 there is a new property "build cache". To install it you open gradle.properties file of your project and add there:
android.enableBuildCache=true
like described here
And if you have no changes, your gradle will build in few seconds.
EDIT: Description of Build Cache from here:
Android Studio 2.2 Beta 3 introduces a new build cache feature that can speed up build times (including full builds, incremental builds, and instant run) by storing and reusing files/directories that were created in previous builds of the same or different Android project.
In other words, Build Cache reuses unchanged files rather then rebuild them.
If you haven't changed anything on your files and it's not the first time you run the app on the device, you can navigate to the app on your device and open it from there. If your device is connected to your computer, you would still be able to access logcat of the app.
If the modifications you've done is on an existing file, like the layout or .java file or any file that already exist, you can simply click on the apply changes button which is besides the run button as shown:
The apply changes button to the right of the run button in android studio
works with android 3.0.1 and later.
If you've added any new resources or created a new java file or new activity, the you must run from scratch to rebuild the hgradle.
Just create new configuration "install" with Launch Options -> Launch: Nothing
I want to test my app and I don't want to run emulator, unfortunately Windows 8.1 doesn't recognize my Samsung device. I want eclipse just to build the app's APK and I'll test the app by myself by using the file that is created in bin directory.
when you don't have any compatible emulator or any connected device, eclipse asks for running new emulator, I don't want see this dialog !
First: Consider fixing the problem with Windows recognizing your phone.
Second: You can use the Android SDK to make an APK - you can then transfer it to the device the way you prefer (download from webserver, e-mail eg.). Alternatively you can use Google Play + the alpha/beta testing feature to roll out tests to your device (+ any other device you want to test on).
In that case, Only Build the project, then in your project directory look for "bin" folder, you will find an APK file of your project there, you can copy that and install it later on your device
Hope this helps
Unfortunately, building the project alone won't create an APK file. You can export your project to get APK file. For exporting, right-click on your project in Eclipse and select Export..., then choose Export Android Application:
Please note that you have to create a key to export your project and sign it. If you want to create an unsigned package (which must be only used for testing purposes), right-click on your project, then from Android Tools select Export Unsigned Application Package:
You can get the application in the bin folder there you can find the apk.
You can build by running the command "ant clean release install" from your application folder.
On ecllipse editor try this:
go to Windows -> Select Preferences
then Android -> Build
Now uncheck "Skip packaging and dexing until export or launch. (Speeds up automatic builds on file save.)"
You may need to restart ecllipse.
I've been planned to develop an Augmented_Reality(AR) application in an android. So I've gone through various of contribution installing a libraries in eclipse(IDE) like artool,qcar sdk and so on, then I've found that NDK installation should be made before getting into artool kit or qcar sdk So I started to install NDK and progressed as they said in below link:
http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/
after doing 'Cygwin' installation they wrote to write 'make -v' in console. Hhen I did I got 'GNU make 3.82.90' but theirs is 'GNU make3.81' as:
where it wasn't as same mine. I know that am using updated cygwin but my problem is I can't able to get .so file as they mentioned accordingly in eclipse. So could you tell me, where I made junk and how can I recover to run AR application in eclipse. Thank you!
actually if you are using window then you do not need to install cygwin. you can also run your project with cmd prompt with following command
start>cmd>cd C:\demoworkspace\testingndk>enter
in Command prompt This is my directory where my project is located with project name. after this
run the ndk address like
C:\demoworkspace\testingndk>C:\ndk-path\ndk-build
ndk-path is directory name where your ndk is located. this will automatically pick your jni c file.
for ndk related query please write me at kdeepak5477#gmail.com
When you are installing cygwin (I used a wizard) make sure you open the DEVEL tree and install MAKE (binary is fine, no need for source).
I also get all the GCC and MINGW stuff just in case.
Perhaps uninstall cygwin, and reinstall using the wizard and ensure MAKE is selected from DEVEL tree.
I can debug/run my Android app via Eclipse and I can export out an obfuscated/shrinked .APK.
However, in order to test the my "Release/Exported" .APK builds, I'm having to manually copy them to my phone (after enabling Disk mode) and install them from there (after disabling Disk mode).
As you can see, it's quite a faff! :o(
Is there not a quick way of "running" a release build after you've exported it via Eclipse?
Thanks!
I suppose easiest way is too, what i do generally for my projects, is creating batch files to compile project, but here in eclipse we have easy way by simply exporting project. and once .apk is ready we can connect device and run batch file with following cmnd :
install_to_device.bat :
cd YOUR_Android_PATH\platform-tools\
adb install [-r] [exported_apk_path]