Ionic cordova run/build/emulate android not working


#1

When I do
adb devices -l I could see my Oneplus in the list.

Doing ionic cordova run android doesn’t open my app on my phone.
I also tried doing ionic cordova --device=<device_address> but that didn’t work also.

I also noticed that doing ionic cordova build android didn’t make an apk that I could copy and past over to my device so that I could manually install it.

Tried ionic cordova emulate android that also didn’t work,

Any idea on how to get this running?


#2

you tried ionic cordova run android --device --livereload ?


#3

remove and reinstall the android platform

ionic cordova platform rm android
ionic cordova platform add android

and if it still fails

edit,
project/node_modules/@ionic/app-scripts/dist/dev-server/serve.config.js
and change android exports line to read

exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'app/src/main','assets', 'www');

and in your app you need to check if cordova platform is ready

import {   Platform } from 'ionic-angular';

 constructor(... platform:Platform){

platform.ready().then(
				(readySource) => 
				{
					console.log(readySource+" Platform ready! there are "+platform.platforms().length+" platforms");
					for(let f of platform.platforms())
					   console.log("platform ="+f);
			   	if(readySource=='cordova')
			   	{	     	 
			   	 // now can call cordova based plugins
			   	}
			  }
}

#4

Yes I tried that already. Still didn’t work.


#5

Didn’t work. The app still doesn’t show up on my phone.

This what I get:

ionic cordova run android --device
Running app-scripts build: --platform android --target cordova
[11:48:13]  build dev started ... 
[11:48:14]  clean started ... 
[11:48:14]  clean finished in 35 ms 
[11:48:14]  copy started ... 
[11:48:14]  deeplinks started ... 
[11:48:14]  deeplinks finished in 517 ms 
[11:48:14]  transpile started ... 
[11:48:44]  transpile finished in 29.49 s 
[11:48:44]  preprocess started ... 
[11:48:44]  preprocess finished in 6 ms 
[11:48:44]  webpack started ... 
[11:48:44]  copy finished in 30.59 s 
[11:49:06]  webpack finished in 22.04 s 
[11:49:06]  sass started ... 
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[11:49:09]  sass finished in 2.65 s 
[11:49:09]  postprocess started ... 
[11:49:09]  postprocess finished in 61 ms 
[11:49:09]  lint started ... 
[11:49:09]  build dev finished in 55.30 s 
> cordova run android --device
Android Studio project detected

ANDROID_HOME=/usr/local/Caskroom/android-platform-tools/latest
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
studio

[OK] Your app has been deployed.
     Did you know you can live-reload changes from your app with --livereload?

[11:49:23]  lint finished in 14.23 s 

#6

Doing --livereload shows something like this.

Development server running!
     Local: http://localhost:8100
     External: http://192.168.1.58:8100

When opening the External url to my phone it gives me a series of messages…not sure what they are. But the app then crashes and never loads on my Chrome app.

Messages:

gap_init:3
gap:[null,"CoreAndroid","messageChannel","CoreAndroid1311606310"]
gap:[null,"CoreAndroid","show","CoreAndroid1311606311"]
gap:[null,"Device","getDeviceInfo","Device1311606312"]
gap:[null,"Keyboard","init","Keyboard1311606313"]

#7

its ionic not ioinc bro :joy: