Cannot emulate app

Post your new ionic info now please.
Please also create a project with ionic start and try to emulate that one and see if that works.

OK, we have some fighting going on in there. For starters, please change the following:

@angular/core => bump to 4.1.3
@ionic-native/ad-mob => goodbye
angular => RIP
ionic => sayonara

Afterwards, vaporize node_modules and try running npm i again.

That is actually fine with current installations. It’s the most recent version.
For the rest: Yep.

1 Like

Ah, that’s the local CLI, then? I mistakenly thought it was an old artifact. The package naming is confusing.

1 Like

C:\myApp>ionic info

cli packages: (C:\myApp\node_modules)

@ionic/cli-utils  : 1.10.2
ionic (Ionic CLI) : 3.10.3

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.0.0
Cordova Platforms  : none
Ionic Framework    : ionic-angular 3.5.0

System:

Android SDK Tools : 25.2.5
Node              : v8.5.0
npm               : 5.3.0
OS                : Windows 10

I then ran ionic cordova run android after using ionic start in a separate directory and got:

C:\Test>ionic cordova run android
[INFO] Running app-scripts build: --platform android --target cordova

[17:10:26] build dev started …
[17:10:26] clean started …
[17:10:26] clean finished in less than 1 ms
[17:10:26] copy started …
[17:10:26] transpile started …
[17:10:30] transpile finished in 3.35 s
[17:10:30] preprocess started …
[17:10:30] deeplinks started …
[17:10:30] deeplinks finished in less than 1 ms
[17:10:30] preprocess finished in 2 ms
[17:10:30] webpack started …
[17:10:30] copy finished in 3.78 s
[17:10:37] webpack finished in 7.54 s
[17:10:37] sass started …
[17:10:39] sass finished in 2.14 s
[17:10:39] postprocess started …
[17:10:39] removed unused font files
[17:10:39] postprocess finished in 6 ms
[17:10:39] lint started …
[17:10:39] build dev finished in 13.11 s

ionic cordova prepare android
cordova prepare android
Discovered plugin “ionic-plugin-keyboard” in config.xml. Adding it to the project

[17:10:44] lint finished in 4.59 s
Installing “ionic-plugin-keyboard” for android

cordova run android
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_131
Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio

[ERROR] An error occurred while running cordova run android (exit code 1).

Weird error because I have android studio installed, and it worked before. Don’t remember messing with the installation.
Also, can I just change those lines in package.json? (for example, just delete the @ionic-native/ad-mob line? what if I’m using that plugin??)

Yes, although clearing node_modules and running npm i after modification is required for it to take effect.

The other @ionic-native/admob-free you have should be sufficient. The ad-mob one is old, and responsible for both your messed-up @angular/core and all the other whinging about peer dependencies you mentioned earlier.

Okay, great, now the only problem is that I’m getting an android error. Should I reinstall Android Studio or is there a faster way to fix this?

C:\myApp>ionic cordova build android
[INFO] Running app-scripts build: --platform android --target cordova

[17:37:39] build dev started …
[17:37:39] clean started …
[17:37:39] clean finished in 15 ms
[17:37:39] copy started …
[17:37:39] transpile started …
[17:37:43] transpile finished in 4.13 s
[17:37:43] preprocess started …
[17:37:43] deeplinks started …
[17:37:43] deeplinks finished in 101 ms
[17:37:44] preprocess finished in 517 ms
[17:37:44] webpack started …
[17:37:44] copy finished in 4.87 s
[17:37:54] webpack finished in 10.09 s
[17:37:54] sass started …
[17:37:57] sass finished in 2.59 s
[17:37:57] postprocess started …
[17:37:57] removed unused font files
[17:37:57] postprocess finished in 16 ms
[17:37:57] lint started …
[17:37:57] build dev finished in 17.44 s
ionic cordova prepare android
cordova prepare android

[17:38:01] lint finished in 4.96 s
cordova build android
× Running command - failed!
[ERROR] An error occurred while running cordova build android (exit code 1):

    ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk\
    JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_131
    Error: Could not find an installed version of Gradle either in Android Studio,
    or on your system to install the gradle wrapper. Please include gradle
    in your path, or install Android Studio

Sorry, but our environments are just too different for me to say anything beyond the error message. I’m on Debian, with the android sdk installed via CLI and gradle via apt-get.

Alright, well, I pretty much got everything working. Thanks, both of you!

If the Android thing is still bugging you, run ionic cordova requirements to get more information. Make this command happy (by reinstalling Android Studio for example).

I had to reinstall gradle and it started working. Not sure what messed it up, but I’m glad it’s working. Thanks again, everyone!

1 Like

Because of all the building issues I faced with iOS and Android I now just use the ionic Pro service to create my builds. I used its predecessor and before that PhoneGap Build - you don’t need any jvm / gradle / android studio stuff on your computer - and if using a mac… well the less said about xcode the better.

Give it a try - after a little knifing and forking I suspect you’ll find a MUCH easier workflow.