Reputation: 7369
Hi I am Really happy to see that , ionic now supporting React Scripting , When i try to run the Ionic react apps in the real devices it shows some error which i could not resolve.
I have tried ,
ionic cordova run android
It will not support because ionic-react using the capacitor instead of cordova,
npx cap open android
It throws an error that "[error] Unable to launch Android Studio. Make sure the latest version of Android Studio is installed"
It says that need to open Android Studio, But what i have tried is to run the app in real devices
Is there any work around ?
Upvotes: 0
Views: 1937
Reputation: 815
npm i @capacitor/core --save-exact
npm i @capacitor/cli --save-exact --save-dev
ionic build
npx cap init YourAppName com.domain.yourappname
npx cap add ios
npx cap add electron
npx cap add android
npx cap open android
ionic build
npx cap sync android
npx cap open android
Upvotes: 1
Reputation: 21
You should let it open Android Studio.
It will open the "android" directory as an android project(that's what it is).
If you have your device plugged in and USB debugging available you should see your device in the IDE. Then just hit start app and you should get you app running on the device.
You can open the project manually from the IDE if you can't fix the
Upvotes: 0
Reputation: 935
Instead of using Cordova, I've been using Capacitor which works with Android. Try running;
ionic capacitor add
and select android
Running npx cap open android
should now open android studio.
If you want to see your app on a physical device (android or iOS) without android studio, you can download the ionic Devapp and run ionic serve --devapp
. As long as your PC and device are on the same WiFi network, you will be able to view the app as if it were installed natively.
Upvotes: 1