Update Flutter App on Android with `flutter install` - android

So I have an App almost finished, which uses a json file located in the documents path of my android device (using the path_provide package). I know that this file will get deleted as soon as I uninstall the app on my phone. For installing the app onto my phone I want to use the command line flutter install (I'm on Windows). So if I add more features to my app and flutter install again on my android, will it update the device leaving the documents directory just as it is or will it delete that and completely reinstall the app?

I don't think that it's going to delete the app and the file.

I found a solution: If you don't already have it installed, then install ADB and on Windows you then must add the folder with ADB to your Path environment variable, so you can easily access it through cmd on Windows (I don't really know about the other platforms). Then you have to create your APK (for example with flutter build apk --split-per-abi) and then run adb install /path/to/your/apk/file.apk.
Source: mannprerak2's comment on this Github issue https://github.com/flutter/flutter/issues/40560

Related

Android emulator on Ubuntu

I want to launch the React Native application on Android emulator using Ubuntu 16.04. Following the react native docs it should be dove by running
react-native run-android
OR
npm run android
Both these commands are not working without sudo for some reason, but that's not an issue. The issue is when I run them every time I get the same error:
Error running adb: No Android device found. Please connect a device
and follow the instructions here to enable USB debugging:
https://developer.android.com/studio/run/device.html#developer-device-options.
If you are using Genymotion go to Settings -> ADB, select "Use custom
Android SDK tools", and point it at your Android SDK directory.
I don't want to connect device via USB and I don't use Genymotion, I just want an emulator. I tried to run the project via Android Studio, but faced with another issue :
Error: please select Android SDK
I tried syncing the files, removing the project, restart the studio - nothing. (However I can see the Nexus 5X in the devices list and even start it)
Please someone help me, I've tried everything I could find - nothing helps
Both these commands are not working without sudo for some reason, but
that's not an issue.
Probably, this is the root cause.
Because, if you have ever installed your Android SDK / Tools using "sudo" or you installed it into the directories of root user, then those files may not be accessible or executable by a normal account. So, try below steps:
Delete the hidden dirs ~/.gradle ~/.idea ~/.m2 and ~/.android using command
sudo rm -rf ~/.gradle ~/.idea ~/.m2 ~/.android.
This step is to clear up your previously installed files with root previlige. If you don't have those folders, ignore this step.
Re-install your Android Studio into your normal user home directory, e.g. ~/android
Create your AVDs using the newly installed Android Studio.
Don't use any "sudo" for your newly configured environment. Because anything installed with root privilege will go to root directory, i.e. /, but not your normal user home dir, i.e. ~/. If you start your Android Studio with a normal user, usually, it will only be able to refer to your setups under ~/. This is probable the reason for not being able to find your "installed" Android SDK.

How to simply install apk in device in Android Studio

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

How to install an apk on the emulator in Android Studio?

How do you install an apk on the emulator in Android Studio from the terminal?
In Eclipse we did
/home/pcname/android-sdks/platform-tools/adb -s emulator-5554 install /home/pcname/Downloads/apkname.apk
Now how about in Android Studio?
Run simulator -> drag and drop yourApp.apk into simulator screen.
Thats all.
No commands.
EDIT: Even though this answer is marked as the correct answer (in 2013), currently, as answered by #user2511630 below, you can drag-n-drop apk files directly into the emulator to install them.
Original Answer:
You can install .apk files to emulator regardless of what you are using (Eclipse or Android Studio)
here's what I always do: (For full beginners)
1- Run the emulator, and wait until it's completely started.
2- Go to your sdk installation folder then go to platform-tools (you should see an executable called adb.exe)
3- create a new file and call it run.bat, edit the file with notepad and write CMD in it and save it.
4- copy your desired apk to the same folder
5- now open run.bat and write adb install "your_apk_file.apk"
6- wait until the installation is complete
7- voila your apk is installed to your emulator.
Note: to re-install the application if it already existe use adb install -r "your_apk_file.apk"
sorry for the detailed instruction as I said for full beginners
Hope this help.
Regards,
Tarek
For those using Mac and you get a command not found error, what you need to do is
type
./adb install "yourapk.apk"
Start your Emulator from Android Studio Tools->Android-> AVD Manager then select an emulator image and start it.
After emulator is started just drag and drop the APK Very simple.
Just drag APK file to android emulator it will install automatically.
In android studio emulator to run an apk file just drag the apk into the emulator.The emulator will install the apk
Much easier is just to start your emulator, then go to sdk/platform-tools and use adb from there to install apk. Like:
adb install xxx.apk
It will install it on running emulator.
Drag and drop apk if the emulator is launched from Android Studio. If the emulator is started from command line, drag and drop doesn't work, but #Tarek K. Ajaj instructions (above) work.
Note: Installed app won't automatically appear on the home screen, it is in the apps container - the dotted grid icon. It can be dragged from there to the home screen.
For Linux: once emulator is running, the following worked for me.
Because I installed the Android SDK on my home directory, I have the following file structure:
home/Android/Sdk/platform-tools/adb
home/AndroidStudioProjects/Metronome.adk
AndroidStudioProjects is a file folder I made for my Android projects. "Metronome.adk" is the file I want to run.
So, using Terminal from the home directory...
./Android/Sdk/platform-tools/adb install ./AndroidStudioProjects/Metronome.adk
Being a Linux novice, I often forget the need to put the "./" in when trying to locate a file or run a command.
After the command achieves "Success", the app is in the Apps area of the emulator and can be run.
When you start Android studio Look for Profile or Debug apk.
After clicking you get the option to browse for the saved apk and you will be able to later run it using emulator
If Android Studio is already open:
Click on File you can find Profile or Debug apk in this menu too
Just download the apk from talkback website
Drag the downloaded apk to the started emulator, Go to settings on emulator > Search for talkback, you will now find it there
1.Install Android studio.
2.Launch AVD Manager
3.Verify environment variable in set properly based on OS(.bash_profile in mac and environment Variable in windows)
4. launch emulator
5. verify via adb devices command.
6.use adb install apkFileName.apk
Upload your apk file on the cloud , then make a direct download link for downloading and then copy that link and paste it on the emulator browser for download it :) ;
In Android Studio: View - Tool Windows - Gradle
In the Gradle tool window navigate to your :app - Tasks - install
and then execute (by double-clicking): any of your install*tasks: e.g. installDebug, installRelease
Note: the apk will also automatically installed when you Run your application

Application not installed in android error

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

How to make an EXE file using .apk file

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.

Categories

Resources