我的帶有 Cloud Endpoints 的 Android 應用說這些類不存在
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
使用以下匯入的任何高于 1.31.0 的版本時
implementation 'com.google.api-client:google-api-client-android:1.31.0'
最新版本是2.0.0但即使是 1.32.1 也有問題。任何 1.31.0 或更低版本的作品都可以。
這是我的代碼的樣子(取自此鏈接):
if (myApiService == null) { // Only do this once
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
.setRootUrl("http://YOUR-PROJECT-ID.appspot.com/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// end options for devappserver
myApiService = builder.build();
}
try {
return myApiService.sayHi(params[0]).execute().getData();
} catch (IOException e) {
return e.getMessage();
}
在新版本中是否有不同的方法可以做到這一點,還是發生了其他事情?
uj5u.com熱心網友回復:
根據您共享的檔案和您正在遵循的代碼示例,這似乎絕對是API 版本的問題。
我強烈建議您在這個GitHub 存盤庫中提出一個新問題。
一旦您在存盤庫中收到回應,我建議您暫時繼續使用較低版本。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/507971.html
標籤:Google Cloud Collective 爪哇 安卓 行家 毕业典礼 谷歌云端点