Android: cannot import BaseGameUtils successfully in Eclipse - android

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

Related

eclipse android can not import google play services library

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

Android install external library

I want to use this library https://github.com/koush/ion in my project.But I don't understand how can I install it.I am using Windows 8 and Eclipse.How can I install ?
Download that project and put it in workspace of eclipse and import it from work space to eclipse and make it as library project and add it to your project.
Steps to import:
Right Click on package explorer
Import
Existing Project into Workspace
And then browse to the location where the project downloaded
Import it
Steps to add it as library to your project:
Right-click on your project -> Properties
In Android->Library section click Add
Select recently added project -> OK
That's it!
Now you can use it
You must perform the following steps:
Download ion project code.
Import it in your workspace using eclipse.
Right click in your current project and select Properties. The project properties windows must be opened.
Select Android option.
Go to the bottom of this tab and you can view the Library section.
Add the library dependency using the Add button.
I hope that helps!
You are probably better off downloading the jars vs the source.
https://github.com/koush/ion#get-ion
Download those two and place them in the "libs" directory of your project. If that directory does not exist, create it. From with your Eclipse project preferences, you can add those jars as dependencies.

Importing google-play-service library showing a red X next to this reference android

Am trying to add google-play-service library in my project using import(For Google map). After adding the path am getting red X next to this reference and the reference is not adding . Know how to resolve this ?
The red X means its a broken link path.
http://developer.android.com/google/play-services/setup.html
Copy the google-play services_lib library project to your workspace (folder where your android map project is). The library project can be found under the following path.
<android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib library project .
Import the library project to your eclipse
Click File > Import, select Android > Existing Android Code into Workspace, and browse the workspace import the library project. You can check if it is library project. Right click on the library project. Goto properties. Click Android on the left panel. You will see Is Library checked.
Right click on your android project. Goto properties. Choose Android on the left panel. Click on Add and browse the library project. Select the same. Click ok and apply
Eclipse does weird things when importing an existing project (google-play-services-lib), especially if you try to import and then allow the project to be automatically 'copied' to your workspace. I had the same issue and here is how I fixed it:
Close Eclipse
Erase all google-play-services projects from your workspace
Manually copy the google-play-services-lib folder (....sdk\extras\google\google_play_services\libproject\google-play-services_lib) into your workspace
Open Eclipse
Add a new project, choosing 'Existing Android Project', then navigate to your workspace and add the newly copied google-play-services-lib project
Finally, add the google-play-services-lib to your project as a library (just like you normally would)
Hope this helps! :)
Though it's over a year for this question but never the less thought of putting it down here. Might help some one facing a similar issue.
While doing a File -> Import one probably might have selected the folder,
C:\adt-bundle-windows-x86-20130729\sdk\extras\google\google_play_services\
instead of
C:\adt-bundle-windows-x86-20130729\sdk\extras\google\google_play_services\libproject\google-play-services_lib
Quite strange as Eclipse did not correctly copy the google-play-services_lib project in my workspace, but this caused a cross mark to appear in my Project Properties.
got a perfect solution for your question. this problem is due to improper referencing of library projects. You need follow these step.
create a new project
copy all the java files from src of your previous project in which you are getting error to the new project you have created just now.
Also copy layouts xml files.
now import play services you will not get this error.
I was also getting same problem.
I copied google library folder into work space and import now it's working fine.
Try to place the Google-play-service library with in your same working Directory by coping the files from Click File > Import, select Android > Existing Android Code into Work space, and browse the work space import the library project.
This is common issue Youur google-play-service-lib project and your android project should be inside the same folder For example
if your Android Appplication name is MyMap is in D:/workspace t hen your play service lib project should be in the same directory D:/workspace
Close Eclipse. Delete
.metadata
and
.recommaditions
folders from your workplace. Import your projects back.
You add Project in to your workspace.
Start Eclipse and import project one option is ther copy to workspace do it.
After that add google play services it also copy in to your work space
and add it your library hope so its working.

import a library into my project

I made a project and I want to use the slideMenu library but when I import it the package.R class will be undefined because the attr.xml that found in library res/values. like import offers.findme.com.R;
Try this ...
Once you download the file from site you mentioned and extract it to a given destination, all you have to do (if you're using Eclipse) is
File-->import-->Android-->Existing Android into Workspace , and select that
library location.
And to use it in your projects go to
properties>Android and add the new library.
Hope this helps...
if you use eclipse then start a new project say projectLib from library source
and then configure the build path of the project to include the projectLib and rember to export i with the app
alternatively you could copy the source and resources of your library to your project and instead of offers.findme.com.R look up for your.project.R
You should refer your library project in your android project.
import library project into your workspace and into eclipse.
Right click on your android project. goto properties. Choose android. Click add browse the library project and add the same.
Now clean and build.
For more info check the link below. The link has snap shots if you scroll down
http://developer.android.com/tools/projects/projects-eclipse.html
First you need to import the library as an Android Project.
Then you need to set it as your project's library, by Right-Click your project directory > Properties
There you can mark the library project as your project's library.
After that, Project > Clean your project.
The README file says the steps clearly.
Regards.
There are a invalid line in style.xml that prevent me to access the new library the line was id property

Cannot Add Library to Android Project in Eclipse

I am trying to add a Library to an existing project inside eclipse. I am keeping the Project Folder itself and the Library Folder in a folder marked "ANDROID" on my desktop. When I try to Import > Existing Code into Workspace > Select "ANDROID".. the only project that gets added is the App itself and NOT the library. I even try to add the library on its own and it will show up on the import list but will not have a "ticked box" with the option of "Finish".
I even right clicked my App - Properties > Android > and noticed that the library is there with a red "X" and does not allow me to search for a new library. What am I doing wrong?
This Identical App and library is working with the same version of eclipse for a friend and not me.
Make sure that the libraries and the project are at the same place, i.e.
Copy the libraries in the same folder as your project
Import the libraries (file > Import > Existing Project in workspace)
Open properties of library > Android and select Is Library
Open project properties > Android > Add (library)
Select the library
save the properties
If this does not work for you copy the jar files from its lib folder and paste it in the projects lib. This should only be done if the above method doesn't work
Import Library project in eclipse . Then right click on project and go to properties->Android (Menu on left side) --> At the bottom(below project build target) you will see a check box named is Library Check that box. Now you've made your project a library .
Then in your orignal project where you want to add library go again to to properties->Android (Menu on left side) --> At the bottom(below project build target) Click add button and you will find that library project visible.
This happens when you import the project from some location. If we import some project then it doesn't refer to the supporting library of that workspace. So always check the check box( copy projects to workspace)
Go to file>import project>browse>select a project>Check the copy project into workspace.
Hope it solve the issue.
A late answer, although I thought of giving an in-depth answer to this question.
First switch your folder structure from Android to Project.
Now search for the libs folder inside app - build folder.
Once you have pasted the .jar file inside libs folder. Right click on the jar file and at end click on Add as library. This will take care of adding compile files('libs/library_name.jar') in build.gradle
Now you can start using the library in your project.

Categories

Resources