google-app-engineandroid-studio-3.4

Google endpoint framework breaks for Android Studio 3.4 (gradle 5.1.1)


I have a project that uses Google App Engine with Android.

I got the following "gradle project sync failed" error after I upgraded to Android Studio 3.4 (gradle 5.1.1).

It was working well prior in the previous android studio version which uses gradle 4.10.1.

Any pointers are welcomed. do tell me if you need me to provide more information

Caused by: java.lang.NoSuchMethodError: org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;
at com.google.cloud.tools.gradle.endpoints.framework.server.EndpointsServerPlugin$2$1.execute(EndpointsServerPlugin.java:108)
at com.google.cloud.tools.gradle.endpoints.framework.server.EndpointsServerPlugin$2$1.execute(EndpointsServerPlugin.java:98)

the following is the build.gradle file for the backend module.
This was after I migrated to GAE V2 using the migration guide (https://cloud.google.com/endpoints/docs/frameworks/java/migrating-android)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'

    }
}

repositories {
    jcenter()
}

apply plugin: 'java'
apply plugin: 'war'

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

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {

    // V2: Endpoints Framework v2 migration
    implementation 'com.google.endpoints:endpoints-framework:2.0.9'
    implementation 'javax.inject:javax.inject:1'
    implementation 'javax.servlet:servlet-api:2.5'

    implementation 'com.googlecode.objectify:objectify:5.1.9' 

}

Solution

  • to get it working again, I had to comment off the following from the build.gradle (module:app )

    //buildscript {
    //    repositories {
    //        jcenter()
    //    }
    //    dependencies {
    //        // V2: Add the new Endpoints Framework plugin dependencies
    //        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.3'
    //    }
    //}
    

    instead, add the classpath into the build.gradle (project)

    buildscript {
        repositories {
            jcenter()
            google() 
        }
        dependencies {
            // V2: Include this dependency when using Endpoints Framework v2
            classpath 'com.google.guava:guava:24.1-jre'
    
            //**moved from the build.gradle in module:app** 
            classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.3'
    
    ///... <snips> the rest of the build.gradle file