IBM / watson-calorie-counter

WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. The repository will be kept available in read-only mode. A mobile app that uses Watson Visual Recognition to provide nutritional analysis of captured food images.
https://developer.ibm.com/patterns/create-an-android-calorie-counter-app/
Apache License 2.0
54 stars 59 forks source link

Incorrect android targets for Docker container #44

Closed scottdangelo closed 6 years ago

scottdangelo commented 7 years ago

Cordova requirements fail:

Scotts-MBP:mobile scottda$ docker run --volume=/Users/scottda/GitRepos/Forkscottdangelo/watson-calorie-counter/mobile:/mobile calorie-counter cordova requirements

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed 
Please install Android target / API level: "android-26".
scottdangelo commented 7 years ago

Note that the manual install instructions are targeting: Android 6.0 (Marshmallow) (API Level 23)

I have tried re-building the image with the Dockerfile containing:

# Install Android SDK.
RUN sdkmanager --update \
    && yes | sdkmanager \
    "build-tools;23.0.3" \
    "platforms;android-23"

But I get the same error.

scottdangelo commented 7 years ago

I deleted my Docker image and my mobile/ dir, re-checked out the /mobile dir and still see android-26 targeted when I do the Cordova platform add android:

Scotts-MBP:mobile scottda$ docker run --volume=/Users/scottda/GitRepos/Forkscottdangelo/watson-calorie-counter/mobile:/mobile calorie-counter cordova platform add android
Using cordova-fetch for cordova-android@~6.3.0
Adding android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Package: com.watson.caloriecounter
    Name: Calorie_Counter
    Activity: MainActivity
    Android target: android-26
scottdangelo commented 7 years ago

Interesting. According to https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html (which is pointed to by the requirements for manual install)

 Cordova's latest Android package supports up to Android API Level 25. 

So, looks like Cordova cannot currently support API 26 anyway...

RiyaMRoy04 commented 7 years ago

@scottdangelo Cordova Android 6.3.0 which was released on 27th September 2017 targets the latest Android API level of API 26 and has fixed issues related to the Android SDK Tools 26.0.2 release. https://cordova.apache.org/announcements/2017/09/27/android-release.html I was able to deploy with API 26 through manual install. For Docker, copying @dolph !

scottdangelo commented 7 years ago

Did we still want to target Marshmallow 6.0 (api 23), so that more phones could actually use this? According to androidauthority.com:

For all non-Google devices, you’ll be in for a bit of a wait to see Android 8.0 Oreo
 on your smartphone. 

As of October 2, 2017, the last version of Android, Android Nougat, 
is running on only 17.8% of devices — more than a year after the software first launched. 
You can expect to see similar numbers for Oreo next year too.
RiyaMRoy04 commented 7 years ago

@scottdangelo Probably, we should leave that to the developers choice(In the documentation step we may want to just guide them and let developers choose their Android SDK API level!).However, this app is compatible with latest Android API level of API 26. Deployed and tested through manual install! Thoughts/inputs/suggestions are most welcome! :-) 👍

scottdangelo commented 7 years ago

yes, I think it's fine to allow the dev to choose the api level. But this should be documented, and we shouldn't expect the dev to be at all familiar with any of this. The target audience for journeys (soon to be patterns) is very broad, and the expectation is that anyone can follow the instructions and be up and running without any prior knowledge.

RiyaMRoy04 commented 7 years ago

@scottdangelo Sure thing! We will document that input! 👍

dolph commented 6 years ago

PR #54 hopefully takes a step in the right direction by getting the Dockerfile working.

From the mobile/ directory in a "dirty" repository, I got the Dockerfile to work with this patch by first discarding Cordova artifacts:

$ git checkout -- config.xml package.json plugins/fetch.json
$ sudo rm -rf platforms/android/ plugins/android.json plugins/cordova-plugin-camera/ plugins/cordova-plugin-file-transfer/ plugins/cordova-plugin-file/

And then building with Docker:

$ docker build -t calorie-counter .
$ docker run --volume "`pwd`:/mobile" calorie-counter cordova platforms add android
$ docker run --volume "`pwd`:/mobile" calorie-counter cordova requirements
$ docker run --volume "`pwd`:/mobile" calorie-counter cordova plugin add cordova-plugin-camera
$ docker run --volume "`pwd`:/mobile" calorie-counter cordova plugin add cordova-plugin-file-transfer
$ docker run --volume "`pwd`:/mobile" calorie-counter cordova build android

However, I wasn't able to successfully use any Android API version besides v26. It seems there's something else in this repository that results in a requirement for v26 specifically (which would need to change to support v23)? If there is, I haven't been able to find it.