Error adding Google AdMob on Android libraries - LIBGDX project - android

I would like to add the Google library to my project libgdx in Android Studio. Currently I have done:
opened the SDK manager and downloaded play-services from the SDK manager,
added the compile string in build.gradle:
compile 'com.google.android.gms:play-services:8.4.0'
Clicked on File -> Project Structure -> choose the project and added the library play-services 8.4.0.
When I do the sync it gives me this error:
If I click on Install and sync repository project I get an error, this:
Another test:
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
If you manually add this library, after all the steps listed... I do not recognize them and it always fails. How do I add? Thank you.
also tried to Add Google Play Services to my project, but with unsuccess :(
My goal is to use AdMob banner.

Looks like at least a few people have had this error before:
Failed to resolve: com.google.android.gms:play-services-gcm:7.5.+
I would try opening the full-on SDK manager (Tools >> Android >> SDK Manager). You can manually download the Google Repository (and any other dependencies) using it.

Related

I can't import card library in my Android Studio

Today I install Android Studio in my new Pc, I tried to start a new project but I couldn´t because I have this error when I try to compile some new library of Material Design as CardView or RecyclerView, I was reading about this problem and I tried to do everything, I installed all SDK, I change the library versions a lot times, but I cant resolve this =(.
This is the picture of my error:
Please, any help will be greatfully. I can´t program if I dont resolve this.
Import with compile 'com.android.support:recyclerview-v7:22.2.1' , this should work with API 22.
Click on Sync now in the warning on top of the code window.
If it doesn't work, try Build -> Rebuild Project. Seems that your gradle file doesn't refresh automatically
If it doesn't work check in the SDK Manager that you have install all the SDK pachages needed for those libraries and rebuild again.
Add card view lib from Open module settings-> app -> dependencies-> + -> Library dependency. It will be perfect . this happens you have updated version 22 installed in your sdk and not the previous version 21 .
or use
compile 'com.android.support:cardview-v7:22.2.1'
just use
compile 'com.android.support:recyclerview-v7:22.2.1'
as the popup says the library you try to import doesn't work with android version 22
and to make sure you don't import outdated libraries like this import them that way.
1-
2-
3-

the import com.google.maps cannot be resolved (clustering.Cluster)

I am trying to use clustering in my application. However on the import statements I get 'the import com.google.maps cannot be resolved (clustering.Cluster).
Also, when using ClusterManager I get 'cannot be resolved to a type'.
The rest of the google play services are working fine.
Are you using Android Studio, or Eclipse? Might need to check your gradle file (Android Studio for example) to see if you have the library/module dependencies lined up. If you are using this library (https://github.com/googlemaps/android-maps-utils) for example, your gradle file should have something like :
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.3+'
}

Cannot resolve symbol 'google' [duplicate]

I am new to Android development. By following this tutorial I got errors The import com.google.android.gms cannot be resolved when I wrote the code into the MainActivity.java:
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
By searching for various fixes I made sure to try these out:
I have downloaded Google API's for a particular API level through
Android SDK manager.
I checked off Google API as project build target.
I have added <uses-library android:name="com.google.android.maps" />
line into the AndroidManifest.xml as a child of <application> tag.
I cleaned the project by selecting Project->Clean... and built it
from scratch.
I included .jar file for maps by right-clicking on my project, went
to build path and added external archive locating it in my SDK: android-sdk-windows\add-ons\addon_google_apis_google_inc_8\libs\maps
Unfortunately, none of the above have helped.
Another way is to let Eclipse do the import work for you. Hover 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. Select that and you should be good to go.
I checked off Google API as project build target.
That is irrelevant, as that is for Maps V1, and you are trying to use Maps V2.
I included .jar file for maps by right-clicking on my project, went to build path and added external archive locating it in my SDK: android-sdk-windows\add-ons\addon_google_apis_google_inc_8\libs\maps
This is doubly wrong.
First, never manually modify the build path in an Android project. If you are doing that, at best, you will crash at runtime, because the JAR you think you put in your project (via the manual build path change) is not in your APK. For an ordinary third-party JAR, put it in the libs/ directory of your project, which will add it to your build path automatically and add its contents to your APK file.
However, Maps V2 is not a JAR. It is an Android library project that contains a JAR. You need the whole library project.
You need to import the android-sdk-windows\add-ons\addon_google_apis_google_inc_8 project into Eclipse, then add it to your app as a reference to an Android library project.
From my experience (Eclipse):
Added google-play-services_lib as a project and referenced it from my app.
Removed all jars added manually
Added google-play-services.jar in the "libs" folder of my project.
I had some big issues because I messed up with the Order and Export
tab, so the working solution is (in this order): src, gen, Google APIs, Android Dependencies, Android Private Libraries (only this one checked to be exported).
In my case or all using android studio
you can import google play service
place in your build.gradle
compile 'com.google.android.gms:play-services:7.8.0'
or latest version of play services depend in time you watch this answer
More Specific import
please review this individual gradle imports
https://developers.google.com/android/guides/setup
Google Maps
com.google.android.gms:play-services-maps:7.8.0
error may occurred
if you face error while you sync project with gradle files
make sure you install latest update
1- Android Support Repository.
2- Android Support Library.
3- Google Repository.
4-Google Play Services.
You may need restart your android studio to response
Note that once you have imported the google-play-services_lib project into your IDE, you will also need to add google-play-services.jar to:
Project=>Properties=>Java build path=>Libraries=>Add JARs
Above solutions should solve your problem. If these do not, make sure you update your Android sdk using SDK manager and install the latest lib project and then repeat the above steps again.
once again Make sure these 2 things happen correctly nothing more than that.
(FOR ECLIPSE USERS)
1) copy the jar file from --> C:\Users(your-username)\android-sdks\extras\google\google_play_services\libproject\google-play-services_lib\libs\ google-play-services.jar
2) Right Click Project--> Build Path -> Add External Archive-> google-play-services.jar
In Android Studio goto:
File -> Project Structure... -> Notifications (last entry) -> check Google Cloud Messaging
Wait a few seconds and you're done :)
import com.google.android.gms.gcm.GcmListenerService should be resolved properly
I too had the same issue. Got it resolved by compiling with the latest sdk tool versions.(Play services,build tools etc). Sample build.gradle is shown below for reference.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.abc.bcd"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:23.0.1'
}
Supposing that you are using ECLIPSE:
Right click PROJECT
PROPERTIES
ANDROID
If you have a version of ANDROID checked, you must change it to a GOOGLE API.
Choose a version of GOOGLE APIS compatible with your project's target version.
In my case just add the below code to the build.gradle(:app)
implementation 'com.google.android.gms:play-services-location:16.0.0'
In my case only after I added gcm.jar to lib folder, it started to work.
It was here: C:\adt-bundle-windows-x86_64-20131030\sdk\extras\google\gcm\gcm-client\dist
So the google-play-services.jar didn't work...
I had the same problem so that the dumb API I decided as follows
changing the import line
import com.google.android.gms.maps.model.LatLng;

Can't import ActionBarCompat from Android Support Library using Android Studio

I am using Android Studio and have followed this article from google as well as some other articles discussing how to use the new ActionBarCompat.
I have downloaded the support library (Rev. 18) in Android SDK Manager and added the following in my build.gradle
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
}
Now I'm trying to import the Support Library API and extend ActionBarActivity in my code,
however, this is what showed up
which is not what it is supposed to be
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
Any Help?
I have the same problem. I followed this step to solved it, in Android Studio - Tools -> Android -> Sync Project with Gradle Files.
Edit:
Sorry, I forgot add this:
After Sync Project with Gradle Files follow this steps:
Right mouse click for your project and select Open Module Settings
After that, select dependencies tab
In the end - selec your library:
This should work.

The import com.google.android.gms cannot be resolved

I am new to Android development. By following this tutorial I got errors The import com.google.android.gms cannot be resolved when I wrote the code into the MainActivity.java:
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
By searching for various fixes I made sure to try these out:
I have downloaded Google API's for a particular API level through
Android SDK manager.
I checked off Google API as project build target.
I have added <uses-library android:name="com.google.android.maps" />
line into the AndroidManifest.xml as a child of <application> tag.
I cleaned the project by selecting Project->Clean... and built it
from scratch.
I included .jar file for maps by right-clicking on my project, went
to build path and added external archive locating it in my SDK: android-sdk-windows\add-ons\addon_google_apis_google_inc_8\libs\maps
Unfortunately, none of the above have helped.
Another way is to let Eclipse do the import work for you. Hover 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. Select that and you should be good to go.
I checked off Google API as project build target.
That is irrelevant, as that is for Maps V1, and you are trying to use Maps V2.
I included .jar file for maps by right-clicking on my project, went to build path and added external archive locating it in my SDK: android-sdk-windows\add-ons\addon_google_apis_google_inc_8\libs\maps
This is doubly wrong.
First, never manually modify the build path in an Android project. If you are doing that, at best, you will crash at runtime, because the JAR you think you put in your project (via the manual build path change) is not in your APK. For an ordinary third-party JAR, put it in the libs/ directory of your project, which will add it to your build path automatically and add its contents to your APK file.
However, Maps V2 is not a JAR. It is an Android library project that contains a JAR. You need the whole library project.
You need to import the android-sdk-windows\add-ons\addon_google_apis_google_inc_8 project into Eclipse, then add it to your app as a reference to an Android library project.
From my experience (Eclipse):
Added google-play-services_lib as a project and referenced it from my app.
Removed all jars added manually
Added google-play-services.jar in the "libs" folder of my project.
I had some big issues because I messed up with the Order and Export
tab, so the working solution is (in this order): src, gen, Google APIs, Android Dependencies, Android Private Libraries (only this one checked to be exported).
In my case or all using android studio
you can import google play service
place in your build.gradle
compile 'com.google.android.gms:play-services:7.8.0'
or latest version of play services depend in time you watch this answer
More Specific import
please review this individual gradle imports
https://developers.google.com/android/guides/setup
Google Maps
com.google.android.gms:play-services-maps:7.8.0
error may occurred
if you face error while you sync project with gradle files
make sure you install latest update
1- Android Support Repository.
2- Android Support Library.
3- Google Repository.
4-Google Play Services.
You may need restart your android studio to response
Note that once you have imported the google-play-services_lib project into your IDE, you will also need to add google-play-services.jar to:
Project=>Properties=>Java build path=>Libraries=>Add JARs
Above solutions should solve your problem. If these do not, make sure you update your Android sdk using SDK manager and install the latest lib project and then repeat the above steps again.
once again Make sure these 2 things happen correctly nothing more than that.
(FOR ECLIPSE USERS)
1) copy the jar file from --> C:\Users(your-username)\android-sdks\extras\google\google_play_services\libproject\google-play-services_lib\libs\ google-play-services.jar
2) Right Click Project--> Build Path -> Add External Archive-> google-play-services.jar
In Android Studio goto:
File -> Project Structure... -> Notifications (last entry) -> check Google Cloud Messaging
Wait a few seconds and you're done :)
import com.google.android.gms.gcm.GcmListenerService should be resolved properly
I too had the same issue. Got it resolved by compiling with the latest sdk tool versions.(Play services,build tools etc). Sample build.gradle is shown below for reference.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.abc.bcd"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:23.0.1'
}
Supposing that you are using ECLIPSE:
Right click PROJECT
PROPERTIES
ANDROID
If you have a version of ANDROID checked, you must change it to a GOOGLE API.
Choose a version of GOOGLE APIS compatible with your project's target version.
In my case just add the below code to the build.gradle(:app)
implementation 'com.google.android.gms:play-services-location:16.0.0'
In my case only after I added gcm.jar to lib folder, it started to work.
It was here: C:\adt-bundle-windows-x86_64-20131030\sdk\extras\google\gcm\gcm-client\dist
So the google-play-services.jar didn't work...
I had the same problem so that the dumb API I decided as follows
changing the import line
import com.google.android.gms.maps.model.LatLng;

Categories

Resources