0

I try to create ionic 2 app with below steps:

1- npm install -g cordova

2- npm install -g ionic

3- npm install -g typescript

4- ionic start sampleApp tutorial --v2

for serve and see in browser use this command :

ionic serve 

for build android apk file download jdk 8 and android sdk manager and install all api and set ANDROID-HOME and after use this command :

ionic platform add android

ionic build android

every things is ok and work very well but I want give GPS state and for this reason add cordova.plugins.diagnostic with this command :

ionic plugin add cordova.plugins.diagnostic

npm install --save @ionic-native/diagnostic

but after add diagnostic plugin and run ionic build android console give me error and build failed .I search in google and find this page :

Ionic android build fails, no matches found

and this pages :

https://forum.ionicframework.com/t/build-failed-android/38071/6

but I don't know how to solve this problem

my project and system info:

ordova CLI: 6.5.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 8.1
Node Version: v6.10.0
Xcode version: Not installed

<preference name="android-minSdkVersion" value="19" />
<preference name="android-targetSdkVersion" value="23" />
Community
  • 1
  • 1
Reza Mazarlou
  • 2,986
  • 4
  • 22
  • 31
  • does `ionic serve` work after adding plugin? – Suraj Rao Apr 17 '17 at 12:09
  • yes work in browser but give me cordova not available error in console that this error for "ionic serve disables all the cordova plugins, because it is not running on a device" – Reza Mazarlou Apr 17 '17 at 12:15
  • ok..any error logs on build failed? – Suraj Rao Apr 17 '17 at 12:16
  • Error: cmd: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'android'. > java.lang.NullPointerException (no error message) * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. – Reza Mazarlou Apr 17 '17 at 12:48
  • are you using ionic 2 or 3? more precisely ionic-native version... – Suraj Rao Apr 17 '17 at 12:50
  • I install ionic with npm install -g ionic and my info is => ionic -v : 2.2.1 and ionic-native : 2.9.0 – Reza Mazarlou Apr 17 '17 at 12:57
  • you can compare your package.json with the [starter app](https://github.com/driftyco/ionic2-app-base/blob/master/package.json) if you want..the docs generally are updated with that – Suraj Rao Apr 17 '17 at 13:02
  • in my package.json ionic-native/core is 3.4.2 but when use this command "npm info ionic-native version" in console give me 2.9.0 – Reza Mazarlou Apr 17 '17 at 13:14
  • can you show your package.json? maybe you have both entries?/ – Suraj Rao Apr 17 '17 at 13:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/141889/discussion-between-roox-and-suraj). – Reza Mazarlou Apr 17 '17 at 13:18

1 Answers1

0

Make sure your Android target sdk version matches the android sdk build tools in your android SDK manager , for your case check that you have android sdk build tools version 23 in sdk manager i tried to recreate the problem and app runs on device well on my side, my ionic ionic info is

cordova CLI: 6.5.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 7
Node Version: v7.8.0
Xcode version: Not installed

Also, upgrade your node version, current version as of this writing is 7.9.0

ionic plugin rm cordova.plugins.diagnostic
cordova platform remove android

then ionic plugin add cordova.plugins.diagnostic cordova platform add android

then
ionic build android

Nelson Bwogora
  • 2,225
  • 1
  • 18
  • 21