BaseGameActivity cannot be resolved - android

I am trying to implement the Google Play API into my Application.
Google says to import BaseGameUtils as library and add this library to my project:
this "main" is the BaseGameUtils, I have no idea why it's called "main".
However, here You can see that it's the BaseGameUtils project:
As You may see, there are the three classes, BaseGameActivity, GameHelper and BaseHelperUtils.
No when I try to import the BaseGameActivity I get following:
But strangely, I can import
com.google.example.games.basegameutils.*;
But when importing this, I still can't use the BaseGameActivity.class
What am I doing wrong?

One thing that you have done wrong is that you are trying to import BaseGameActivity into your application project.
I am assuming that you have already done this:
https://developer.android.com/google/play-services/setup.html
Then follow this:
https://developers.google.com/games/services/android/quickstart
In essence, you import the TypeANumber and BaseGameUtils code from the Android samples into your workspace (not into your application project).
Then you confirm that both Google Play services and BaseGameUtils are defined as library projects (Properties .. Android .. Is Library should be checked).
Then IN YOUR APP PROJECT add them as references (Properties .. Android .. Reference ..Add)
But I have just emphasised key steps that I suspect you may have misunderstood or omitted. You have to follow the whole thing carefully. Good luck !

Related

Importing a sample from an already imported library in android

In android studios, I have successfully imported a library called ChatKit(https://github.com/stfalcon-studio/ChatKit). The creators of the library were kind enough to include a fully working sample within the library. Instead of recreating the process I want to import the sample from the library into my project but android studios is not allowing me to do so.
In my main activity, I can add :
import com.stfalcon.chatkit.dialogs.DialogsList;
But when cannot add:
import com.stfalcon.chatkit.sample.ChatSamplesListAdapter;
So I'm curious what other people have done to import a sample from an already imported library.
Thank you.
import com.stfalcon.chatkit.sample.ChatSamplesListAdapter;
It happens because this class is not included in the library.
It is a sample file used as sample.
As you can see it is just a simple RecyclerView.Adapter then you can copy it in your project or you can use a own adapter.

cannot resolve symbol 'vrtoolkit'

As a newbe to cardboard, I have created a simple pano app in Android Studio by trying to duplicate the google cardboard sample simplepanowidget. The java activity class shows the vrtoolkit as being unresolved, e.g. in import statements such as:
import com.google.vrtoolkit.cardboard.widgets.pano.VrPanoramaEventListener;
I am trying to include the appropriate library but do not know which one it should be: is it libvrtoolkit.so or in a .aar archive?
The answer is pretty obvious (after unzipping and looking in the class tree for panowidget provided with the google cardboard sample): it is in panowidget.aar.

quickblox chat sample is showing errors

hello I try to implement open group chat feature in my android app by using quickblox android sdk
I import the sample chat from quickblox android sdk and import the core and chat jars as external jars through properties-> java build path-> library
and pull-to-refresh as a library through properties-> android-> add
I followed all the steps in quickblox docs
but still I get errors in splashactivity project
it shows error as R cannot be resolved to a variable. ........
a spend whole day but i did't get anything please could someone help me
I would put this as a comment but don't have enough reputation yet. Errors in your XML layouts can lead to this error (R does not get built if there are errors in the layouts), so check there first. If everything is good there, check your imports in the file you have the errors in. You might have a bad import; you should have something like:
import <package_name>.R;
If that is not referencing your current project you will have a problem.
Also, make sure you do a Project > Clean.

Cannot import google cloud endpoints client library class in Android project

I'm having difficulty getting Google Cloud Endpoints working. I have an Python endpoints project running on GAE and it works perfectly using the api explorer. However I'm struggling to properly generate the client library and use it in my android app. I've tried a number of sample projects and have the same problem every time; I can't import and use the model classes from the client libraries.
Here's what I'm doing (for this example I'll use the helloworld api python sample at https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-python)
Unzip the sample code
Generate the client library by navigating to folder and running
<gae-sdk>\endpointscfg.py get_client_lib java helloworld_api.HelloWorldApi
Unzip the generated folder and copy into root of project in eclipse
In Eclipse add "your_app_id_appspot_com-helloworld-v1-20140310110152-java-1.17.0-rc-sources.jar" to build path (Right click the JAR> Build Path>Add to Build Path)
At this stage, I can import com.appspot.your_app_id.helloworld.model.*but I cannot import com.appspot.your_app_id.helloworld.model.Greeting
Can anyone shed any light on what's happening here? I have tried many different ways to get this to work but have the same problem every time.
Many thanks,
Tom
The problem is that by default, the generated zip file only contains a sources jar, not an actual compiled library jar which your Android app can use.
Here's the solution:
In your backend api folder (from the same place where your app.yaml is located), generate the client library as a gradle library, like so:
<gae-sdk-path>\endpointscfg.py get_client_lib java -bs gradle helloworld_api.HelloWorldApi
You'll now have a helloworld-v1.zip. Unzip this (either right here or in somewhere convenient like ~/temp)
This will create a folder called helloworld, which should have a build.gradle in there along with a src folder.
Build your client library using "gradle install" in this folder.
Copy build/libs/helloworld-v1-1.X.X-SNAPSHOT.jar into your Android app's libs folder.
Add it as a library in Android Studio by right-click/add-as-library.
Your classes should now resolve correctly.
Step 4 should install the just-built client library into your local maven repository. You can follow the instructions in readme.html in the helloworld/ folder you extracted to integrate directly with your Android app's gradle build system instead of copying the jar your built manually.
This post said that there is a bug with Android Studio's Add As Library: Android Studio: IncorrectOperationException when 'Add as Library' is clicked whilst trying to configure Google Apps Endpoints client libraries
Not sure if it applies to Eclipse.
I was able to solve this problem and have provided the solution below.
I switched to Android Studio Preview 0.4.6 from Eclipse which helped get rid of some of Googles library import issues(through I guess build.gradle config). I feel it was not a problem of Eclipse which I was using earlier.
I was able to to fix the import issues. The code on the tutorial segments on the official Google docs needs to be put in sync.
The solution is to roughly do the following changes:
In MainActivity.java, replace:
HelloGreeting with HelloworldApiGreeting
In MainActivity.java, add the following at the top:
import android.widget.Toast;
import android.os.AsyncTask;
import android.util.Log
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreeting;
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreetingCollection;
In MainActivity.java, comment the following at the top:
import com.appspot.androidbackend1.helloworld.Helloworld.Greetings.Multiply;
import com.appspot.androidbackend1.helloworld.model.HelloGreeting;
In Application.java, add the following at the top:
import com.appspot.androidbackend1.helloworld.model.HelloworldApiGreeting;
In Application.java, replace:
HelloGreeting with HelloworldApiGreeting
Hope this saves time for others

Android The import com.google cannot be resolved

I'm trying to test LocationService example of Android developer as per following link http://developer.android.com/training/location/retrieve-current.html. At that time, error message show me that "The import com.google cannot be resolved" for following 5 lines. I'm really confused how to solve this problem.
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
You will need the Google Play Services SDK configured within Eclipse and import google play services as library will dismiss this error .
There is a much simpler solution. In my case, I've gone through all the answers from a few sources and none of them give a straight answer to my problem. Finally, I found a sample app source code and when I import the source code I found out adding the library from Google Play Service Library directory solved it. Google Play Service Library is located (for windows user) here:
\sdk\extras\google\google_play_services\libproject
Import the library into Eclipse as a library project and add this library in your actual project will fix it.
EDIT: This guy made a great contribution on his tutorials how to use Android Google Map v2 step by step and very details. It also includes how to use with Android Support package’s backport of fragments.
http://ddewaele.github.io/GoogleMapsV2WithActionBarSherlock/part1
Assuming you use Eclipse.
Right-click on your project -> properties -> Android.
There use Google API's instead of standard Android.
If you're using Android Studio:
Right click on your app folder -> Open Module Settings -> Dependencies -> Click on the plus button -> Choose library dependency -> Search for "play-services" -> Double click on the com.google.android.gms:play-services
Press Ok and wait for Gradle to rebuild.
You can use this way. First of all close projects which are using google-play-services library. Whenever your mouse over the com.google.android.gms import that can not be resolved and towards the bottom of the popup menu, select the "Fix project setup" option as below. Then it'll prompt to import the google-play-services library.
If you're using Eclipse, you can fix this by installing Google Play Services SDK via the SDK Manager, load the google-play-services-lib project into Eclipse, and set this as a reference from your project. This is documented at http://developer.android.com/google/play-services/setup.html
Do you use android sdk with google api? If not, do that and it will work.
set your project properties to google api.
You will need the Google Play Services SDK configured within Eclipse.
Maybe useful for some other developers facing this error:
If you are changing to a newer Android Version and if you are using the android-support-library, you have to beware that all projects that you use as library also have the SAME version of the android-support-library. One example would be the actionbar-sherlock. ;)
It Works = Do you use android sdk with google api? If not, do that and it will work.
In project.properties I had to add the following (for ANT build):
android.library.reference.1=${root_prefix}/${sdk.dir}/extras/google/google_play_services/libproject/google-play-services_lib
If you are using Android studio you may be missing to add gradle to your project.
Add specific play service you want.
Here you may want to compile
com.google.android.gms:play-services-location:10.2.1
Add this to your build.gradle app module in dependencies.
In android studio,add dependency as follows:
In gradle script,go in build.gradle(Module:app) and add these lines
compile 'com.google.android.gms:play-services:10.0.1' in dependencies tag
Here 10.0.1 may be skipped or changed according to your library installed

Categories

Resources