title: What are the necessary gradle dependencies for an App Engine Backend with Google Cloud Messaging?
body: <p>What are the necessary gradle dependencies for an App Engine Backend with Google Cloud Messaging?</p>
  
  <p>Currently, when you add a module like that to your Android Studio project it adds this dependency:</p>
  
  <p>'compile 'com.google.android.gms:play-services:8.4.0'</p>
  
  <p>However, when you run the project you get this error: </p>
  
  <blockquote>
    <p>Error:Execution failed for task
    ':app:transformClassesWithDexForDebug'.</p>
    
    <blockquote>
      <p>com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
      org.gradle.process.internal.ExecException: Process 'command
      '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java''
      finished with non-zero exit value 2</p>
    </blockquote>
  </blockquote>
  
  <p>Someone suggested using this:</p>
  
  <pre><code>defaultConfig {
          multiDexEnabled true
  }
  </code></pre>
  
  <p>But that actually didn't work for me. </p>
  
  <p>So it appears that I have to specify only the required libraries for GAE + GCM. So far I have:</p>
  
  <pre><code>compile 'com.google.android.gms:play-services-auth:8.4.0'
  compile 'com.google.android.gms:play-services-gcm:8.4.0'
  compile 'com.google.android.gms:play-services-base:8.4.0'
  </code></pre>
  
  <p><a href="https://developers.google.com/android/guides/setup" rel="nofollow">full list here</a>. But that didn't work. I got this error:</p>
  
  <blockquote>
    <p>E/GMPM: GoogleService failed to initialize, status: 10, Missing an
    expected resource: 'R.string.google_app_id' for initializing Google
    services.  Possible causes are missing google-services.json or
    com.google.gms.google-services gradle plugin.</p>
  </blockquote>
  
  <p>So I am at a loss.</p>
  
  <p>Is there some other way around this issue? What is weird is my old GAE + GCM projects work fine importing the whole google play services. Importing those older versions of google play services in my new project does not work however. So I am not sure what is going on.</p>
  
  <p><strong>EDIT: Some more information:</strong></p>
  
  <p>I did some tests.</p>
  
  <p>1) Started new Android Studio project, added new google cloud module 'App Engine Java Endpoints Module'. The auto-generated build.grade (Module: app) looks like this:</p>
  
  <pre><code>dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
      compile 'com.android.support:appcompat-v7:23.1.1'
      compile 'com.android.support:design:23.1.1'
      compile project(path: ':backend', configuration: 'android-endpoints')
  }
  </code></pre>
  
  <p>Result? Compiles and runs perfectly - no problems!</p>
  
  <p>2) Started new Android Studio project, added new google cloud module 'App Engine Backend with Google Cloud Messaging'. the auto-generated build.grade (Module: app) looks like this:</p>
  
  <pre><code>dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
      compile 'com.android.support:appcompat-v7:23.1.1'
      compile 'com.android.support:design:23.1.1'
      compile 'com.google.android.gms:play-services:8.4.0'
      compile project(path: ':backend', configuration: 'android-endpoints')
  }
  </code></pre>
  
  <p>Result? Same crappy error I have been getting!</p>
  
  <p>So it looks like the line 'compile 'com.google.android.gms:play-services:8.4.0'' is the problem. I replaced it with </p>
  
  <p>'compile 'com.google.android.gms:play-services-gcm:8.4.0''</p>
  
  <p>since in theory that is all I need for google cloud messaging. When I run it I get this:</p>
  
  <blockquote>
    <p>12-30 14:14:16.482 10573-10573/com.myapp.myapp
    E/GMPM: GoogleService failed to initialize, status: 10, Missing an
    expected resource: 'R.string.google_app_id' for initializing Google
    services.  Possible causes are missing google-services.json or
    com.google.gms.google-services gradle plugin. 12-30 14:14:16.482
    10573-10573/com.myapp.myapp E/GMPM: Scheduler not
    set. Not logging error/warn. 12-30 14:14:16.502
    10573-10623/com.myapp.myapp E/GMPM: Uploading is
    not possible. App measurement disabled</p>
  </blockquote>
  
  <p>So it looks like I am missing this google-services.json file or something. I don't get what happened with Android Studio because several months ago I made a GCM enabled app the same way and that one compiles no problem. The gradle.build file of that app looks like this:</p>
  
  <pre><code>dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      compile project(path: ':gcm-backend', configuration: 'android-endpoints')
      compile 'com.android.support:appcompat-v7:22.2.0'
      compile 'com.ganyo:gcm-server:1.0.2'
      compile 'com.google.android.gms:play-services:7.5.0'
      compile 'com.android.support:support-v4:22.2.0'
  }
  </code></pre>
  
  <p>So it looks like Android Studio stopped adding the 'compile 'com.ganyo:gcm-server:1.0.2'' dependency. </p>
  
  <p>So I ran a project with </p>
  
  <pre><code>'compile 'com.ganyo:gcm-server:1.0.2'
  'compile 'com.google.android.gms:play-services:8.4.0'
  </code></pre>
  
  <p>Result? Same Execution failed error.</p>
  
  <p>Ok so let's try the old play-services library in my new project:</p>
  
  <pre><code>'compile 'com.ganyo:gcm-server:1.0.2'
  'compile 'com.google.android.gms:play-services:7.5.0'
  </code></pre>
  
  <p>Result? Same Execution failed error.</p>
  
  <p>I just don't get why this isn't working out of the box like it used to...</p>