4

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' 

}
Angel Koh
  • 12,479
  • 7
  • 64
  • 91
  • Same problem here. My GAE endpoints project won't work with Gradle 5.1.1 – pldenc44 May 20 '19 at 06:01
  • @pldenc44, I got it working by commenting out the buildscript in build.gradle(module:app), and moving the class path into the project level build.gradle. hope it works for you too. (refer to my answer). – Angel Koh May 20 '19 at 06:19

2 Answers2

3

Updating from: classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2' to: classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.3'

Fixed this problem in my project

0

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
Angel Koh
  • 12,479
  • 7
  • 64
  • 91
  • Angel Koh, any idea about my json issue ? https://stackoverflow.com/questions/59079651/how-do-i-retrieve-data-independently-from-nested-json-objects-that-are-part-of-t –  Nov 27 '19 at 23:16