我正在学习官方教程 https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints .当我重建时,然后尝试从我的客户端 android 应用程序访问端点。找不到以下类:AndroidHttp、AndroidJsonFactory、GoogleClientRequestInitializer、AbstractGoogleClientRequest、AbstractGoogleJsonClient
这是代码 fragment
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
// options for running against local devappserver
// - 10.0.2.2 is localhost's IP address in Android emulator
// - turn off compression when running against local devappserver
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
我也看不到 MyApi。有没有其他人遇到过这个问题?
最佳答案
我将以下内容添加到后端 gradle 并且它有效
dependencies {
compile 'com.google.http-client:google-http-client-android:1.19.0'
compile 'com.google.api-client:google-api-client:1.19.0'
compile 'org.projectlombok:lombok:1.12.6'
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.slf4j:slf4j-jdk14:1.7.21'
}
关于android - Cloud Endpoints 后端 API 开箱即用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43295381/