I am working in Google App Indexing for my project.
Newbee for this feature. I just following the google guide lines.
Notify the google using API
In this page,asked to create an instance of GoogleApiClient. I tried but getting "GoogleApiClient cannot be resolved a type" error.
And I have added the following libraries into my project.
1.Google play services
2.Google api client
3.Google http api client
and
the error is
How can I resolve this error?
Copy the library project at /extras/google/google_play_services/libproject/google-play-services_lib/ to the location where you maintain your Android app projects (your projects folder).
Import the library project into your Eclipse workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it (browse to the google-play-services_lib folder).
In your app project, reference Google Play services library project (right click on project, Properties, Android, click on Add..., select google-play-services_lib folder).
After you've added the Google Play services library as a dependency for your app project, open your app's manifest file and add the following tag as a child of the element (this is a new requirement as of updated Google Play Services):
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Then add this statement in your class (or fix the error):
import com.google.android.gms.common.api.GoogleApiClient
For Android Studio, follow directions here:
https://developers.google.com/android/guides/setup
If you update SDK all...
Remove "google-play-services.jar" in libs directory.
Import google-play-services_lib project in SDK ([your-sdk]\extras\google\google_play_services\libproject\google-play-services_lib)
Click your Project > Right Click > Properties > Click Android > Click [Add] button in the Library section and add google play library.
And... Fix the Red alerts(?) :)
I hope this helps you...
Related
I have created an Android app in that when I imports Google Play Services library it removes R.java file.
I had clean and build the project and also restarts the eclipse but can't get the R.java file.
How to solve this problem?
Thanks.
As mentioned here : https://developer.android.com/google/play-services/setup.html#Setup
Here's different steps to proceed for setting up Google Play Services :
Copy the library project at /extras/google/google_play_services/libproject/google-play-services_lib/ to the location where you maintain your Android app projects.
Import the library project into your Eclipse workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
In your app project, reference Google Play services library project. See Referencing a Library Project for Eclipse for more information on how to do this.
Note: Don't forget to copy the library to your development workspace :
check your resource file error.
after solving your resource xml file error remove import android.R; from your java file and import com.your.package.name.R; in your java
Finally I got the solution myself.
I just changed the android:minSdkVersion="8" to android:minSdkVersion="14" in AndroidManifest.xml file and problem solved.
Thanks.
hello i am quite new to Android development and i want to learn how to use the google Maps API v2. After trying numerous tutorials, i always seem to have a problem with the google play services library. Somehow, Eclipse can't import it properly. I tried this tutorial https://github.com/thecodepath/android_guides/wiki/Google-Maps-Fragment-Guide and when i try to include Google Play Services project as a library, first it all goes nice and smooth, i get a green tick in the Project Properties - Android - Library window, but when i close it i still get lots of "can't be resolved to a type" errors. I return to the window where i add the library and i see a red "X" and a question mark under "project" instead of the green tick. I tried several other tutorials and i always have a problem with this library. I like this tutorial and i would really like to make it work. I also tried to manually copy the library folder in the workspace but that didn't work either. I googled like crazy trying to find an answer but i always find something that i tried before (like manually copying the library in the workspace or something similar). I am quite desperate, i really have no idea why it can't just see the library please help. Also this is my first post to StackOverflow so be gentle :)
later Edit (solved):
when i imported the downloaded project, i kept it on the desktop and thats why it didn't work, after i copied it in the workspace everything worked. Thank you all very much for helping a beginner :)
The important thing in adding a library in eclipse is to remember that your project and the library project need to be in the same workspace.
To solve this follow below ways,
You can copy the google-play-services library project to the same workspace where your main project is there.
else
While importing the library to eclipse remember to check copy projects into workspace which will add a copy of the library to your workspace.
I see a red "X" and a question mark under "project" instead of the
green tick.
The problem is -
The path to your google play services library is not same as the path to your project. It is outside of your project. And so is not recognized by simple import.
Solution - Put the library in the project's libs folder.
NOTE: Just putting the library to the libs folder is not enough.
After you added your library follow these steps -
1) Go to Project -> Properties -> Java Build Path -> Libraries -> Add JARs..
2) Now add your recently added jar to the build path from JAR selection process.
3) Go to Project -> Properties -> Java Build Path -> Order and Export.
4) Put a tick mark in the check box against this library name and press OK.
5) Do Project -> Clean.
if your giving google-Play-Service-lib as a references to your project , try to keep your project and the Google-play services lib should be in same drive.
if your project is on C: drive means place Google-play-services-lib in C:
While making the copy of the entire folder libproject containing google-play-services_lib from eclipse import project by selecting the copied libproject folder in your working place.
For the rest follow the steps in Setting Up Google Play Services
Eclipse
Copy the library project at
<android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/
to the location where you maintain your Android app projects.
Import the library project into your Eclipse workspace. Click
File > Import, select Android > Existing Android Code into Workspace
and browse to the copy of the library project to import it.
After you've added the Google Play services library as a dependency for your app project, open your app's manifest file and add the following tag as a child of the <application> element:
< meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Android Studio
Open the build.gradle file inside your application module directory.
Add a new build rule under dependencies for the latest version of play-services
eg
...
dependencies {
compile 'com.google.android.gms:play-services:9.2.0'
}
apply plugin: 'com.android.application'
Source developers.google.com
I want to use game api in my android project.
And I get started by following the instructions described in Google Site
(the part - Setting up your game project) from the following link.
https://developers.google.com/games/services/android/init
I have downloaded the library BaseGameUtils from this link
https://github.com/playgameservices/android-samples
Then I import it as a project as described in instruction.
However, what I've got is a project named main but not BaseGameUtils.
And then I cannot called its BaseGameActivity in my android project.
How can I solve it?
Same issue solved differently.
I've imported the BaseGameUtils project and also couldn't refer to it.
If you right-click the BaseGameUtils project that you've just imported and then go to properties > android and check "is library" you are able to refer to it in your app project.
Solved.
When importing project, not to select BaseGameUtils folder, but the root folder 'android-samples-master'. Then check the project named BaseGameUtils.
This worked for me:
Download code from github, https://github.com/playgameservices/android-basic-samples
In the downloaded folder copy the files from
android-basic-samples-master\BasicSamples\libraries\BaseGameUtils\src\main\java
to
android-basic-samples-master\BasicSamples\libraries\BaseGameUtils\src\main\src
Now import android-basic-samples-master as an android project.
Choose only BaseGameUtils , you'll get a project called main, right click project > properties > android
Add library and select google-play-services_lib and also tick isLibrary and OK.
Also add an external jar android-support-v4.jar by right clicking project > properties > Java Build Path > Add external Jar .
Now add this project named main to your actual project as a library. TADA !
SOLVED.
You must follow: From the command line run Scripts/make_eclipse_compat (or Scripts/make_eclipse_compat.cmd on Windows). This creates the directory structure needed to import the projects correctly.
Attention: android-basic-samples-master > Script/make_eclipse_compat.cmd
Ref: https://github.com/playgameservices/android-basic-samples
Adding to SEG.Veenstra's answer "....just imported and then go to properties > android and check "is library" you are able to refer to it in your app project" this link as there are problems in Google's documentation: Android Play Services Leaderboard cannot be installed (BaseGameUtils)
This is the original Directory structure from this playgameservices github link
android-basic-samples->BasicSamples->libraries->BaseGameUtils->
Change your BaseGameUtils project directory structure to this:
Now try importing this BaseGameUtils project into your Eclipse workspace.
Right Click on BaseGameUtils project->properties->Android->Check Is Library
Right Click on "YourProject"->properties->Android->Add->BaseGameUtils
Apply & OK.
Now BaseGameUtils is linked with your project
I cannot add google play service library project in my existing android app project to implement google map. Android dependencies are also not been added in the existing app project. It shows me error. I am always trying to add it from my saved sdk manager folder in my adt bundle but the library project is not added. Though I have imported the google_play_service_lib project in my package explorer. Please some body help me.
Thanks in advance.
RightClick On Project->property->Android->Add->select google play services lib ->Apply->ok
Go to: Your Drive:\android-sdk-windows\extras\google\google_play_services add it in your eclipse, if this will added if you have completed whole process of google map.
Make sure that your library and project in the same Workspace.
RightClick On Project->properties->Android->Add->select googleplayservices library->Apply->ok
Try Like this,
File>New>Project>Android>Android Project from Existing code>Browse: Navigate to adt-bundle-windows-x86\adt-bundle-windows-x86\sdk\extras\google\google_play_services> Select libproject
Then you can add this Library project in your own project.
Hope this will help.
Import the android project library "google-play-services_lib" in your Eclipse workspace.
File > Import > Android > Existing Project in WorkSpace.
Select path to google play services library. Click Ok.
Go to your Project Settings (right click project).
then go to Android Tab in left.
Under library section click ADD to add the library project. Apply the settings.
I have following problem:
I try to use SupportMapFragment from com.google.android.gms.maps.SupportMapFragment which is part of Google Maps Android API v2.
My first approach was to add project to Eclipse from android-sdk\extras\google\google_play_services\libproject\google-play-services_lib location and set it as referenced project in Properties -> Project References menu of MyApp. I also added project to Java Build Path / Projects. Error indicators disappeared from Eclipse but when I tried to run my app I got NoClassDefFoundError exception.
So my second approach was to copy jar file from google-play-services_lib/libs to my project's libs directory. MyApp succesfully started but in LogCat I can see dead code ... something message so I guess that jar file has to be referenced in another way.
And now I am confused and tired..
Maybe someone more experienced in Android can tell me what should I do ?
The quick start guide that keyboardsurfer references will work if you need to get your project to build properly, but it leaves you with a dummy google-play-services project in your Eclipse workspace, and it doesn't properly link Eclipse to the Google Play Services Javadocs.
Here's what I did instead:
Install the Google Play Services SDK using the instructions in the Android Maps V2 Quick Start referenced above, or the instructions to Setup Google Play Services SDK, but do not follow the instructions to add Google Play Services into your project.
Right click on the project in the Package Explorer, select Properties to open the properties for your project.
(Only if you already followed the instructions in the quick start guide!) Remove the dependency on the google-play-services project:
Click on the Android category and remove the reference to the google-play-services project.
Click on the Java Build Path category, then the Projects tab and remove the reference to the google-play-services project.
Click on the Java Build Path category, then the Libraries tab.
Click Add External JARs... and select the google-play-services.jar file. This should be in [Your ADT directory]\sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs.
Click on the arrow next to the new google-play-services.jar entry, and select the Javadoc Location item.
Click Edit... and select the folder containing the Google Play Services Javadocs. This should be in [Your ADT directory]\sdk\extras\google\google_play_services\docs\reference.
Still in the Java Build Path category, click on the Order and Export tab. Check the box next to the google-play-services.jar entry.
Click OK to save your project properties.
Your project should now have access to the Google Play Services library, and the Javadocs should display properly in Eclipse.
What i have done is that import a new project into eclipse workspace, and that path of that was be
android-sdk-macosx/extras/google/google_play_services/libproject/google-play-services_lib
and add as library in your project.. that it .. simple!!
you might require to add support library in your project.
Be Careful, Follow these steps and save your time
Right Click on your Project Explorer.
Select New-> Project -> Android Application Project from Existing Code
Browse upto this path only - "C:\Users**your path**\Local\Android\android-sdk\extras\google\google_play_services"
Be careful brose only upto - google_play_services and not upto google_play_services_lib
And this way you are able to import the google play service lib.
Let me know if you have any queries regarding the same.
Thanks
Some of the solutions described here did not work for me. Others did, however they produced warnings on runtime and javadoc was still not linked. After some experimenting, I managed to solve this. The steps are:
Install the Google Play Services as recommended on Android Developers.
Set up your project as recommended on Android Developers.
If you followed 1. and 2., you should see two projects in your workspace: your project and google-play-services_lib project. Copy the docs folder which contains the javadoc from <android-sdk>/extras/google/google_play_services/ to libs folder of your project.
Copy google-play-services.jar from <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/libs to 'libs' folder of your project.
In google-play-services_lib project, edit libs/google-play-services.jar.properties . The <path> in doc=<path> should point to the subfolder reference of the folder docs, which you created in step 3.
In Eclipse, do Project > Clean. Done, javadoc is now linked.