I want to use some Google services in my application, so I have added this line to the .gradle file: com.google.android.gms:play-services-gcm:8.7+. But after trying to sync the project I got this error:
Failed to resolve: com.google.android.gms:play-services-gcm:8.7+
I checked all the available answers on Stackoverflow. They suggest installing the sdk for Google repository and Google play services and I did that. Here is a screenshot of the sdks installed on my computer:
Here is the gradle file code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.project.android.eyedetection"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/localization/LocalizedFormats_fr.properties'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile project(':libraries:opencv')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services:8.7+'
compile files ('libs/commons-math-2.2.jar')
compile files ('libs/commons-math-2.2-javadoc.jar')
compile files ('libs/commons-math-2.2-sources.jar')
}
I tried to remove the +, but that didn't solve it.
How can I solve the problem?
EDIT: As suggested by Stanojkovic and Gabriele Mariotti using 8.4 solves the problem, this is because I was mistakenly trying to use 8.7 which is not released yet. Thanks all.
Try with
com.google.android.gms:play-services-panorama:8.4.0
Your issue depends by
compile 'com.google.android.gms:play-services:8.7+'
This version is not published yet (the apk is still in rollout, but the library is not public in the IDE)
Use the last stable release:
compile 'com.google.android.gms:play-services:8.4.0'
Related
I can't stop getting this error every time, and I don't know what caused it and how I can solve it:
Multiple dex files define Lcom/google/android/gms/location/places/zza;
I think it may have to do with google-services, but I'm not entirely sure.
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.xxxx.xxxx"
minSdkVersion 14
targetSdkVersion 28
versionCode 10173
versionName "4.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// Fixes "Duplicate files copied in APK" build bug
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
// Pushy SDK
implementation 'com.google.firebase:firebase-messaging:17.5.0'
compile 'me.pushy:sdk:1.0.43'
// AppCompat v7 Dependency
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.google.android.gms:play-services-maps:16.1.0'
compile 'com.google.android.gms:play-services-places:10.2.0'
// Google Play Services Dependencies
compile 'com.google.android.gms:play-services-location:16.0.0'
compile 'com.google.android.gms:play-services-ads:17.1.1'
// All .jar files in ./libs
compile fileTree(dir: 'libs', include: ['*.jar'])
}
apply plugin: 'com.google.gms.google-services'
If your app has more than 65535 methods, you need to enable the multidex format for your app.
This can be caused by having lots of dependencies in your project.
I am having trouble building my app all of a sudden.
the error:
Error:Execution failed for task
Duplicate files copied in APK lib/x86_64/libogg.so
File1: C:\Users\name\.android\build-cache\72c018be052ae391eef4ab43483d6a04be10a818\output\jni
File2: C:\Users\name\.android\build-cache\425f82e82c18acce2ff0ced2ade670804d31a815\output\jni
I have attempted to fix using packaging options:
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LGPL2.1'
}
entire file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LGPL2.1'
}
defaultConfig {
applicationId "myappsid"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v4:26'
compile 'com.android.support:support-vector-drawable:26'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'
compile 'com.ibm.watson.developer_cloud:java-sdk:3.9.1'
testCompile 'junit:junit:4.12'
compile project(':library-release')
}
any help is greatly appreciated. I have tried longer exclude options as well in other posts that I have found but that didn't help either.
You can try using pickFirst in packagingOptions. You need to get the correct package name of libogg.so from File1 or File2:
packagingOptions {
pickFirst 'com/library/name/lib/x86_64/libogg.so'
...
}
UPDATE:
There is a conflicted dependencies:
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'
compile 'com.ibm.watson.developer_cloud:java-sdk:3.9.1'
From the Watson Developer Cloud Java SDK documentation you can find the following:
The Android SDK utilizes the Java SDK while making some
Android-specific additions. This repository can be found here. It
depends on OkHttp and gson.
which is pointing to the first library. So, you should only use:
compile 'com.ibm.watson.developer_cloud:android-sdk:0.4.2'
I'm using Android Studio, and for other projects, when I try to Generate a signed APK I get the app-release.apk file with any further trouble.
But in this particular project, I can only get an app-release-unaligned.apk file.
The main difference with my other projects is the use of the transloadit jar and org.apache.httpcomponents library for which I had to write down the packagingOptions field in my graddle file.
This is my build.grade file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.bambinotes.bambinotessnap"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENCE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile files('libs/transloadit-1.0.2.jar')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.anupcowkur:reservoir:2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.mcxiaoke.volley:library:1.0.16'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.android.support:support-v4:22.2.0'
}
** UPDATE**
I've just found out what was the error that I was having, Android Studio was opening the finder in another folder, the one that generates the app-debug and app-release-unaligned files (which we can consider as intermediate files), the app-release.apk file was two folders up in the directory structure.
Even though I feel embarrassed for knowing the reason of my trouble, I'll leave this question open to see if this happens to anyone else in the future.
The app-release.apk file is in the application folder.
Sometimes Android studio shows another directory where the unaligned file is, so you just have to look for the newly created file.
You need to add the signing configuration to your Gradle file, see this answer for more information How to create a release signed apk file using Gradle?
Hi I've currently updated my SDK tools as well as the other components of my SDK except for the M-preview and the sample files which is currently I won't be using. Now problem is after updating the libraries and syncing the gradle it gives me this error:
error: Attribute "track" has already been defined
error: Attribute "thumbTextPadding" has already been defined
error: Attribute "switchMinWidth" has already been defined
error: Attribute "switchPadding" has already been defined
and now my app won't build or run due to this values error on which I'm not sure of why it happens. Here's my current gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
lintOptions{
checkReleaseBuilds false
abortOnError true
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 17
versionName "1.1.0"
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile 'com.android.support:design:22.2.0'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'in.srain.cube:grid-view-with-header-footer:1.0.9'
compile 'com.felipecsl.quickreturn:library:1.5.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'it.sephiroth.android.library.imagezoom:imagezoom:+'
compile 'com.makeramen:roundedimageview:1.5.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:facebook')
}
Can someone point out to me on why does this happen? TIA.
By the look of it the attributes you are using ie
error: Attribute "track" has already been defined
error: Attribute "thumbTextPadding" has already been defined
error: Attribute "switchMinWidth" has already been defined
error: Attribute "switchPadding" has already been defined
might being used by the M-Preview SDK.Just change your attributes of the Switch you are using in the attrs.xml file and you are good to go!
I have added this line to my build.gradle
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
and I want to use MultipartEntityBuilder in my code. However Android studio doesn't add the library to my code.
Can anyone help me with this?
If you are using target SDK as 23 add the below code in your build.gradle
android{
useLibrary 'org.apache.http.legacy'
}
Additional note here: don't try using the gradle versions of those files. They are broken (28.08.15). I tried over 5 hours to get it to work. It just doesn't.
not working:
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
Another thing don't use:
'org.apache.httpcomponents:httpclient-android:4.3.5.1'
It's referring to 21 API level.
The accepted answer does not seem quite right to me. There is no point dragging a different version of HttpMime when one can depend on the same version of it.
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
compile (group: 'org.apache.httpcomponents' , name: 'httpmime' , version: '4.3.5') {
exclude module: 'org.apache.httpcomponents:httpclient'
}
Try adding this to your dependencies:
compile 'org.apache.httpcomponents:httpclient:4.4-alpha1'
And generally if you want to use a library and you are searching for the Gradle dependency line you can use Gradle Please
EDIT: Check this one too.
None of the others worked for me. I had to add the following dependency, as explained here
compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
because I was targeting API 23.
I resolved problem by adding following to my build.gradle file
android {
useLibrary 'org.apache.http.legacy'}
However this only works if you are using gradle 1.3.0-beta2 or greater, so you will have to add this to buildscript dependencies if you are on a lower version:
classpath 'com.android.tools.build:gradle:1.3.0-beta2'
I searched over and over this solution works like a charm ::
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.anzma.memories"
useLibrary 'org.apache.http.legacy'
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
I don't know why but (for now) httpclient can be compiled only as a jar into the libs directory in your project.
HttpCore works fine when it is included from mvn like that:
dependencies {
compile 'org.apache.httpcomponents:httpcore:4.4.3'
}
Working gradle dependency
Try this:
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'