I have two Android Studio projects using Google Maps. One works fine, the other is unable to find com.google.android and so can't compile. Fails with
error: package com.google.android.gms.maps.model does not exist
Both have the same code in Manifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="4323000" />
Both have the same import statement.
build.gradle is:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:appcompat-v7:+'
}
I've read several similar questions on StackOverflow but those answers have no beneficial effect.
Any thoughts appreciated ...
Please add Google Play services to your project..
Google Play Services Rev 16 was added via SDK Manager, but it seems you have to manually add it via Project/Structure as a Dependency also. (You didn't do that on the project that was working already, but it does show up there, so somehow it added automatically in that case) So kindly add that manually..
Add this to dependencies:
compile 'com.google.android.gms:play-services:4.3.23'
And replace (or leave) 4.3.23 with version you need, i.e. 4.3.+
Related
I have tried to put Facebook ads in my application, which is earlier works with Google Admob ads. But while adding this line in my gradle file makes errors. compile 'com.facebook.android:audience-network-sdk:4.+'. I have also tried with the specified versions. But same errors.
Main error is
can't resolve Symbol R
I also tried clean, rebuild and Sync Project with Gradle file. But no response.
I have updated my Google play services, and Google Respirotory.
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 15
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.myapp.application"
minSdkVersion 15
targetSdkVersion 15
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':businessApp')
compile 'com.facebook.android:audience-network-sdk:4.+'
}
I can successfully build the gradle if I remove this line
compile 'com.facebook.android:audience-network-sdk:4.+'
There is no other errors in My app. If I need to change anything in Android studio to use Facebook Audience Network, or any other requirements?
After adding this dependency , sync your project and then click on Build-->Clean Project
I have this error :
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzrf.class
I want to add google play services to my project so i put this line in build.gradle file :
compile 'com.google.android.gms:play-services:7.8.0'
So I had to enable multidex and I followed android doc, adding this in build.gradle :
compile 'com.android.support:multidex:1.0.1'
and
multiDexEnabled true
I add this in android manifest :
<application
...
android:name="android.support.multidex.MultiDexApplication">
But I have the error I wrote above. I've found a lot of questions relative to this problem (app:packageAllDebugClassesForMultiDex) but not with that (duplicate entry: com/google/android/gms/internal/zzrf.class).
I tried some solutions like remove some google libraries but I don't know what refers to internal/zzrf.class.
Here is my gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "fr.djey.testgoogleplus"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:multidex:1.0.1'
}
I faced same problem. In my case I used home made Android library used by My Android app. Which means 1 project with 2 separate modules, while the app module depends on the library module.
Both have support of multidex. The root cause was inconsistency between google play services version. In the app module I used 7.8.+ and in the library I used 8.1.+. So I just updated both to same 8.1.+ and that fixed for me. So my answer is to check all the libs you depend on and may 1 of them using google play services version below yours.
Delete all files under build folder of that project. In my case, it is the jar file of the whole google play conflict with the jar file of only ads service.
As I said in the comment : I created another project and just did the same things : putting google play services and multidex, the problem didn't appear anymore.
I imported a project into Android Studio from Eclipse. It was building successfully in Eclipse.
At the end of importing process I got this error:
Gradle project sync failed. Basic functionality will not work
In the Gradle console I get the following error:
Error:Failed to find: com.android.support:appcompat-v7:20.+
I have already installed google support repository as mentioned in other places.
This is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.0.0"
defaultConfig {
applicationId "com.entujn.demo"
minSdkVersion 10
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:20.+'
compile files('libs/commons-lang3-3.3.2.jar')
}
local.properties:
sdk.dir=/home/pankaj/adt-bundle-linux-x86_64-20140702/sdk
SDK directory structure screenshot
Looks like the appcompat stuff is not present at the right place, how do I fix it ?
Looks like Android Studio uses another copy of SDK, which does not have Android Support repository installed. Please make sure it has all needed components installed.
I followed the instructions at this link to create a simple mobile/wearable app in Android Studio. However, it won't recognize any of the classes specific to the wearable SDK, giving the error "cannot resolve symbol ______". The screenshot at this link is what I am seeing.
The following is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.example.lsykora.androidwearwidget'
minSdkVersion 'L'
targetSdkVersion 'L'
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro'
}
}
productFlavors {}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v13:+'
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}
I have installed all SDK's using SDK manager and I have tried tinkering with the minimum, target, and compile SDK's in the build.gradle file, setting them to 19, 20, or Android-L, but I'm having the same results - program won't compile because of these unrecognized classes. Any input is appreciated! Thanks
Don't extend WatchActivity (that class doesn't actually exist).
The base class for Android Wear activities is just the standard Activity.
(Also, if you're using Android Studio 0.8.0, update to 0.8.1 -- 0.8.0 has a bug in its templates and creates new Activities using extend WatchActivity, which is actually invalid).
I followed the instructions at this link to create a simple mobile/wearable app in Android Studio. However, upon trying to run it I am getting the error "Failure [INSTALL_FAILED_OLDER_SDK]". My problem seems to be like the one asked at this link, however unlike that user the reddit post that is linked to didn't contain any information that helped me (it basically suggested to add < uses-sdk tools:node="replace" /> to the android manifest, but android studio didn't like the tools thing." My build.gradle files are exactly the same as those at the above link. I just updated Android Studio today (0.8.2) and have installed all necessary SDK's. Many people are getting this error but mine is unique in that I'm targeting the Wear stuff and not concerned with Android L. Any input is appreciated. Thanks!
I believe I have the answer here. Basically instead of deploying to the phone like the instructions say to, you have to enable bluetooth debugging and deploy directly to the watch.
Do those changes in build.gradle file in the wear module
compileSdkVersion 20
targetSdkVersion 20
So the final wear/build.gradle content will be:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "your package name"
minSdkVersion 20
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}