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]
Related
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 have made application in Netbeans7.1.2 .
my application working perfectly in emulator which is configured android 2.1 but after copying bin folder in Android device(tablet) that gives error "Application not installed".
what is this problem plz if someone know about this ?
Copying bin/ folder is not sufficient enough to warrant an install.
You can do it this way:
Use the Android's SDK tool called adb to install it directly on to the device. For example, suppose your package-name in your project is called org.foo.bar.app and an apk file is generated and called foobar.apk (This will be found in the bin/) folder typically, or where you specify Eclipse to generate the apk, via from within Eclipse:
Right click on project
Click on Android Tools
Click on Export the unsigned Application Package
OR
Click on Export Signed Application Package.
Then:
Plug in cable to device, and issue the command from within Windows Cmd or Linux Terminal, in this manner, adb install foobar.apk
To uninstall an app from the device, specify the package-name, like this adb uninstall org.foo.bar.app
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
am almost done with my project in android, now I want to make the executable version of the application.
I need to demonstrate it in .exe form as soft app as on emulator, not by built and debug process from eclipse.
what the op is asking for is simple - he wants to create a MS Windows program file that runs just like the APK he's made.
Unfortunately this cannot be done. The only way to 'show off' your program is as people have stated:
Through the emulator on Windows
On an acual device (Once installed, you can disconnect the device from the computer and use it like a normal app)
You can't convert an APK file into a .exe file. APK files hold Android apps as self-installable files already - opening an APK file on a phone or the emulator will start the installation process. It sounds like you just want to sign the app with a 'proper' key rather than using a debug key. To do that, read the official page on signing apps.
You don't need to create a .EXE file for doing what you want. You can just create a bat file that executes adb commands that will: install and start your application in the emulator. I guess, the problem here is that you don't understand how the APK files work... I'm just saying.
OK... in order to install an Android application using adb (which is basically what Eclipse does in the background) you need to do this:
adb install path/name_app.apk
Then, you can start the application by using adb shell am command. You can find info here: http://pdk.android.com/online-pdk/guide/instrumentation_testing.html
Another thing you have to take in account is that you will have to run the AVD before installing and executing your application: http://developer.android.com/guide/developing/tools/avd.html
All those commands you have to execute (may be using a .bat file as I mentioned before) are executables that you can find in the android-sdk\tools directory.
When I have a client that want's to show an app, at conference for example, I always use Bluestacks it's not perfect but it allows you to run android apps on your computer without doing all the technical stuff (like installing an emulator etc).
To install an app on your you computer using the Bluestacks device/emulator you simply click on the apk.
http://bluestacks.com/
Once you create a project/application in Eclipse then along with this you also have created the .apk file. Android can run .apk files, so go to the place where your project have been saved and open it, like this Open Project -->bin-->.apk.
Now send the .apk file to your android phone through Bluetooth or copy it.