Android studio appengine端点不包含构建器

时间:2015-07-01 13:32:19

标签: android google-app-engine android-studio google-cloud-endpoints

在android studio 1.2.2中使用两个模块工作:android和另一个是从类生成的端点,称为' backend'对于app-engine模块。尝试使用端点时,IDE会为SearchObjectEndpoint.Builder

提供错误

端点类:

public class SearchObject {

    private String Location;

    public String getLocation() {
        return Location;
    }

    public void setLocation(String location) {
        Location = location;
    }
}

生成的端点:

@Api(
        name = "searchObjectApi",
        version = "v1",
        resource = "searchObject",
        namespace = @ApiNamespace(
                ownerDomain = "SearchPackage.Package.backend.co.za",
                ownerName = "SearchPackage.Package.backend.co.za",
                packagePath = ""
        )
)
public class SearchObjectEndpoint {

    private static final Logger logger = Logger.getLogger(SearchObjectEndpoint.class.getName());

    @ApiMethod(name = "getSearchObject")
    public SearchObject getSearchObject(@Named("id") Long id) {
        return null;
    }

    @ApiMethod(name = "insertSearchObject")
    public SearchObject insertSearchObject(SearchObject searchObject) {
        return searchObject;
    }
}

在android项目中,当我调用SearchObjectEndpoint.Builder时,它找不到Builder ..

import za.co.backend.Package.SearchPackage.SearchObjectEndpoint;
 ...
 SearchObjectEndpoint.Builder builder = new SearchObjectEndpoint.Builder(AndroidHttp.newCompatibleTransport(),
                    new AndroidJsonFactory(), null)

app build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(path: ':backend', configuration: 'android-endpoints')

backend build.gradle:

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
    compile 'com.google.appengine:appengine-endpoints:1.9.18'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.googlecode.objectify:objectify:5.1.5'
    compile 'com.ganyo:gcm-server:1.0.2'
}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
    endpoints {
        getClientLibsOnBuild = true
        getDiscoveryDocsOnBuild = true
    }

我通读了stackoverflow上的其他类似问题,但它们似乎已过时或无法解决问题。请帮忙

1 个答案:

答案 0 :(得分:1)

问题是我没有为Builder使用正确的对象:

我使用了自动生成的端点类SearchObjectEndpoint,而不是端点@Api(name = searchObjectApi

我试图:

SearchObjectEndpoint.Builder builder = new SearchObjectEndpoint.Builder(AndroidHttp...

而不是:

SearchObjectApi.Builder builder = new SearchObjectApi.Builder(AndroidHttp...