cannot resolve symbol GoogleApiClient - android-studio

in my application I was using LocationManager and now I want to use Fused Location Services
I'm using Android Studio 1.1.0 and added google play service library in gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':pull_to_refresh')
compile project(':uil_library')
compile project(':viewPagerIndicatorLib')
compile files('libs/date4j.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.google.maps.android:android-maps-utils:0.3.+'
compile 'joda-time:joda-time:2.7'
compile 'com.github.shell-software:fab:1.0.5'
compile 'com.google.android.gms:play-services:6.5.87'
}
but when I define GoogleApiClient variable it says
Cannot resolve symbol 'GoogleApiClient'
So I click alt+Enter to import it but it show 'Add library 'google-play-service-6.5.8.7' to classpath' so I click it and when I run my app it show error
Error:(9, 41) error: package com.google.android.gms.common.api does not exist
Error:(23, 13) error: cannot find symbol class GoogleApiClient
How can I solve this problem and what caused it in first place .

I feel very Stupid :)
this gradle was in my main app but I was using GoogleApiClient in Library project so I must add compile 'com.google.android.gms:play-services:6.5.87' to my library too

Related

getting transformClassesWithJarMergingForRelease error in android studio

I am getting error while creating sign apk in android studio.
Following error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/HttpHeaders.class
My dependencies are following:
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile project(':wordPayLib')
compile project(':simple-crop-image-lib')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.+'
compile 'com.crittercism:crittercism-android-agent:+'
compile 'com.google.android.gms:play-services:10.0.+'
compile 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-messaging:10.0.0'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.googlecode.android-query:android-query:0.24.3'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.skyfishjy.ripplebackground:library:1.0.1'
compile 'org.jsoup:jsoup:1.10.1'
compile 'com.squareup:otto:1.3.8'
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'
compile 'org.apache.httpcomponents:httpmime:4.3.5'
}
I am not using any external jar in libs folder.
Please suggest me how to fix above error.
Thank you.

Android Studio - cannot resolve symbol 'Glide'

I'm trying to use glide in Android Studio to deal with Gif animation from a resource stored in R.drawable but i get "cannot resolve sysmbol 'Glide'".
I've added glide to my dependencies in the builde.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
}
and i'm using the following code to set the image view to the gif.
ImageView img=(ImageView)findViewById(R.id.catImg);
int resourceId = R.drawable.gangrycat;
Glide.with(this.context)
.load(resourceId)
.into(img);
I solved this problem by removing dependency from builde.gradle and sync my project, then again add glide dependency to project builde.gradle and sync again.
I have also solved this problem by removing dependency and then again add glide dependency to project builde.gradle and sync again
I was also having the same problem. Initially, I added the following dependencies:
dependencies {
...
implementation 'com.github.bumptech.glide:glide:4.14.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.0'
...
}
I just downgraded the glide dependencies version to 4.12.0 and synced again
and it worked for me.
dependencies {
...
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
...
}
Below Dependency should be Used
/**
* Glide :- https://github.com/bumptech/glide
*/
implementation 'com.github.bumptech.glide:annotations:4.14.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
implementation ("com.github.bumptech.glide:glide:4.14.2#aar") {
transitive = true
}

gradle fails at compiling sample project (appcompat-v7:23.3.0)

I'm trying to clone Udacity Android's Basics course project. I've cloned the project from GitHub and imported it in my Android Studio 2.1.2.
When I try to run it, gradle generates errors as follow:
Error:(24, 13) Failed to resolve: com.android.support:appcompat-v7:23.3.0
Error:(24, 13) Failed to resolve: com.android.support:appcompat-v7:23.3.0
Error:(25, 13) Failed to resolve: com.android.support:support-v4:23.3.0
I've updated all my SDKs but it still generates the error.
Also when I click on "Install Repository and Sync Project" link in the gradel messages, it says:
Following packages are not available:
Package id: extras;android;m2repository
Can anybody tell me what's wrong, why exactly gradle is not working, and how can I fix it?
Follow the simple steps:
1) Open any android project which is working on your SDK.
2) Open the build.gradle(Module:app) file.
3) copy the dependencies
eg:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
}
4) paste them in your current project.
5) Also see the
compileSdkVersion 24
buildToolsVersion "24.0.0"
They should match with what ever is written after v7 support library (android_support_lib_version).
6) Finally sync the project once again.

Android Studio (Gradle) cannot find Mockito

I try to use Mockito from within Android Studio 1.2.2 but I get the following error:
Error:(50, 17) Failed to resolve: org.mockito:mockito-core:1.10.19
The error occurs when I sync Gradle after adding the dependency manually. This is the dependency in my module Gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
testCompile 'org.mockito:mockito-core:1.10.19'
}
Could anyone help my resolve this issue?
Related questions:
Do I first need to download Mockito manually?
If so, where should I put it?
Note: the comments were helpfull to solve the above problem. However, it got me into another problem which I could not solve. But updating to Android Studio 1.3 solved it. I am now running Mockito from within Android Studio.
Try replacing testCompile with androidTestCompile, it works for me when importing Mockito libs.
However, you may run to a runtime error if you include only mockito-core. You'll need to add into your gradle:
androidTestCompile "org.mockito:mockito-core:1.10.19"
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
If you have error with dexcache, put this line into your setUp() (Assuming you are using InstrumentalTestCase)
System.setProperty("dexmaker.dexcache", getInstrumentation().getTargetContext().getCacheDir().getPath());
I was stuck into a similar problem, and adding the mockito jar file manually did the thing for me.
To do that, first create a directory called "libs" in your app directory. Take note that this directory should be in the same level as that of the src/main and build directories.
Next, download the mockito jar file and paste it into the libs directory.
Include that into your dependencies in the app level build.gradle file:
dependencies {
compile files('libs/add-your-jar-file-name-here')
}
Sync the gradle and that should do the job.
Refer to this answer for more detailed answer with snapshots.
androidTestCompile has now been replaced with androidTestImplementation
dependencies {
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'org.mockito:mockito-core:1.10.19'
}
Make sure the test file is located under $your_module/src/test/java or $your_module/src/androidTest/java directory.

Android error: package android.os does not exist

I have imported a project to Android Studio using Gradle. Import process was successful, but it gives an error for android.os.*, when I try to import it.
It is a libGDX project.
I suggest to use AGP Upgrade assistent.
I often have probs upgrading gradle. This time with artic fox and java 11 it I got all those infamous android.* not found errors.
Then I discovered that neat AGP Upgrade assistent (in tools since Studio 4.2) - and it did what it should and everything is now using gradle 7 and compiles again.
About time such a tool was introduced - and I just saw about half a year too late ;)
Recently, I met a similar case in Android Studio 3.2.1 Ubuntu/Linux version.
I am quite sure about the issue shall be related to the Android SDK installation,because I build the same project in Android Studio of my Windows 10 laptop.
Issue:
Java compiler error at Android studio
error: package android.os does not exist
error: package android.media does not exist
error: package android.content does not exist
error: package android.util does not exist
error: cannot find symbol variable Log
error: cannot find symbol class Context
error: cannot find symbol class AudioRecord
Solution:
The android.jar which was mentioned at the build.gradle file was not installed at the /sdk/platforms/ directory. See the android.jar dependency at my build.gradle file below(which caused the issue),
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files(sdkDir+'/platforms/android-24/android.jar')
}
Install the correct android platform(correct API level as mentioned in the build.gradle file,if any) and rebuild the project.
I am building from an old article, https://medium.com/#authmane512/how-to-build-an-apk-from-command-line-without-ide-7260e1e22676, and it doesn't yet have a build.gradle file, but I had the same error. I solved it by changing the compile command in my Makefile to:
classes: $(SOURCES)
javac -d obj \
-source 1.6 \
-target 1.8 \
-classpath src \
-bootclasspath $(ANDROID) \
$+
where ANDROID is /usr/local/src/android/adt-bundle-linux-x86_64-20130717/sdk/platforms/android-19/android.jar.
I get warnings now that source value 6 is obsolete, but at least it compiles.
In my case it was showing same kind of error with android.content.context
I figured out that the issue is I was using old gradle version with below android params in build.gradle
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
So I removed this and the error is no more.

Resources