How to import com.android.location.provider? - android

How I can import com.android.location.provider for creating custom unbundled location provider?
I use android studio and I import .jar file but it doesn't work .
in java code I wrote :
import com.android.location.provider.LocationProviderBase;
but It makes error and compiler can't reference to the library .

Finally I found the solution. Library com.android.location.provider.LocationProviderBase is not in public android API which is implemented in android.jar and can not be used easily.For referencing to this library you should use reflection in java and linking process occurs at runtime.
OR
You should get source of this package and manually add it to your project.

You need to set up Google Play services.
Follow following link to set up the google play service:
https://developers.google.com/android/guides/setup
Add following lines to you gradle file:
dependencies {
compile 'com.google.android.gms:play-services:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
}
You can use following links for further information:
https://developer.android.com/training/location/index.html
http://www.vogella.com/tutorials/AndroidLocationAPI/article.html

Related

Flutter Android Support Library Not Recognized

I am writing a Flutter wallpaper app and am calling Android Specific code and I need to ask the user for some permissions, I need to import ContextCompat for that but there is not option to import in the quick menu, so I read online and manually did it.
import android.support.v4.content.ContextCompat
The problem is that Android Studio can't resolve the support symbol, I also read some forums online about that as well. The most common answer I found was to include add the android support library in the Gradle, which I have already tried but did not work.
Any help would be dearly appreciated.
com.android.support:appcompat-v7 should automatically take care of the dependency of ContextCompat
e.g. adding following in the dependency -
implementation 'com.android.support:appcompat-v7:26.1.0'
Here the version 26.1.0 would depend on your compile version.

Class symbol not recognized after module added

This is the library I am using. But I need to change the style java code. But since it's an external dependency, the file is read-only.
I learned here that if I add it as module I can then edit the file. I did that. I added the module successfully.
But now, the problem is how do I use the class from the library module. For instance, in my MainActivity.java, when I declared the global variable CarouselPicker carousel, Android Studio said 'Cannot resolve symbol CarouselPicker' and there is no Alt+Enter option to import any class. CarouselPicker is a class in the library. It worked when I used the library using compile in dependencies.
EDIT:
This is my Android file structure:
screenshot of Android file structure
This is the dependencies block code of my build.gradle(Module:app):
screenshot of code bloack
In my Share.java file, I tried to import CarouselPicker, this is what I get for Alt+Enter:
What Alt+Enter gave me.
please make sure that you have added the dependency line of the module in the gradle
see this for more details How to import class from another module in android studio?

Android Studio cannot resolve symbol utils when trying to migrate CSipSimple

I'm using CSipSimple. I followed the migration guide from Eclipse to Android Studio carefully and the only error that I am getting is
cannot resolve symbol utils
and is happening on below lines:
import com.actionbarsherlock.internal.utils.UtilityWrapper;
import com.csipsimple.R;
In build.gradle, I have added the following line:
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:19.0.+'
}
Does anyone know why this would be happening? Any suggestion will be of great help.
ActionBarSherlock-4.4 does not have the package utils.
Check the version that was used before migrating to Android Studio.
VenomVendor's answer already provides the reason: there's no UtilityWrapper on ActionBarSherlock. So, I'll try to provide the fix instead.
tqcenglish has a GitHub repo for Android Studio port for CSipSimple. Its readme says:
Change
/res/values/wizard_sipgate_string.xml
<string xm:lns:ns0="http://schemas.android.com/tools" /> -
<resources xmlns:ns0="http://schemas.android.com/tools"/> +
delete jni folder
add jniLibs folder and org.pjsip.pjsua to java folder
delete about quote UtilityWrapper
Reference
com.actionbarsherlock:actionbarsherlock:4.4.0#aar
This seems to give a hint of removing any reference to UtilityWrapper, including import com.actionbarsherlock.internal.utils.UtilityWrapper;. However, it might compromise something.
You're on the right path to use com.actionbarsherlock:actionbarsherlock:4.4.0#aar for the dependency.
Alternatively, I don't see any reasons why files under utils won't work outside of com.actionbarsherlock.internal package, so you should be able to copy all files from com.actionbarsherlock.internal.utils to your java folder, then replace the import statement to use the corresponding package.
If you get this error while trying to use OpenCV, import this:
import org.opencv.android.Utils;

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

android.support.v13.dreams.BasicDream cannot be resolved

I'm trying to work on extending BasicDream which exists in package: android.support.v13.dreams. I have tried downloading all most all android version (just trying luck to get it working) but I'm unable to import it. i.e. On
import android.support.v13.dreams.BasicDream; statement I'm getting an error:
The import xxxxxx... cannot be resolved.
I tried copying my sdk/extras/libs/../android-support-v13.jar in my libs folder and added to build path but found this package does not show dreams. While typing import statement I'm able to see v13 i.e. I can write import android.support.v13.app.*; but it does not have dreams/basicdream.
Tried google and do found the source code of this class but no idea why my jar file does not have these classes or how to use it. Please suggest what am I missing here.
Update: Finally I figured out that BasicDream was part of Android Support Library version 13 Link: BasicDream source codeshipped with android 4.1.2 however latest Android Support Library version 13 does not have Basic Dream.support library v13 class list
As I'm working on some native functionality, I downloaded BasicDream source code from the link mentioned above and included in same folder where I have my other source files. Updated the package to my application package
In your case probably the best way to get it is to check code of this class on GrepCode and manually resolve (copy) all dependencies. Good luck!

Categories

Resources