Cannot import Google client after updating Android Studio -
after updating android studio 2.3 appears can not use code cloud endpoints
class endpointsasynctask extends asynctask<pair<context, string>, void, string> { private static myapi myapiservice = null; private context context; @override protected string doinbackground(pair<context, string>... params) { if(myapiservice == null) { // once myapi.builder builder = new myapi.builder(androidhttp.newcompatibletransport(), new androidjsonfactory(), null) // options running against local devappserver // - 10.0.2.2 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); } }); // end options devappserver myapiservice = builder.build(); } context = params[0].first; string name = params[0].second; try { return myapiservice.sayhi(name).execute().getdata(); } catch (ioexception e) { return e.getmessage(); } } @override protected void onpostexecute(string result) { toast.maketext(context, result, toast.length_long).show(); } }
the problem arises importing androidhttp , androidjsonfactory. used work click-alt-enter import, not now. can copy import manually
import com.google.api.client.extensions.android.http.androidhttp; import com.google.api.client.extensions.android.json.androidjsonfactory; import com.google.api.client.googleapis.services.abstractgoogleclientrequest; import com.google.api.client.googleapis.services.googleclientrequestinitializer;
but highlights 'client', cannot resolve symbol client. gradle file has dependency compile project(path: ':backend', configuration: 'android-endpoints') , have synched.
rather trying rollback versions, there different import need use or configure differently? code on google cloud page outdated?
i added these dependencies in endpoints build.gradle file:
compile group: 'com.google.api-client', name: 'google-api-client', version: '1.22.0' compile group: 'com.google.api-client', name: 'google-api-client-android', version: '1.22.0'
i don't know why needed, solved adding these dependencies missing packages.
Comments
Post a Comment