Skip to content

Latest commit

 

History

History
137 lines (112 loc) · 4.12 KB

ANDROID_README.md

File metadata and controls

137 lines (112 loc) · 4.12 KB

project status image

Transitioning Android Projects

Moving legacy projects from Android Studio requires a few extra steps. This will guide you through that process

Make sure you have the cloud SDK installed (see the app-gradle-plugin for more)

This guide starts from a basic android studio project with a cloud backend File -> New Project (click through, using defaults) File -> New Module -> Google Cloud Module (click through, using defaults)

Make changes in the backend/appengine module

<project>/backend/build.gradle

Remove the old appengine plugin jar and add in the new appengine and endpoints jars

buildscript {
  ...
  dependencies {
    // delete this
    // classpath 'com.google.appengine:gradle-appengine-plugin:1.9.51'
      
    // add these 
    classpath "com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0"
    classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.1'
  }
}

Remove the old plugin and apply the new ones

// delete this
// apply plugin: 'appengine'

// add these
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'

Remove all the old appengine and endpoints dependencies and add the new endpoints dependencies

dependencies {
  // delete these, we are using the cloud SDK and new endpoints tooling now
  // appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.51'
  // compile 'com.google.appengine:appengine-endpoints:1.9.51'
  // compile 'com.google.appengine:appengine-endpoints-deps:1.9.51'
  ... 
  // add these (inject needs to be explicitly included now)
  compile 'com.google.endpoints:endpoints-framework:2.0.7'
  compile 'javax.inject:javax.inject:1'
  ...
}

...
// delete this whole block, it's configuration for the older plugin
// appengine {
//   downloadSdk = true
//   appcfg {
//     oauth2 = true
//   }
//   endpoints {
//     getClientLibsOnBuild = true
//     getDiscoveryDocsOnBuild = true
//   }
// }

Make changes in the android client

<project>/app/build.gradle

Add in the new endpoints jar

buildscript {
  ...
  dependencies {
    // add this
    classpath "com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0"
  }
}

Apply the endpoints plugin after the android plugin

apply plugin: 'com.android.application'
// add this
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'

Use the new endpointsServer dependency and remove the old compile dependency, also explicitly add in the google-api-client dependency

dependencies {
   ...
   // remove this
   // compile project(path: ':backend', configuration: 'android-endpoints')
   
   // add these
   endpointsServer project(path: ':backend', configuration: 'endpoints')
   compile "com.google.api-client:google-api-client:+"
}

Finally, if you see this, to deal with a buildscript classpath issue (see: gradle forums) Make changes in the root project

<project>/build.gradle

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    // add this
    classpath 'com.google.guava:guava:19.0'
    
    classpath 'com.android.tools.build:gradle:2.2.2'
  }
}

Android Studio

Android Studio's App Engine tooling will no long Gradle Sync with these plugins, and while things may continue to work on stale configuration, it's not safe to depend on it to always work.

Run

In Android Studio, you need to run the local development server using the gradle task appengineStart which starts the development server in non-blocking mode. It is not recommended to use appengienRun from within Android Studio. If you use appengineRun you may block Android Studio from using the gradle daemon to launch any gradle further related tasks.

Deploy

For deploy, you must first login using glcoud and then deploy using the gradle task appengineDeploy

$ ./gradlew appengineDeploy