24719

Cannot resolve symbol 'MyApi'

MyApi was perfectly fine before. I added Objectify to the dependencies, along with some endpoints, and all of a sudden it says that MyApi isn't a thing!

Here's where I call it:

import android.content.Context; import android.os.AsyncTask; import android.util.Pair; import android.widget.Toast; 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; import java.io.IOException; class SendRegisterInfo 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) { // Only do this once 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); } }); // end options for 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(); } }

Here's the gradle file for the client:

apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "grademe.ip.com.grademe" minSdkVersion 15 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0' compile project(path: ':backend', configuration: 'android-endpoints') }

Here's the gradle file for the backend:

buildscript { repositories { jcenter() } dependencies { classpath 'com.google.appengine:gradle-appengine-plugin:1.9.14' } } repositories { jcenter(); } apply plugin: 'java' apply plugin: 'war' apply plugin: 'appengine' sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 dependencies { appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.14' compile 'com.google.appengine:appengine-endpoints:1.9.14' compile 'com.google.appengine:appengine-endpoints-deps:1.9.14' compile 'javax.servlet:servlet-api:2.5' compile 'com.googlecode.objectify:objectify:5.0.3' } appengine { downloadSdk = true appcfg { oauth2 = true } endpoints { getClientLibsOnBuild = true getDiscoveryDocsOnBuild = true } }

Answer1:

Found the problem! I believe it is the whitespace that I had in my web.xml document in the <param-value> element in the backend side of the project.

This

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> <servlet> <servlet-name>SystemServiceServlet</servlet-name> <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class> <init-param> <param-name>services</param-name> <param-value>com.ip.grademe.server.MyEndpoint, com.ip.grademe.server.UserEndpoint, com.ip.grademe.server.UniversityEndpoint</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>SystemServiceServlet</servlet-name> <url-pattern>/_ah/spi/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>

was changed to this

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> <servlet> <servlet-name>SystemServiceServlet</servlet-name> <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class> <init-param> <param-name>services</param-name> <param-value>com.ip.grademe.server.MyEndpoint,com.ip.grademe.server.UserEndpoint,com.ip.grademe.server.UniversityEndpoint</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>SystemServiceServlet</servlet-name> <url-pattern>/_ah/spi/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>

and it worked!

Recommend

  • Datastore admin - Unable to resolve the server's DNS address
  • “POST /_ah/mail/.+” returning 404
  • Using get_serving_url() for a image stored as blob property in datastore
  • GAE instance is serving on different url
  • Docker in Google App Engine Flexible health check has wrong URL
  • Handle Form Failure when uploading to Appengine Blobstore
  • Windows Phone 7 sniffer
  • Why is my event listener written in Google Closure not working?
  • GCM registration works for debug APK but not release APK
  • Saving image file path to sqlite database
  • How to avoid using dynamic variables / a billion if statements in Java?
  • Google cloud datastore emulator init data
  • Is Android development possible on netbooks? [closed]
  • Why isn't Kubernetes service DNS working?
  • Google OAuth2 for an web application hosted behind NAT (intranet server without public IP)
  • Why is OpenID Connect considered mobile friendly compared to SAML
  • Bootstrap Popover showing at wrong place upon zoom in/out or resizing Browser window
  • NHibernate proxyexception
  • How to resolve docker host names (/etc/hosts) in containers
  • Should I be afraid to use UDP to make a client/server broadcast talk?
  • How to map Request parameter in Spring?
  • JSON - slashes not escaping
  • CORS with socket.io
  • mave 3.2 not able to access local nexus instance return 502 code
  • Validate jQuery plugin, field not required
  • Android cannot disable cut copy paste
  • Thread 1: EXC_BAD_ACCESS (code =1 address = 0x0)
  • Tomcat memory Leak
  • ASP.NET MVC 2 Preview 2 - display directory list rather than home/index
  • Android app gives error “BatteryStatsImpl: reading network stats”
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Installing iPhone App to iPhone
  • Could not find rake using whenever rails
  • Meteor: Do Something On Email Verification Confirmation
  • Disable Enter in editText android
  • Cannot resolve symbol 'MyApi'
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Release, debug version and Authorization Google?
  • using HTMLImports.whenReady not working in chrome