I want to add the google play service to my project with gradle but every time I try to build/ run I get the following error:
Gradle: A problem occurred configuring project ':BPA App'.
Could not resolve all dependencies for configuration ':BPA App:_debugCompile'.
Could not find com.google.android.gms:play-services:4.2.42.
Required by:
BPA App:BPA App:unspecified
My build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
// maven { url "http://dl.bintray.com/populov/maven" }
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.google.android.gms:play-services:4.2.+'
}
Of course I have installed google repository and other things from the SDK-Manager.
The support-v4 and support-v7 libs works fine.
I´m new in builds with gradle. Before gradle I have imported the service-lib as a module and everything works.
Hope someone can help me.
There could be several things going on here:
You don't have installed the Google Play Services extra from the SDK Manager. So you can go there and install it. (Not just Google Repository, but Google Play Services itself)
If you got the extra installed, but Studio doesn't recognize it, maybe you're pinpointing the wrong SDK. It happens that Android Studio had its own pre-bundled SDK, so, if you got another one installed on your computer, you may be installing the extras in that one, and AS is triying to build with the one that has not the extras installed.
Check it out in Files>ProjectStructure and make sure you got the right SDK.
To get play services I usually go for:
compile 'com.google.android.gms:play-services:4.2.+'
This will give you the latest variant of 4.2 (i.e. 4.2.highest available incremental version)
Move mavenCentral() to the top, dependencies are resolved in top down order, if that still fails remove maven { url "http://dl.bintray.com/populov/maven" } as a test
I know that it is not the best practice not to mention the version of the compiled code but if you do not want to update your dependency section each time you update your google play services (using SDK manager), just put this reference in your dependency section:
compile 'com.google.android.gms:play-services:+'
Related
I received the Security Alert from Google Play regarding OpenSSL vulnerability. I do not use OpenSSL directly but one of the libraries that I am using could be.
I have updated everything including JDK, SDK, gradle, all possible libraries but still the OpenSSL version shows 1.0.1j for my app. I tried all the solutions mentioned in Stack Overflow, other websites and blogs but nothing changed. Given below are few links that I already referred:
Google Play and OpenSSL warning message
OpenSSL Security Alert Mail from Google Play for android apps
Update Android app to latest version of OpenSSL
Security Alert: You are using a highly vulnerable version of OpenSSL (Google Groups)
This is not a duplicate question because no answers of other questions could help me. Please help.
This is my app's build.gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.21.6'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
maven { url 'http://maven.localytics.com/public' }
maven() {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
lintOptions {
disable 'InvalidPackage'
abortOnError false
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
defaultConfig {
applicationId "co.myandroid.app"
minSdkVersion 14
targetSdkVersion 24
versionCode 29
versionName "1.0.0.19"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.6.0#aar') {
transitive = true;
}
compile('com.github.worker8:tourguide:1.0.17-SNAPSHOT#aar') {
transitive = true
}
compile project(':cropper')
compile 'com.android.support:support-v4:24.0.0'
compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.13.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.squareup:android-times-square:1.6.5#aar'
compile 'com.google.android.gms:play-services-analytics:9.2.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
compile 'com.google.android.gms:play-services-ads:9.2.0'
compile 'com.localytics.android:library:4.0.1'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}
First you need to make sure where does that library come from. AFAIK you can't check this in Settings -> Project dependencies, at least not in the stable version.
But you can go to your Android Studio Terminal tab, make sure you are in the root of the project, and type this:
Windows version: gradlew app:dependencies
Mac/Linux version: ./gradlew app:dependencies
That will print a nice dependencies tree and hopefully you can find openssl there.
IMPORTANT: These commands will only work if you are using the gradle wrapper. If you are on Mac or Linux, you might need to chmod 755 first to make it executable. If not using the gradle wrapper, then I guess you might be able to do the same just changing to your gradle directory (if not in the global path) and replacing gradlew for gradle in the above posted commands.
I'm new to android studio and had somebody write an app I made which was originally used in app inventor. I followed his template and added new things. The app has a problem with the Gradle and gives me the following.
"Error:(3, 0) Plugin with id 'com.android.application' not found."
It also says that my extras Android Support Repository isn't installed however it is. and everything is up to date. I saw many things about updating the Gradle, How do I do that if the SDK manager didn't.
code is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "contactorganizer.introcode.or.myapplication"
minSdkVersion 8
targetSdkVersion 21
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.android.support:appcompat-v7:21.0.0'
}
Sorry about not having much knowledge.
If you would like the project I can email it to you because I have absolutely no clue and would love to just build this.
Thanks for your help!
When I updated my Android Studio to the latest, I got the same problem. Here is how I solved it.
First:
Add the following code to the top of your build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Second: Find the gradle-wrapper.properties.
Change the last sentence to this:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Hope this works for you.
I have faced the problem too. The android plugin is 1.2.3. It appears when running one module task in the module directory like this way, ../graldew :module:xxx.
I eventually notice plugin 1.2.3 cannot get right context and android plugin 1.5 works well. So It will work to give it right gradle file.
../gradlew -b ../build.gradle -c ../settings.gradle :module:xxx
This is the situation for me. You can just regard it as a reference.
Android SDK Manager notified me this morning that there was a new Google Play Services release to download: revision 18. So how do I find the corresponding long version number to put in my build.gradle file? All my test devices are running version 5.0.84, so I tried updating
compile 'com.google.android.gms:play-services:4.4.52'
to
compile 'com.google.android.gms:play-services:5.0.84'
But that resulted in an error:
Gradle 'MyApp' project refresh failed: Could not find com.google.android.gms:play-services:5.0.84. Required by: {my app} Gradle settings
I'm running Android Studio 0.5.2 and building for API19 (I haven't upgraded to Android L/API20 yet): maybe that's the issue? But in general, how do you match a revision number shown in SDK Manager (e.g. 18) with a version code for build.gradle (e.g. 5.0.84)?
Here's my full build.gradle in case it helps:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
// Avoid "Duplicate files copied in APK" errors when using Jackson
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
// Was "compile 'com.android.support:support-v4:+'" but this caused build errors when L SDK released
compile 'com.android.support:support-v4:19.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
// Support for Google Cloud Messaging
// Was "compile 'com.android.support:appcompat-v7:+'" but this caused build errors when L SDK released
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:5.0.84'
// Jackson
compile 'com.fasterxml.jackson.core:jackson-core:2.3.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.3.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.3'
}
OK, I haven't quite managed to find a mapping of one to the other, but I've managed the next best thing which is to see a list of Play Services long version numbers installed on my development machine.
For Windows, it's in [android-sdk]\extras\google\m2repository\com\google\android\gms\play-services
(where [android-sdk] is the path to your Android SDK folder).
On a Mac, it's inside the Android.app package: browse to sdk/extras/google/m2repository/com/google/android/gms/play-services
The latest version on my machine was 5.0.77 (not 5.0.84), and putting that in my build.gradle worked fine.
Here's the kind of thing you should see at that location:
What I did in my project was download google play service and open the project structure > dependencies tab and click on the plus button and choose google play service. I dont have to care about the version anymore
I have created a template project from minimum & target SDK 15 and compile SDK Google Glass Sneak Peek.
Ive only added this code to the MainActivity Class:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Card card = new Card(this);
card.setText("Hello World");
card.setFootnote("santiapps.com");
setContentView(card.toView());
}
but the Card words are all highlighted red saying Cannot resolve symbol Card.
I checked a StackOverflow which pointed to dependencies, but I checked my 2 build.gradle files (cause I don't know which it should be) and they have:
Innermost build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 15
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
}
Outtermost build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Where dependencies are highlighted yellow saying 'dependencies' cannot be applied to groovy.lang.closure.
Ive clicked the button to resync gradle files but it doesn't get rid of the dependencies yellow warning.
I also get a red warning under the word google:
import com.google.android.glass.app.Card;
The other thing I noticed is that in a sample hello-world I downloaded I was able to see in File->Project Structure->PlatformSettings an entry for Android SDK but in my case I only get this:
So Im not sure what else to do. Thanks in advance (Android Studio 0.4.3)
You're not declaring the glass sdk dependency anywhere.
You'd either have to copy it from your $ANDROID_HOME/add-ons/addon-google_gdk-google-15/libs/gdk.jar to your local project and then add it to your dependencies like this:
dependencies {
compile files('libs/gdk.jar')
}
or upload it to a repository and then add it to your dependency section.
This was the solution for me:
http://b2cloud.com.au/uncategorized/google-glass-gdk-setting-up-the-project
It seems Android Studio doesn't specify that it must build that project with GDK even if you specifically tell it to when creating the New Project.
The previous answers are now outdated. Please don't directly include the gdk jar file.
Make sure you update Android Studio to the latest version (at least 0.5.5) and put:
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
in your app's build.gradle file. (For most projects, this is app/src/build.gradle.)
I am trying to include the library Slik and Cards-UI in my app, I'm using android studio and gradle to build. The app builds fine without this but adding the dependency make the build fail. Looking at the debug log of the build it doesn't seem to be looking in the local repo for the arr file. I can see the files are there and I have followed the tutorial on the github wiki page for the install and that works fine. The error is:
A problem occurred configuring project ':climbtrack'.
> Could not resolve all dependencies for configuration ':climbtrack:_debugCompile'.
> Could not find com.afollestad.cardsui:library:1.0-SNAPSHOT.
Required by:
ClimbTrack:climbtrack:unspecified
> Could not find com.afollestad.silk:library:1.0-SNAPSHOT.
Required by:
ClimbTrack:climbtrack:unspecified
Here is my build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenLocal()
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.afollestad.cardsui:library:1.0-SNAPSHOT'
compile 'com.afollestad.silk:library:1.0-SNAPSHOT'
}
The google play services dependency works fine and is found from the maven central repo as expected.
Any ideas anyone?
Thanks
This is bug https://code.google.com/p/android/issues/detail?id=63908
If you look at comment #3 in that bug, there's a workaround. Try it and see if it helps:
This appears to be a bug in Gradle 1.9 with local Maven repositories.
See https://plus.google.com/109385828142935151413/posts/hF7W59uZ7rX
The workaround for now is to use
maven { url "${System.env.HOME}/.m2/repository" }
instead of mavenLocal()
In Android Studio 0.4.6 using mavenLocal works fine:
repositories {
mavenCentral()
mavenLocal()
}
Check and configure your Maven installation on Preferences >> Maven to ensure it points to your local repository.
I hope this update helps newcomers.