Published using Google Docs
Setting up an Instance in Appspot with GCS
Updated automatically every 5 minutes

Setting up an Appspot Instance to use Google Cloud Store (GCS)

You can comment on this document

Introduction

Creating an Appspot/Cloud Platform instance

Create a Cloud Platform account

Creating a Project

Creating an application within the project

Setting up a cloud storage bucket

Running an App Inventor server

Share your companion app

Launch the server

Historical information on the API transition

Old Objects

Including a Companion App

Introduction

When you follow the information in this document, you should make sure you are signed in to only one Google account. If you are signed into multiple accounts, you might get the error "Failed to load" with a tracking number.

Creating an Appspot/Cloud Platform instance

Create a Cloud Platform account

  1. Go to https://cloud.google.com/
  2. Start a free trial, which requires a credit card. As of August 12, 2019, the terms say you will not get charged after the trial unless you explicitly agree to be later. Make sure that's still true.

If you had an appspot account, it will have been migrated to Google Cloud Platform, but you still need to start the free trial.

Creating a Project

  1. Go to the App Engine dashboard.
  2. You will be prompted to activate your free trial. You need to click the ACTIVATE button.
  3. Next, you will need to click "Upgrade".
  4. At the top of the page (the App Engine dashboard), there should be a dropdown menu headed by "My First Project". Click on the triangle, then on "NEW PROJECT".
  5. Set a project name, such as "App Inventor". There is no need to specify a location:
  6. Note your Project ID. In the above example, it is "app-inventor-249700".

Creating an application within the project

  1. Back at the dashboard, your project should appear in the dropdown menu. Select it:
  2. Back at the dashboard, click "Create Application".
  3. Specify a region, and click on "Create app":
  4. It will then try to take you through an optional wizard. Click "Cancel".

Setting up a cloud storage bucket

  1. From the dashboard for the project, select Storage > Browser.
  2. If you see that there are already buckets (with names like <Project ID>.appspot.com and staging.<Project ID>.appspot.com), you're done. Otherwise, click on "Create Bucket".
  3. Give your bucket the same name as your project and application (e.g., "app-inventor-249700).
  4. Choose any storage class (such as "Multi-Regional").
  5. In response to "Choose how to control access to objects", choose "Set object-level and bucket-level permissions".
  6. Continue with the default settings.

Running an App Inventor server

Share your companion app

TODO

Launch the server

You can now follow the instructions in How to build App Inventor from the MIT sources. The command line (no line break) to deploy a server is:

appcfg.sh -A <PROJECT-ID> --oauth2 update appinventor/appengine/build/war

You may get a permissions error if you recently connected to App Engine with a different Google account. To force re-authentication:

appcfg.sh -A <PROJECT-ID> --no_cookies --oauth2 update appinventor/appengine/build/war

If using Google Cloud SDK, you will need to run the following command:

gcloud app deploy --project=<PROJECT-ID> --version=1 \ appengine/build/appengine-web.xml

Historical information on the API transition

Effective May 20, 2015 newly created Appspot instances may not use the “files” API. Unfortunately, until that date, the files API was how we accessed the Blobstore from App Engine. By default, when you installed from the “master” branch, App Inventor was configured to use Blobstore via the files API.

Starting May 20, the supported alternative is to use the Google Cloud Store (GCS) instead of the Blobstore.

The App Inventor master branch as of 5/29/2015 (this commit) supports the use of GCS. Every Appspot instance created since around the end of February 2014 has a GCS “bucket” created automatically for it. We will now use this bucket by default.

You may find yourself in one of three situations:

  1. If you are about to create an Appspot instance, and you use code from our master branch after 5/29/2015 (reference above), you should be fine. All should just work. You’re done…
  2. If you created your instance after February of 2014 you likely already have a GCS bucket, you should update your code to be based on our latest master branch. Once you deploy this code, all new objects will be written to GCS while older objects will still reside in the Blobstore (which is a problem, which we need to address, read on…).
  3. If you created your Appspot instance prior to February of 2014, you may not yet have a default GCS bucket, but you can create one from the Google App Engine console. You must be an “owner” of your application, not just a “developer.” If you are an owner, then go to the bottom of the “Application Settings” page (it is one of the links on the left hand side of the page under “Administration.” At the bottom of the Application Settings page there is a section labeled “Cloud Integration” under which there is a “Create” button. Click that button! It should then create your default GCS bucket and our latest master branch code will work. Note: If you upgrade to our latest master branch (which sets use.gcs=true in appengine-web.xml) and you do NOT have a bucket, you will get 500 errors. The App Engine log should make it clear that you don’t have a bucket!

Old Objects

We are currently working on code to migrate old objects from the blobstore to the GCS bucket. We’ll make an announcement on the Open Source group when it is done (and update this document as well).

Update (July 2015)

Google recently changed its policy and now requires you to start a free trial with Google App Engine before you’re allowed to create a GCS bucket. To create a bucket, first navigate to https://console.developers.google.com/project and select your Appspot project. Then, in the sidebar, select Storage > Cloud Storage > Browser. On this page you should see a link to start your free trial on Appspot. Once you’ve finished signing up, navigate back to the “Browser” page. You should now see a button that says “Create Bucket”. Click it to create your default GCS bucket.

Including a Companion App

Modify the end of  components/src/com/google/appinventor/components/common/YaVersion.java to set the following variables:

Set COMPANION_UPDATE_URL = "/companions/MITAI2Companion.asc"

Set COMPANION_UPDATE_URL1 = "/companions/MITAI2Companion.apk"

Set COMPANION_UPDATE_EMULATOR_URL = "/companions/Emulator.asc"

Run the following commands from the appinventor directory:

appinventor$ mkdir -p docs/companions/

appinventor$ ant PlayApp PlayAppExtras Emulator   # builds the companion variants

appinventor$ cp build/buildserver/MITAI2Companion-full.apk docs/companions/MITAI2Companion.apk

appinventor$ openssl base64 < build/buildserver/MITAI2Companion-full.apk | tr -d '\n' > docs/companions/MITAI2Companion.asc

appinventor$ openssl base64 < build/buildserver/Emulator.apk | tr -d '\n' > docs/companions/Emulator.asc

appinventor$ ant noplay   # builds the appengine package