Location Update example for Android not working - android

I am trying location update example from following link
http://developer.android.com/training/location/retrieve-current.html#AppPermissions
It gave me some errors that I resolved by adding google play services, the application is building without errors, but when I am running it (both using AVD or real device) it is giving ClassNotFoundException and is not working.
I am using eclipse and ADT for my development
Adding error snapshot for reference

You need to add the lib android-support-v4.jar that is is your sdk.
Then, go to project properties (alt+Enter) -> Java Build Path -> Order and Export and then check android-support-v4.jar. Clean the project and it will work.
If you don't know how to ass a library you can co to properties -> Java Build Path -> Libraries tab and then click to add external jars.

Did you include the Google-play-services.jar file and also please make sure you have this metadata included in your manifest
for more details - refer
http://developer.android.com/google/play-services/setup.html

I think you should right-click on the Android project, choose properties, Java Build Path, and Checks the "Android Private Libraries" under "Order and Export".
You should tick something ;)
Check this out

Related

R.java not being generated for new Android project

When I create a new android project in Eclipse, and I choose to have a default main activity, my R.java file does not get generated.
I have seen some questions online and on this site about R.java not being generated but all are due to some manual action/mistake that had to be corrected during the development of the application.
However, does anyone know why R.java would not get generated for a brand new android project, where I have made no manual modifications whatsoever?
I think your problem is just the latest update of the SDK.
Test the following operations on two projects :
In the project properties (eclipse) -> java build path -> order and export make sure that all your jars in the libs folder are checked.
And "Android Tools -> Fix Project Properties"
And "Project -> Clean"
I hope you have helped!
ADT version 22 requires that you install "build tools". To get it to work i had to update:
SDK Tools
Platform Tools
Then install:
Build Tools
This link recommends you add build tools to your environment path. I had to do the following before the R.java was generated:
Append build tools to PATH environment variable
Restart Eclipse.
Make sure your project is free of errors and problems. You can use Windows-View to find and rectify them. Common mistakes are in the layout files.
Check the AndroidManifest file and see if the activity names match the classes in your source folder. Clean and rebuild.
R.java creates every time when you create android project first time r.java created by default
so check for the errors and clean the project.

For Android Map api v2 Description references non existing library google-play-services_lib\bin\google-play-services_lib.jar

I have import google-play-services_lib into my workspace and Add google project into MYProject it give mr error:
Description Resource Path Location Type
The container 'Android Dependencies' references non existing library 'D:\Android
Workspace\google-play-services_lib\bin\google-play-services_lib.jar' HBuddy Build
path Build Path Problem
Description Resource Path Location Type The project cannot be built
until build path errors are resolved HBuddy Unknown Java Problem
and I have already installed Google Play Service in Extras
I met this issue as well.
My solution is,
clean project google-play-services_lib firstly
then clean my project which depends on play service library
Hey i know what your problem is. I think it seems like you didn't built your google-play-services project... Try the following solution:
Import the google-play-services_lib "project" into your workspace
Add the freshly imported project to your applications build path
RIGHT-CLICK the google-play-services_lib project and select "Build Project"
Wait a few moments or "clean up" your project
Run your application and - Voila -
Please uncheck "Is Library" as follows ;
Your bin folder doesn't exist! You probably don't have permission to create a folder.
If you create a project from existing code make sure you check "Copy projects into workspace".
I found that the reference is looking at the wrong folder. It normally looks in <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/bin/ for the jar file and the file is actually inside the <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/libs folder. I couldn't find a way to change the reference link, so I just copied the jar file and the matching jar properties file from the /libs folder to the /bin folder.
I hope it helps.
My solution is,
clean project google-play-services_lib firstly
then clean my project which depends on play service library
There is another way to resolve this issue. Import google_play_services_lib project to your work space.
android-sdk/extras/google/google_play_services/libproject/google-play-services_lib
Then add the google-play-services.jar file externally.
right click on your_project -> properties ->java build path -> Libraries -> add External JARs -> select google-play-services.jar from work space ->clean ->build
It works for me.
I was facing the same issue and got it solved when I updated my eclipse Android SDK tools.
I was using version 22 and when I updated Android SDK tools to 22.0.1 the error vanished and I could build my project.
I hope this helps someone...
Check Read Only property of the Project folder.
If its checked, uncheck it and then try.

How to add google-play-services.jar project dependency so my project will run and present map

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.

NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager

Platform: MonoDroid v4.2.4
IDE: Visual Studio 2012
Minimum SDK version: API 12
I'm having runtime issues when trying to utilize the LocalBroadcastManager class included in the Android.Support.v4.Content namespace. In my IDE, I've explicitly added the reference and can scope the namespace/class fine, and, after writing some code, compiles as expected. However, upon application deployment and launch, I'm prompted with the error: "NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager"
Here's the code that prompts the runtime error (DSC_Discconected_From_Device is a class that inherits from BroadcastReceiver). It stops execution at the last line.
IntentFilter filter = new IntentFilter(UsbManager.ActionUsbDeviceDetached);
DSC_Disconnected_From_Device Receiver = new DSC_Disconnected_From_Device();
LocalBroadcastManager.GetInstance(this).RegisterReceiver(Receiver, filter);
Under the SDK manager, all the API packages are installed, as well as the "Support Library" package under extras.
Where is it looking for the definition of the class? I've presumably copied the source, LocalBroadcastManager.java, to paths in the android-sdk framework where it "might" be looking. For example: ..\android-sdk\extras\android\support\v4\src\honeycomb\android\support\v4\content\LocalBroadcastManager.java
Ideas?
Edit: Forgot to mention that my project already references the support library, android-support-v4, in the folder "libs", located in the root of my project. I had to create the directory and add it through Visual Studio.
This problem was hounding me for almost six months now and no solution was helping me but today I have managed to find the correct solution on my own.
When you select your project target version to be greater than or equal to Android 4.0, Android SDK includes "android-support-v4.jar" file in your projects "libs" folder. This jar contains all the classes and methods related Android 4.0 or later.
Android is trying to find the class definition which is in "android-support-v4.jar" so that means you have not configured the build path to the "android-support-v4.jar" file. To do this, follow these steps:
Open your project properties
Select "Java Build Path" from left side menu
Select "Libraries" tab
Press "Add External Jar"
(Most important step) Select "android-support-v4" jar file of "libs" folder from your CURRENT PROJECT LOCATION (path should be on your project folder and not the android sdk).
Select "Order and Export" tab and "TICK" the checkbox of "android-support-v4.jar"
That's it, you're done!
I had this error with android facebook integration.The reason was I had android-support-v4.jar library added to my project. Facebook sdk has already support library. So delete support library both from libs and from java build path If you are using a library already has support library in it.
in Android Studio 0.8.2
Press the green "+" in tab Dependencies of Project-Structure, then the keyboard key "1" (for libs) and choose the v4+ lib
If you have proguard enabled, try adding
# Local Broadcast Manager
-keep public class android.support.v4.content.LocalBroadcastManager
This fixed it for me.
You need to add the support library .jar file to the /libs directory in your IDE if it is Eclipse so that when the apk is made the Android packager will include that in your apk.
The problem seems to be related to the "properties" of the android-support-v4.jar library.
By default, the "Build Action" listed in the Advanced Properties in Visual Studio had a value of Content. I switched the value to AndroidJavaLibrary and the runtime error has disappeared.
However, the BroadcastReceiver isn't receiving the USB disconnect intent, hmm... Will update this answer accordingly.
Edit: I could never get a LocalBroadcastReceiver to work, so I had to use a regular one.
Just replace the android-support-v4.jar of your project that is in>libs folder with android-support-v4.jar present in FacebookSDK>libs folder

achartengine demo compiling, but runtime error

I followed demo instructions on page http://www.achartengine.org/content/goodies.html
i successfully imported the demo project, but every chart give throws
a NoClassDefFoundError at runtime, similar to this:
java.lang.NoClassDefFoundError:
org.achartengine.model.XYMultipleSeriesDataset
achartengine-1.0.0.jar is on build path, and it is reported under
'Referenced Libraries'. I guess this is a newbie problem, but I
decided to report it since I just imported the demo project 'as is'
and tried to run it on my phone.
Do I need other steps, not listed on 'goodies' page?
I found a good answer on google groups, tested it and it seems to be working:
The only thing that I have ever came across in this case is the export of the jar ... if that makes sense.
In Eclipse:
Right click your project - go to build path - select Configure build
path
go to the "Order and Export" tab
Check the "achartengine-1.0.0.jar box and then single click its name
move it up so its right below the Android dependancies (sometimes this can make a difference if you have multiple Jars)
click ok then clean your project. (Project -> Clean...)
Remind to change the "lib" directory to "libs" first !
Then CHECK the box of achartengine-1.0.0.jar and move it over the Android Dependencies in the "Configure build path" - "Order and Export" tab"!
The error (NoClassDefFoundError) you are seeing is runtime error. Referenced library solves only compile time error not runtime error. Add those jars to lib folder of your project. Those jars should be available at runtime also.
The answer from 'Shine' worked with the addition of removing import of android.R from PieChartBuilder and removing two #Overrides from PieChartBuilder and XY_ChartBuilderbefore Eclipse would agree to compile.
You need simply to add your jar files to the Libraries folder. It should work fine.

Categories

Resources