Cannot resolve symbol 'android' in Import - android

I am getting error in Android Studio. My import:
imports com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
are not working.

Use
import com.google.android.gms.common.api.GoogleApiClient;
instead of imports to import a class.

Download new version of google-play-services library.
Always update/download newest version of google-play-services library.

you must add
compile 'com.google.android.gms:play-services-location:7.8.0'
in dependencies block, in app/build.gradle.
also update google play in sdk manager

Related

import android.support.v7.app.AppCompatActivity not found

I have recently migrate one project in androidx .This project working fine . Now when i am opening other project in android studio i am found in all other project i am getting error
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
these all package not found i have not changed any thing other project . Why android support libraries not workig with other project. Please help me how can i run android support lib again this android studio .I have done already invalide chache and restart and also clean project but no luck
You need to use androidX dependencies like this:
import com.google.android.material.navigation.NavigationView;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
Make sure you have updated your app.gradle too
api 'androidx.appcompat:appcompat:1.1.0-rc01'
api 'com.google.android.material:material:1.1.0-alpha08'
You also need to add the following to gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Once you update your gradles and delete the old dependencies Android Studio should find the new ones.
Add the support library to the dependency section.
implementation 'com.android.support:design:28.0.0'

Cannot resolve PlaceAutocompleteFragment with 10.2.0

I'm trying to add a PlaceAutocompleteFragment to my activity, this are all the imports I'm using:
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlaceAutocompleteFragment;
import com.google.android.gms.location.places.ui.PlaceSelectionListener;
I was following this tutorial, so initially my app gradle had compile 'com.google.android.gms:play-services-location:8.4.0' with this version all the imports above work perfect, but I want to use a newer version.
The problem is that with compile 'com.google.android.gms:play-services-location:10.2.0' none of the imports work and it cannot resolve any of those classes. Same for 9.4.0.
I have clean, rebuild and re sync the project but the error persists.
What could be wrong?
I'm using Android Studio with
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
Places has split out into its own library since the tutorial was written
Add
compile 'com.google.android.gms:play-services-places:10.2.4'

Android : Google Cloud Messaging Error

I'm following a tutorial and I've pulled the google gms git repository.
I'm getting an error "cannot resolve symbol android" when I import
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;
I have updated google play services. Here's my gradle -
...
compile 'com.google.android.gms:play-services-gcm:8.4.0'
}
Where am I going wrong??
Try This code. It's very simple and easy steps.
Link: https://github.com/googlesamples/google-services/tree/master/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart
Hope it works for you.
Check the base package and make sure the gradle is updated

Cannot Resolve Symbol Google API Client in Android Studio

I'm getting an error in Android Studio for the following:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API).build();
I have put this in my manifest,
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
and compile 'com.google.android.gms:play-services:6.5.87' in my gradle dependencies.
I've downloaded the required sdk files as well.
Why do I still get this error?
For the benefit of searchers:
If you are following the android tutorial that relates to this, you can add the dependency via the UI.
In Android Studio, go to File > Project Structure.
Go to the dependencies tab.
On the right hand side add a 'Library Dependency'.
Type "com.google.android.gms:play-services" into the searchbox and pick the appropriate dependency.
Then follow #Dmac's answer
Even though not officially listed in the tutorial, you must use the following imports:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
I had to do the following to get my app to compile successfully:
Update my build.grade with 'com.google.android.gms:play-services:<version>'
Add imports as needed:
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
In Android Studio: File --> Invalidate/Restart...
Clean build
I had this problem, only with import com.google.android.gms.common.api.GoogleApiClient;I unfortunately had moved <meta-data android:name="com.google.android.geo.API_KEY" android:value="#string/google_maps_key" /> after its relative activity <activity android:name=".MapsActivity" android:label="#string/title_activity_maps" ></activity>. I returned to previous state and the problem was solved.
Add following lines to your dependencies to use Google Places Api interfaces
dependecies{compile 'com.google.android.gms:play-services:11.2.0'
testCompile 'junit:junit:4.12'
}
Just to log the problem.
This happens when there is version conflict. Check the build message, and it will suggest the version you should be importing.
The classpath version in main gradle (classpath 'com.google.gms:google-services:3.1.0') should be complaint with the version of jar included in the app gradle (compile 'com.google.android.gms:play-services-auth:11.0.0')
the question is old ,but now that GoogleApiClient is deprecated I found out that I can't use it anymore and that one should use its substitute,
subclasses of GoogleApi .

Error package `com.google.android.gms...` doesn't exist

I am new to Android development. I am learning to use Parse.com backend service and get stuck early on.
I am following tutorial to create application that uses Google Maps Android API v2. What I've done :
download sample
project from parse
Import AnyWall-android\Anywall folder from downloaded project to Android Studio
Rebuild project
Then I get a bunch of errors here :
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;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap.CancelableCallback;
import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
common, location, and maps highlighted red. The question is how to resolve these errors?
I appreciate any kind of help or direction (What should I check? Is it about missing library? If it is, what library should I add and where to get it?)
Can't find the class com.google.android.gms.location.LocationClient (android)
There is some problem with the last GPS lib. You have to use an older version than the latest(6.+). Try with an older version. I didn't see anything inside the doc deprecated or missing about the LocationClient.class...
compile 'com.google.android.gms:play-services:5.+'
I think the best solution is, add compile API on your Gradle. services-location has this method.
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
if you wish to include other services, please refer here:
https://developers.google.com/android/guides/setup (scroll down)
Google Play Services is now modular, you can select the packages you want from it.
To get analytics add:
compile 'com.google.android.gms:play-services-analytics:7.3.0'
to you build.gradle's dependencies section
P.S
replace 7.3.0 with new version as they arrive, or replace with "+" to always get the latest
Android Studio is complaining that it can't find the Play Services library.
Follow the steps here to ensure Google Play Services SDK is installed (specifically, make sure 'Google Repository' is installed along with 'Google Play Services'): http://developer.android.com/google/play-services/setup.html#Install
Then, make sure the following is added to the dependencies{} block in your build.gradle:
compile 'com.google.android.gms:play-services:+'
Clean and rebuild.
Add this line you build.gradle in Gradle Scripts folder
dependencies {
compile 'com.google.android.gms:play-services:11.2.0'
}
with this i solved this issue.
Previous answers were correct.
But in gradle:3.0 the compile configuration is now deprecated and should be replaced by implementation or api.
Check out more information in the documentation - API and implementation separation.
Its just a common mistake in my case, I just remove default ""flutter:"" keyword in pubspec file while managing package

Categories

Resources