Cannot import com.google. .... why? - android

I am simply trying to compile and run the example project from: http://developer.android.com/training/location/geofencing.html
I get the following errors:
package com.google.android.gms.common does not exist
package com.google.android.gms.location does not exist
package android.support.v4.app does not exist
I have tried the following already:
I have download Google API already, see screenshot of my SDK Manager window.
I saw different related posts but have not been successful in compiling this yet - even tried restarting computer.
Screenshot of my SDK Window showing Google API Installed: http://postimg.org/image/xf64h3fu3/

You need to add the Android Support library to your project.
http://developer.android.com/tools/support-library/setup.html
"In order to use a Support Library, you must modify your application's project's classpath dependencies within your development environment."

Please find below Steps to need to follow after downloading it:
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"
This will add google play service project into eclipse
Now, Right click on your project (not google play service project) and select "Java Build path".
Select Libraries Tab and click on "Add Jars" button. Locate google_play_service project(NOTE: google play service project should not be closed in pkg explorer window) and add libraries from lib folder and click ok.
(if still not appearing libs then follow this steps) Again right click on your project, select properties and select "Android" option.
From left panel, select "Android" option.
Under "Library" section, you will see "Add" button. Click on that button and locate "google-play-services_lib".
Then click on Apply. It will be added to your project. :)

Related

unable to run android project as eclipse considering it as a library

I was working with Google Map in Eclipse ADT. I followed this and this tutorial. Everything went smooth. However, right now, when I tried to build the project, Eclipse is saying
"Android Library projects cannot be launched"
I tried again from the beginning thinking that I might have clicked some wrong check boxes however the error still persist. The only library project I have imported is the google play services libs.
Any help would be great. Thanks :)
This error is coming because of the fact that you have checked the box "Is Library" in the Properties option for your project. Please uncheck that checkbox and you wont see that error again. Your proejct is a app project which is referencing Google Play Services, which is a library its referencing but your project is not a library, hence you have to uncheck that checkbox as library projects cannot be launched as they do not contain .apk file.
Here are the steps to run the Map project as a app project and not as a library:
- In the Package Explorer, right-click the library project and select Properties.
- In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
- **Do not** select the "is Library" checkbox and click Apply.
- Click OK to close the Properties window.
Make sure that you have declared your fragment activity in your manifest file with Internet and Map Receive permissions.

Unable to configure Facebook SDK in eclipse

I did all the steps according to the facebook tutorial on how to configure the facebook SDK, and without any luck, also tried the github configuration as shown Android Facebook SDK configuration on Eclipse
And I'm still getting in the eclipse environment a "!" sign by the side of the project I included Facebook to it. and when trying to run, it says I have errors.
Without the Facebook SDK I managed to work great on my project and run it, so it is not a problem with my project..
What can I do?
I was trying to get started using Facebook's SDK for Android with Eclipse and couldn't get it to work. After trying different things here is the solution that consistently works:
1) Import (File->Import->Existing Android Code Into Workspace) just the Facebook SDK folder alone (PATH\facebook-android-sdk-3.0.1). (Do not check the copy to workplace)
2) Import (i.e. PATH\facebook-android-sdk-3.0.1\samples\ProfilePictureSample) just one of the sample projects (for now). I will be using ProfilePictureSample as an example
As you can see, Eclipse throws errors saying that it doesn't know what FragmentActivity in ProfilePictureSampleActivity. FragmentActivity is part of the android support library. If you take a look at the package explorer, there is not a libs folder or any reference to the android support lirbary; It is on the FacebookSDK library. We need to tell Eclipse to export it.
4) Right-Click on the FacebookSDK library then click on properties. On the left menu go to Java Build Path. Then under the Order and Export tab check Android Private Libraries (you can also click on the android-supportv4-jar instead).
5) Project->Clean
Now for some reason (maybe somebody can elaborate on this), the sample project also needs to export the android support library.
6) Right-Click on the sample project (i.e. ProfilePictureSample) then click on properties. On the left menu go to Java Build Path. Then under the Order and Export tab check Android Private Libraries.
7) Project->Clean
Hopefully this helps!!
please set the Android Api for this project by this steps below
Rightclick on project->properties->android->set android Target version
Also remove Facebook library project once and again add it.
The problem was that the path to the android-supprort-v4.jar wasn't correct..
Fixed it by setting the correct path.
Import the sdk without copying the project to workspace. this solution has worked for me and does not present any errors

"Android library projects cannot be launched" in Facebook Android tutorial

I installed both the Android and Facebook SDKs. I did all the steps in http://developers.facebook.com/docs/mobile/android/build/#sdk till Step 6.3.
In step 6.4, when I try to run the project in Emulator (Using Android 4.0.3), I get "Android library projects cannot be launched" and the project doesn't proceed further. Even the logcat doesn't have any content.
Can someone please tell me what may be the problem?
Thanks
Souvik
Folow these steps
1. In the Package Explorer, right-click the library project and select
Properties.
2. In the Properties window, select the "Android" properties group at left and
locate the Library properties at right.
3. Select the "is Library" checkbox and click Apply.
4. Click OK to close the Properties window.
Library projects cant be launched. you can use that in your project and run your project adding it as library.
It would be much better to have the Facebook sdk as a Library so you can simply #import the sdk file into eclipse. Simple. I spent a day trying to get the sample source into a project to test the post on wall. I get the app to run but no breakpoints get called in my project, I had to create the build.xml and not sure if that is the cause. It would be better if the whole test project files were included instead of only the resources and jar files. That way you could just import everything and it should work within 5 mins.

How to run example Android code

I'm going through some of the Android tutorials and am having trouble running on of the example projects. This page explains how to put ads in a project and it links to an example project (http://dl.google.com/googleadmobadssdk/examples/android-banner-essentials.zip). I downloaded the project, but I don't know how to run it. I tried "Import" in Eclipse, but I couldn't find any way to do it. I also tried making a new project, then deleting all the files and replacing them with the files from the example, but then it says "Resource is out of sync with the file system: '/AndroidBannerXML/AndroidManifest.xml'".
In Eclipse :
From the Eclipse menu, click File > New > Project...
From the Select a wizard window, select Android > Android Project from Existing Code, click Next.
From the Import Projets window, set Root directory to where the samples are (normally C:\Android\adt-bundle-windows-x86\sdk\samples\android-17\ ); check Copy projects into workspace; click Finish.
The sample application will appear as a project in the Package Explorer.
Run the package as you would any Android project (Run > Run As, ...).
Ok, in Eclipse, click
File
New
Project
select Android Project
Then check the radio button labeled "Create Project from Existing Source"
Then just browse to the project. It will fill in most of the data needed like API level.
PS: For a good tutorial on adding adds, see the link, there is about 6 videos elling you how to add admob and publish your app.
http://www.youtube.com/user/thenewboston#p/search/0/8IerupLaakE.
try to right click on project and refresh to sync files
If you don’t install any ADB Driver then you need to download it first from the link here : click here:
http://developer.samsung.com/android/tools-sdks/Samsung-Andorid-USB-Driver-for-Windows
Install the driver in you windows.
Now you open your android code and right click on the project you have made or create a new project and make a program that you want to run. I have already made a SilentToggleMode code. Just right click and go to Run As > Run Configurations.
Then you can see a configuration window. You need to expand Android Application > SilentToggleMode. On the right, you go to Target and enable by click Always prompt to pick a device.
After that click Apply from the bottom of the window. Now you can click Run from the window bottom or close the window and click Run from the eclipse menu bar and choose your application. Then you can see a window from which you can choose your android device, you select it and click OK.
You will be happy now to see that your program is running in your device.
For details, Please follow the link below:
Run Android Program on Android Device

How do i open a sample Android SDK app in Eclipse

I have created a basic program in Eclipse for Android 2.1. then I wanted to look at some of the samples, and import sample projects which are in the SDK directory. I have tried opening a new project and 'create project from existing source', I browse and can select a project, all the details come up and I can click finish, but I receive an error message saying 'could not write file', and if I click on details, it says "access is denied" I have tried copying a project folder into my own workspace but it still does the same thing.
Right click in the package explorer window.
Select New -> Other
Under the Android folder select Android Sample Project
Choose the build target and then the sample project
In the new android project window there should be three options:
1. Create new project in workspace
2. Create project from existing source
3. Create project from existing sample
(The third one is a bit hidden, as there is a text box, and check box below the second item before the third one.
Select #3, then select the api level you want the sample for (in the list below), then you can select a sample from the now non-grayed out list.
This is security issue:
Go to you android SDK directory in my case (windows 7, 64 bit) its "C:\Program Files (x86)"
Right click on Android directory and choose 'properties'.
Go to 'security' tab and click on 'Edit'.
Choose Users from the list and tic on 'full control'.
Apply.
1- In Eclipse->Window->Preferences->Android, make sure you have set the SDK Location then Apply and press OK
2- Select File->New->Android Project
3- Click on Create project from existing samples
4- Select the SDK version and select the sample you want
Try this in ADT.
File --> New --> Project.. --> Android Sample Project(Inside Android) --> (Select your build target) and finish. If you installed the sample projects, it will show the list of projects. Select and open.
If you want to import sample projects into Eclipse, do the following:
Click the File menu on the top left of the Eclipse screen.
Select Import.
In the pop-up menu, select Existing Projects into Workspace.
In the next pop-up menu where it says Select root directory, click the Browse button
Browse to the folder where your sample projects are located. Each project should be inside a folder by itself.
Select the folder.
Click the OK button.
If it is a complete project, it will be imported into Eclipe where you can run it, and modify it if needed.

Categories

Resources