Android SDK workspace template

environment

#1

So I made a Dockerfile in this github site

https://github.com/hpssjellis/templates/tree/master/ws-android-sdk

which was forked from your Cloud9 Workspace templates site at https://github.com/c9/templates

and sent a pull request. Do you guys test it out or is their some way that I can try it on Cloud9.

I have a workspace image if you want it


Workspace from Dockerfile/Snapshots
How to install android SDK into meteor workspace?
#2

@jerteach you’ve probably already seen my response on Github but I want to make sure this is public information.

Right now, there is no way for you to test out the Dockerfile. Once you submit the PR, we will test it and update you with any further information. If changes need to be made, we’ll consult you on them to make sure you’re aware. If everything looks good then we can merge the pull request and then there will be a new workspace template in Cloud9 :slightly_smiling:


#3

Thanks @bradydowling:

I see the information on github at https://github.com/c9/templates/pulls but things seem to have stalled. I think @nikolai is needed to merge the pull request, or a few more steps need to be done to activate the dockerfile on cloud9. Any updates about where the Android-SDK is at?


#4

We’re just testing the image and hope to get this out very soon! Thanks for your patience :slight_smile:


#5

Until the image is out I have made a phoengap example. t https://github.com/hpssjellis/Phonegap-and-Android-SDK-on-Cloud9

and an android example at

you have to enter “Y” about 6 times but the final result is awesome. Both make fully working example Android apps, auto-magically and load the .apk onto an apache2 website ready to download to your Android Phone. Skipping the entire emulator mess.

Keep up the good work Cloud 9.


#6

@bradydowling @justin8 @nikolai @fjakobs

Any updates about the Android-SDK workspace image I submitted. I see that it has been absorbed into the Cloud 9 Github site at https://github.com/c9/templates but I have no idea of a possible release date. I guess with a big company these things do not happen quickly.

Just curious, since I have a few youtube videos planned for my channel that should explaining how to use the Android-SDK for Ant, Gradle and Phonegap building of an .apk file.

I also want to make another workspace image, based on Google’s Artificial Intelligence Deep Learning engine called TensorFlow that uses Virtual Neural Networks. It was recently released to the public (Nov 2015), but not sure if I really want to invest all those hours of research again.


#7

So I can test out the Android-SDK and I can see that the docker image has installed both the Android-SDK and the Android-NDK and that the PATHS and ANDROID_HOME have been setup correctly, however it looks like the Kitkat, Lollipop and Marshmallow platforms were never installed. Also the command

android list sdk

has a problem finding or saving the fetched file: Here is the reply

:~/workspace (master) $ android list sdk
Refresh Sources:
  Fetching https://dl.google.com/android/repository/addons_list-2.xml
  Failed to fetch URL https://dl.google.com/android/repository/addons_list-2.xml, reason: File not found
  Fetched Add-ons List successfully
  Refresh Sources
  Fetching URL: https://dl.google.com/android/repository/repository-11.xml
  Failed to fetch URL https://dl.google.com/android/repository/repository-11.xml, reason: File not found
Refresh Sources:
  Fetching URL: https://dl.google.com/android/repository/repository-11.xml
  Failed to fetch URL https://dl.google.com/android/repository/repository-11.xml, reason: File not found
Refresh Sources:
  Fetching URL: https://dl.google.com/android/repository/repository-11.xml
  Failed to fetch URL https://dl.google.com/android/repository/repository-11.xml, reason: File not found
Refresh Sources:
  Fetching URL: https://dl.google.com/android/repository/repository-11.xml
  Failed to fetch URL https://dl.google.com/android/repository/repository-11.xml, reason: File not found
Packages available for installation or update: 0

And what it should look like is

~/workspace (master) $ android list sdk
Refresh Sources:
  Fetching https://dl.google.com/android/repository/addons_list-2.xml
  Validate XML
  Parse XML
  Fetched Add-ons List successfully
  Refresh Sources....

Not sure what to do about this. The fetch command does not seem to work.

I think the real problem is that these lines in the Docker file do not seem to be working

Look just after the following RUN command. I think the “yes” just has to be a “y”

RUN yes | (\
    /usr/local/android-sdk-linux/tools/android update sdk --filter tools --no-ui --force -a && \
    /usr/local/android-sdk-linux/tools/android update sdk --filter platform-tools --no-ui --force -a && \
    /usr/local/android-sdk-linux/tools/android update sdk --filter android-19 --no-ui --force -a && \
    /usr/local/android-sdk-linux/tools/android update sdk --filter android-20 --no-ui --force -a && \
    /usr/local/android-sdk-linux/tools/android update sdk --filter android-21 --no-ui --force -a && \
    /usr/local/android-sdk-linux/tools/android update sdk --filter android-22 --no-ui --force -a && \
    /usr/local/android-sdk-linux/tools/android update sdk --filter android-23 --no-ui --force -a && \
    /usr/local/android-sdk-linux/tools/android update sdk --filter extra --no-ui --force -a && \
    /usr/local/android-sdk-linux/tools/android update sdk --all --filter build-tools-23.0.2 --no-ui --force)

Solved it. In the terminal android list sdk does not work but

sudo android list sdk

works. which may mean that the docker file somehow needs sudo.

(I bet the docker build is crashing on these commands since it can’t answer the yes/no question about accepting the Android license. I have a fix in my github at https://github.com/hpssjellis/ws-android-scripts/blob/master/a00-fix-docker.sh)

but it is not the best solution. I have seen hacks for this for a bash file but not for a docker file.

This quote looks interesting

If you want to have these settings permanent, create a file in /etc/apt/apt.conf.d/, like /etc/apt/apt.conf.d/90forceyes with the following content:

APT::Get::Assume-Yes “true”; helped me to avoid interrupt in an installation in a docker container. – Mehdi Sadeghi 5

APT::Get::Assume-Yes "true";

APT::Get::force-yes "true";

Her is an actual docker command that might help

RUN apt-get update && apt-get install -y --force-yes apache2

The regular apt-get looks like

apt-get -y --force-yes install package

Looking again at the code perhaps it is not looking for a “yes” but a “y” can we change the code to I will send a pull request.


#8

I have made a github repo at

https://github.com/hpssjellis/ws-android-scripts.git

to install on the Android-sdk with a few batch files to help debug it

Hopefully the lat issue:

:validateDebugSigning is not working. I will have to research this. somehow the path or the jarsigning certificate maker is not working.


#9

@bradydowling @justin8 @nikolai @fjakobs

For the next people who submit a workspace container, please, please, PLEASE make a developmental server for compiling docker file’s (or give the developer’s some way to compile it on Cloud 9).

I have been using a home computer installation of docker which is much more locked down than yours. My Android SDK container works great on my docker but I need to compile it for Cloud 9. It’s like developing for the iPhone but submitting to Google.

It is very frustrating, time consuming, data intensive and a waste of the awesome Cloud 9 employees time. If you can simplify the method to test a Dockerfile, I could submit a fully working container, that a Cloud 9 employee could then just OK or decline. The WS-ANDROID workspace, should have taken me about 3 days to get working but has taken more than two months since I can’t compile or test it for Cloud 9.

The WS-ANDROID container works perfectly on my computer’s docker, my Github is at

https://github.com/hpssjellis/templates/tree/android-fix-B/ws-android

(I can compile Ant, Gradle and Android Studio projects in seconds and auto upload a debug .APK to testing cell phones from the Apache Web Server). My docker however, seems more locked down than yours so adding paths or testing it, using the local environment does not seem to work. Waiting a few weeks for a Cloud 9 employee to review the Pull Request and compile it and then send me a test link is a horribly slow developmental technique.

I absolutely love teaching coding using Cloud 9, the benefits of having every student use the exact same workspace makes debugging their code a snap. The present workspace creation system however is the exact opposite of easy, hopefully a slightly changed method can be made for the future.

Jeremy Ellis
Twitter @rocksetta


#10

Thank you for the feedback about this, this is definitely good to know and I’m really sorry this hasn’t been as smooth a process as we had hoped. We’ve realized that submitting a PR for a new workspace type actually requires much more Docker knowledge than most C9ers have right now and quite of bit of testing and maintenance on our end that we also may not be ready for.

I think Justin has made a few comments about handling the PR that still need some attention but if that looks too time intensive to get those things figured out then you can wait for workspace cloning to be available on a templating basis.

Basically you’ll make a workspace, configure it the way you want to, then tick a box that says others can copy it and use it as a template. From there, users will be able to create a workspace using that custom template you’ve created.


#11

Actually, if it’s not too much of a side-track, I was thinking about this a bit recently when I was setting up a Google App Engine box. I thought I could set up a base environment and use clone to create new instances for different projects/tests.

I’m fairly new to C9 and I still haven’t worked out how public workspaces actually operate, but I was thinking it would be good if there was a “community” account where various curated (maybe) environments could be cloned from various users once they’re ready to reuse. Then you could have links to them in the community area somewhere.

Then if I wanted a particular type of environment I could just look it up and clone it from the one place. Eg. there could be an Android SDK base environment ready to clone.

Might be a naïve idea.


#12

No, I think this is a good idea. I’m not sure how we’ll be structuring things in this regard but certainly a good thought.


#13

Can someone make some suggestions why my docker setup hates the “export” command used to setup ANDROID_HOME or PATH commands. I can run a bash file, but it will not activate the “export” command.

When I web research solutions, most Docker files use the ENV command which works great for me, but Cloud9 expects a bash file to be installed and ran after the container has been setup.

Here is the bash file that seems to work for Cloud9 employees but I can’'t seem to get it to run from my Docker installation.

https://github.com/hpssjellis/templates/blob/android-fix-B/ws-android/files/profile.d-android.sh

Anyone have any suggestions?


#14

Aaaaaargh. I hate little mistakes. It looks like export and PATH need an “=” sign after them. Fixing the file now.

so

export JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
export PATH $PATH:$JAVA_HOME/bin

should have been

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin

#15

After my ridiculous EXPORT PATH screw-up I have managed to get a local version of Cloud 9 running, which massively improves the ability to debug docker installations.

My problem is that the bash script that runs the environment variables, works great but it runs a few statements that I only want to run once on start-up not every single time that I open a terminal.

I assume you check if a variable has been set, do your one time tasks and then set the variable for the next iteration to test if it has been set. Does anyone have any example code? Lots of online examples, just wondering if anyone has a Cloud9 bash script friendly example.

… 2 days later

What I did was fairly easy. First run through the bash file I checked if the other bash file was available, If it was I called it and then moved it to a slightly different name

if [ -e /home/ubuntu/start-here/a00-auto-ant-gradle.sh ]
  then
    sudo bash /home/ubuntu/start-here/a00-auto-ant-gradle.sh 
    sudo mv /home/ubuntu/start-here/a00-auto-ant-gradle.sh /home/ubuntu/start-here/a00b-auto-ant-gradle.sh 
fi

Seems to work fine. Runs the bash file once and then never again.


#16

So we can code android apps in cloud9!!! :smiley:


#17

@PhpCoder231 That is the plan. The workspace is taking longer than I expected to get working. But it is much closer to being ready.

Glad someone appreciates how cool this will be once it is ready.

If you want to play around with it today just make a new custom workspace using this github

and right click run the setup.sh file.

The install is slow (12 minutes) and needs about 6 “Y” entries, but the result will be the same as the workspace I am trying to make (This github is actually better since it installs the NDK as well as the android SDK!). It auto-makes an Ant and Gradle build and puts the .apk link on a running webpage, much easier than using a virtual android device, just install the app on your own phone over the web.


#18

Wow @jerteach you are amazing. Man Cloud9 will soon be one of the best Code Editors In the universe! I dont see anything wrong with Cloud9, but full of feautures!


#19

@jerteach i get to the application and run it. But after i run it and get the welcome page thier is a link to download apk for android. Well when i click on that link, it gives me a 404 not found


#20

Working on it. I thought that workspace worked. Check if the ant or gradle .apk’s are where they should be. I will look into it.
Ant should be in the helloAnt bin folder. HelloGradle is in builds/output/apk.

Having a similar issue with the Dockerfile. I am setting ownership for cloud9 “ubuntu” instead of root for the AndroidSDK, which seems to fix the issues.