I am developing an ionic app. And I want to emulate it on real Android device. I already downloaded the Android Studio. I plugged my Android device and when I tried to run this command ionic cordova run android There's a lot of errors.
Note: I am on Windows 8.1 32bit. JDK 32 bit.
This is for an academic thesis.
This is the error:
Have you enabled usb debugging on your device? You'll have to enable developer mode on your Android. Google can tell you how, but you just go to settings/about/build number, tap 7 or 8 times... Then, you should be able to use ionic run android --device. That should build out to emulate so long as you've installed the Android sdk.
It can be solved by removing platforms, then add again.
ionic cordova platform rm android
ionic cordova platform add android
if above solution does not work please run following command,
ionic cordova run android --livereload
If still problem persist,run same command with --verbose options,
ionic cordova run android --verbose
Alternatively , and way faster , you can build your app then drag/drop it inside the emulator (running aside)..it will install quicker and run sleeker.
And you'll have peace of mind , I know this is not what you're looking for ,but still a nice hack if you're time-bound.
I already solved my problem! As we can see in the error that I posted, it is the gradle file! It is corrupted download. What I did is delete the .gradle folder and run ionic cordova run adnroid. In that way, it will automatically download the gradle file! Thanks for the replies by the way!
Related
I have an Ionic 4 mobile app project and have been previously been testing with with ADB with Android Studio. I can successfully run/build and install onto my android device. However, no changes I make in the code take affect when I view the app on my device.
This link was the closest I could find to my issue: Android studios doesn't update app on mobile device't-update-app-on-mobile-device/38919601
I have tried to Build > Clean Project in Android Studio but it hasn't worked for me.
This is my first question on here so any tips on how to improve my ability to ask would be much appreciated :)
Your suggested link having a solution. Try Re-build the Gradle.
Do build->Rebuild project then run it.
To be sure you are on right project :).
I needed to run an ionic build before running npx cap add android and npx cap open android
I'm trying to run a blank app of ionic 4 on my android 9 device. Already followed each step on the website and running it on browser is okay.
When I run it on my device here is what i get:
Error when running
It says I dont have gradle and android studio but here is my environment:
android sdk list,my /etc/environment,and my npm, ionic, gradle and java versions
Am I missing something guys?
This error occurs when gradle is not properly installed. I have experienced this before. try installing gradle on your system.
For some reason the ionic project does not locate the gradle, to verify that this is the case, try opening the project on android studio and you will get the warning that no gradle wrapper was found.
IDK if some of you people have the same problem, but it's because of the Gradle. Installed it the way the website said, tried both automatically with SDK manager and also the manual downloads. Still no. So I installed it using:
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle
Then find location where it was installed then add to path. Now I can install the app on my device
Your question is not clear, are you facing error on local emulator or real mobile device?
it seems you are trying to run on local android emulator, can you please mention that where you are facing error?
Also, please do debug or production build with the help of ionic cordova build android command and try to run on your android device, generally android studio will pops up of gradle build update, which will help to generate faster sequential android build, and which needs gradle for it.
I have installed ion2-calendar in my ionic application using npm install ion2-calendar moment --save and i have made some changes on its files located in node_modules/ion2-calendar/dist/components/month.component.js, i have added (panEnd) and (panStart) in its dates.it is working good using ionic serve and ionic cordova run android.but the events are not working when we make build usinng --prod option like
ionic cordova run android --prod
the build was successfull and we can run the app on mobile,but the added event does not works.is there anything we need to do to add this changees in production build?
I had the same situation but I solved this doing this step and rebuilding the project for production.
try production build commands
after removing local page module file (i.e login.module.ts) of each of your page!
I mean do this
To
NOTE!! if that does not work for your do post your logs by testing your device logs using
CHROME DEV tools. you can inspect device logs there using
chrome://inspect/#devices
make sure you are using ADB drivers for your android on your machine!
you won't require this for IOS though you can directly check your log commands in XCODE Console!
I am new to Ionic and Android programming, so I am sorry if there are any inconveniences.
My problem is that I can't see my app (default app in tutorial) on the emulated android virtual device. It just shows a stock android phone basically after I run ionic emulate android. So I assume the app wasn't installed on the emulator.
It builds the apk but doesn't do anything with it it seems.
I think I installed everythink correctly:
> duc#duc-ThinkPad-T450s:~/myApp$ ionic info Your system information:
> Cordova CLI: 6.0.0 Ionic Version: 1.2.4 Ionic CLI Version: 1.7.14
> Ionic App Lib Version: 0.7.0 OS: Distributor ID: Ubuntu Description:
> Ubuntu 14.04.4 LTS Node Version: v4.4.1
I hope you could help me out, just wanted to get the tutorial going :)
Greets, Duc
Edit:
I finally managed to install the apk manually to the emulated device
using this command:
adb -s <your emulator> install </your/apk/path>
However installing it manually is very inconvenient and annoying.
Anyone has a solution for this?
Problem solved!
You have to write in the commandline:
android avd
Then a menu pops up and you have to create your own avd, then start it
Then you need to open a new terminal (ctrl+alt+t).
Cd to the right path of your app.
Now ionic emulate android should work.
You can also use third-party emulator like Genymotion (which works much faster).
Use ionic build android and just drag build APK /platforms/android/build/outputs/apk/android-debug.apk to Genymotion emulator.
in case that i need to test cordova on app i must do this:
Run cordova build android
Go into android ADT (Eclipse)
Clean the project
And then run from eclipse on device.
Exist some less time consuming plugin or script for this?
Thanks for any advice.
You should be able to just do
cordova run android
from the command line. See here: Cordova Command Line docs