Documentation on Android SDK

Hi there,

I am trying to get Ionic running for Android development.

The overall documentation with the Android SDK dependency is a pain.

I tried both on Mac and Linux to get the installation running but I am always beaten by the fact the
the gradle/wrappers could not be found.

I tried to install Android Studio and the command line tools on both platforms and read various Stackoverflow questions about the same issue.

Although it is perhaps in the direct scope of the Ionic team but the first hands experience with Ionic and Android SDK ist not very developer friendly. It took me half a day to get the stuff somewhat running on Mac and I am still trying to get the SDK configured in a way to make it work with Ionic.

While this first hands experience with Ionic is nice (in particular for iOS) there is a major pita problem when it comes to Android development.

Also: I tried to installed Ionic 3 (which is obviously in beta). …no official documentation how to install Ionic 3 using NPM. Answer on IRC was: install Ionic 2 (which would be Ionic 3)…well…pretty hard to get - even if you have 25 years backend dev experiences.

Andreas

Be careful, Ionic != Ionic CLI. I think you tried to install the Ionic CLI v3 beta, but that is definitely not expected as this is still experimental and getting tested and fixed. If you use the normal CLI, it will automatically create Ionic 3.1.0 (at the time of writing) projects when you create new ones. That’s what you want.

What exact error are you getting?

I think the problem is probably related to changes in the Android SDK so Cordova can not handle it any more. If so, this pre-release version of cordova-android 6.2.2 (which will be released in the next few days I think) could help: cordova platform update https://github.com/apache/cordova-android#6.2.2

Sorry you had such a shitty experience, there are lots of moving parts coming together and with Google Android changing things under the tools using it, it can get messy.

Ok, the starting point was this posting

https://blog.ionic.io/ionic-3-0-has-arrived/

with the idea to start with Ionic 3 (i played with Ionic 1 a while ago) for some evaluation work against real-world Android hardware.

So the documentation

installed Ionic 2.2.3 on my system.

What do you mean with Ionic vs. Ionic CLI?

Anyway…Ionic 2 vs. 3 would not make a big difference for my evaluation work.

My Android setup:

  • downloaded sdk-tools-linux-3859397.zip and unzipped

Then I tried to download the SDK stuff for Android 6.0

~/Downloads/tools/bin/sdkmanager --verbose  "platforms;android-25" "build-tools;25.0.2" "extras;google;m2repository" "extras;android;m2repository"
Info: Parsing /data/home/ajung/Downloads/build-tools/25.0.2/package.xml
Info: Parsing /data/home/ajung/Downloads/extras/android/m2repository/package.xml
Info: Parsing /data/home/ajung/Downloads/extras/google/m2repository/package.xml
Info: Parsing /data/home/ajung/Downloads/patcher/v4/package.xml
Info: Parsing /data/home/ajung/Downloads/platforms/android-25/package.xml
Info: Parsing /data/home/ajung/Downloads/tools/package.xml
Info: Parsing /data/home/ajung/Downloads/build-tools/25.0.2/package.xml
Info: Parsing /data/home/ajung/Downloads/extras/android/m2repository/package.xml
Info: Parsing /data/home/ajung/Downloads/extras/google/m2repository/package.xml
Info: Parsing /data/home/ajung/Downloads/patcher/v4/package.xml
Info: Parsing /data/home/ajung/Downloads/platforms/android-25/package.xml
Info: Parsing /data/home/ajung/Downloads/tools/package.xml
done

Accepted all licences using “sdkmanager --licences”

ionic start firstapp
…
ionic platform android

I set

ANDROID_HOME=/home/ajung/Downloads/tools/

which is obviously wrong.

> ionic-hello-world@0.0.0 ionic:build /data/home/ajung/src/ionic3/firstapp
> ionic-app-scripts build

[16:10:41]  ionic-app-scripts 1.3.5 
[16:10:41]  build dev started ... 
[16:10:41]  clean started ... 
[16:10:41]  clean finished in 3 ms 
[16:10:41]  copy started ... 
[16:10:41]  transpile started ... 
[16:10:43]  transpile finished in 2.12 s 
[16:10:43]  preprocess started ... 
[16:10:43]  deeplinks started ... 
[16:10:43]  deeplinks finished in 9 ms 
[16:10:43]  preprocess finished in 11 ms 
[16:10:43]  webpack started ... 
[16:10:43]  copy finished in 2.26 s 
[16:10:51]  webpack finished in 7.55 s 
[16:10:51]  sass started ... 
[16:10:52]  sass finished in 1.07 s 
[16:10:52]  postprocess started ... 
[16:10:52]  postprocess finished in 1 ms 
[16:10:52]  lint started ... 
[16:10:52]  build dev finished in 10.83 s 
[16:10:53]  lint finished in 1.47 s 
ANDROID_HOME=/home/ajung/Downloads/tools/

JAVA_HOME=/usr/java/latest

Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /home/ajung/Downloads/tools/tools/templates/gradle/wrapper

However the downloaded sdk tools do not contain the gradle stuff

ajung@blackmoon2:~/Downloads/tools> find . -name wrapper
ajung@blackmoon2:~/Downloads/tools> find . -name gradle

So I am missing here something?

Andreas

I mean exactly what I wrote: The Command Line Interface called “Ionic”, what you installed via npm and is version 2.2.3 right now isn’t Ionic Framework, which is version 3.1 right now.

If you start a project with the current CLI (2.2.3) it will generate a project using the current Framework version (see ionic-angular in package.json). It’s confusing the first time, but it just is this way. Don’t aks me why.

I have no linux experience, so I don’t know. The docs say this: How to Install The Ionic Framework CLI to Build Mobile Apps which links to Android Platform Guide - Apache Cordova for Android installation instructions. Did you follow these?

Try building something. I believe the gradle wrapper is downloaded automatically for you when needed.

Same issue here after updating to Ionic 3.1.1 CLI 2.2.3 when attempting to build ionic android version

ANDROID_HOME=/Users/flavio/Library/android-sdk-macosx

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home

Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /Users/flavio/Library/android-sdk-macosx/tools/templates/gradle/wrapper

I’ve updated SDK with sdkmanager, I’ve also did a
sdk install gradle 3.5
then
export PATH=$PATH:/opt/gradle/gradle-3.5/bin

so gradle is installed now and I can verify that by doing:

gradle -v

------------------------------------------------------------
Gradle 3.5

Build time: 2017-04-10 13:37:25 UTC
Revision: b762622a185d59ce0cfc9cbc6ab5dd22469e18a6

Groovy: 2.4.10
Ant: Apache Ant™ version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_102 (Oracle Corporation 25.102-b14)
OS: Mac OS X 10.12.4 x86_64

Any idea?

I’ve solved the problem by doing:

cordova platform remove android cordova platform add android@6.2.2

This at least has worked for me due to some breaking functionality added in latest Google SDK tools.

1 Like

Does it mean that android@6.2.3 won’t work ?

For him this seems to have been the solution… but that was a month ago. Right now most people are happily running android@6.2.3 with current Android SDK (via Android Studio is the most stable).

Thanks for your answer.
However, if I do

cordova platform add android@6.2.3 --save
ionic package build android

I get the gradle error,
but not with cordova platform add android@6.2.2 --save.

Am I doing something wrong ?


$ ionic info
[ERROR] Error with
        /home/louisro/Documents/mobileApps/BoardLine/ionic_version/www/lib/ionic/version.json
        file: FILE_NOT_FOUND

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 6.5.0 
    Gulp CLI         : CLI version 3.9.1 Local version 3.9.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/cli-plugin-cordova : 1.4.0
    @ionic/cli-plugin-gulp    : 1.0.1
    @ionic/cli-plugin-ionic1  : 2.0.0
    Cordova Platforms         : android 6.2.3 ios 4.3.1
    Ionic Framework           : unknown

System:

    Node       : v7.4.0
    OS         : Linux 4.4
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 4.0.5

ionic package is a remote service, if you search the forum for that error you should find some recent posts about that.

BUT that error you are getting and the missing Ionic Framework version are reason for concern. This should be fixed. Please post you package.json content. You ARE using Ionic v1, right?

Yes I am using ionic V1 (for this project at least) :slight_smile:

I don’t know how to fix things here. But here’s my package.json:


 {
  "name": "boardapp",
  "app_id": "bc689f0f",
  "version": "1.0.0",
  "description": "newIonic: An Ionic project",
  "dependencies": {
    "@ionic-native/globalization": "^3.2.0",
    "@ionic/cloud": "^0.9.0",
    "@ionic/cloud-angular": "^0.4.0",
    "bluebird": "^3.4.6",
    "gulp": "^3.5.6",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0",
    "gulp-sass": "^2.0.4",
    "ionic-app-lib": "^2.2.0"
  },
  "devDependencies": {
    "@ionic/cli-plugin-cordova": "1.4.0",
    "@ionic/cli-plugin-gulp": "1.0.1",
    "@ionic/cli-plugin-ionic1": "2.0.0",
    "bower": "^1.3.3",
    "gulp": "^3.9.1",
    "gulp-replace-task": "^0.11.0",
    "gulp-util": "^3.0.7",
    "shelljs": "^0.3.0",
    "yargs": "^5.0.0"
  },
  "cordovaPlugins": [
    {
      "locator": "https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git",
      "id": "cordova-plugin-datepicker"
    },
    "ionic-plugin-deploy",
    "cordova-plugin-extension",
    "cordova-plugin-admobpro",
    "cc.fovea.cordova.purchase",
    "onesignal-cordova-plugin",
    "cordova-plugin-geolocation",
    "cordova-plugin-device",
    "cordova-plugin-network-information",
    "cordova-plugin-compat",
    "cordova-plugin-app-version",
    "cordova-plugin-console",
    "cordova-plugin-globalization",
    "cordova-plugin-google-analytics",
    "cordova-plugin-googleplus",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "cordova-plugin-whitelist",
    "cordova-plugin-x-socialsharing",
    "ionic-plugin-keyboard",
    {
      "id": "cordova-plugin-facebook4",
      "locator": "cordova-plugin-facebook4",
      "variables": {
        "APP_ID": "583996261696416",
        "APP_NAME": "Boardapp"
      }
    }
  ],
  "cordovaPlatforms": [
    "android@6.1.0",
    {
      "platform": "android",
      "version": "",
      "locator": "android"
    }
  ],
  "main": "gulpfile.js",
  "scripts": {},
  "repository": {
    "type": "git",
    "url": "git+https://LouisDoe@bitbucket.org/boardappdevs/boardapp.git"
  },
  "author": "",
  "license": "ISC",
  "homepage": "https://bitbucket.org/boardappdevs/boardlapp#readme"
}

is for Ionic v2+, so probably out of place for your project.

I don’t know how to figure out the Ionic v1 version :confused: Please create a new post with “ionic v1” category here and include your ionic info output and ask how to fix the missing Ionic Framework version.

I just did : Ionic info shows an error

1 Like

Best approach to fix those type of issues is to create a blank new project with any name in Ionic, then observe how the package.json file and config.xml file were created.

Use the created files to check the versions of plugins that are required by your ionic framework and cordova installed in your system. Then, update the corresponding mismatching ones in your project file and finally to re establish the latest modules you should do:

  • remove completly the node_modules folder of your project
  • remove your platform folder
  • remove your www folder

then, do:

npm install

Finally, add your platforms

cordova platform add ios
if it says that platforms are already there, remove any entry of your config.xml or ionic.config.json files that indicate any platform and repeat this step until platform folder is created and all plugins installed.

Finally do:

cordova prepare
cordova run ios

1 Like