This question already has answers here:
Gradle build tool cannot find play-services-tasks.aar? Why?
(8 answers)
Closed 4 years ago.
Help me to solve those errors in my gradle.
Errors:
Warning:Configuration 'androidTestCompile' is obsolete and has
been replaced with 'androidTestImplementation' and 'androidTestApi'.
It will be removed at the end of 2018. For more information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Warning:Configuration 'compile' is obsolete and has been replaced with
'implementation' and 'api'. It will be removed at the end of 2018. For
more information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Warning:Configuration 'androidTestApi' is obsolete and has been
replaced with 'androidTestImplementation'. It will be removed at the
end of 2018. For more information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Warning:Configuration 'testCompile' is obsolete and has been replaced
with 'testImplementation' and 'testApi'. It will be removed at the end
of 2018. For more information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Warning:Configuration 'testApi' is obsolete and has been replaced with
'testImplementation'. It will be removed at the end of 2018. For more
information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Error:Failed to resolve: firebase-analytics Open
File
Error:Failed to resolve: play-services-base Open
File
Those error and warning found in my gradle.
These error appeared recently, Previous there was no problem.
This is my app gradle:-
'apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.alagappan.vivo"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
}
dependencies {
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:27.1.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support.constraint:constraint-layout:1.1.0'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.google.firebase:firebase-core:15.0.0'
compile 'com.google.firebase:firebase-database:16.0.1'
compile 'com.google.firebase:firebase-auth:16.0.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-auth:15.0.1'
compile 'com.firebaseui:firebase-ui-database:3.2.2'
compile 'com.android.support:design:27.1.1'
compile 'com.firebase:firebase-client-android:2.5.0'
compile 'com.andkulikov:transitionseverywhere:1.7.9'
}'
apply plugin: 'com.google.gms.google-services'
this is application side gradle:-
'// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
buildscript {
dependencies {
classpath 'com.google.gms:google-services:3.2.0' // google-services plugin
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}'
Thanking You in advance friends
Remove:
compile 'com.firebase:firebase-client-android:2.5.0'
since it is deprecated.
https://www.firebase.com/docs/android/quickstart.html
Change the top level gradle file to this:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
https://developer.android.com/studio/releases/gradle-plugin
Change:
compile to implementation
androidTestCompile and androidTestApi to androidTestImplementation
testCompile and testApi to testImplementation
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration
Related
I tried to run my project for first time but I faced this error:
Failed to notify dependency resolution listener.
Problems reading data
from Binary store in
C:\Users\Ghaem\AppData\Local\Temp\gradle9202596089529693792.bin
(exist: true)
I've tried changing version of gradle to all available version with no luck.
My Project (root) build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
maven { url 'https://repo1.maven.org/maven2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My App build.gradle file:
buildscript {
repositories { maven { url 'https://plugins.gradle.org/m2/' } }
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.itechnotion.wpnews"
minSdkVersion 15
targetSdkVersion 26
versionCode 5
versionName "1.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [onesignal_app_id: "f893b120-b601-41e5-b0e3-715626efe0a3",
onesignal_google_project_number: "REMOTE"]
}
buildTypes {
release {
minifyEnabled false
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.facebook.stetho:stetho:1.1.1'
compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.firebase:firebase-core:16.0.0'
compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
compile 'org.jsoup:jsoup:1.10.1'
compile 'com.google.android.gms:play-services-ads:17.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
}
apply plugin: 'com.google.gms.google-services'
Error: Program type already present:
com.google.android.gms.internal.measurement.zzet
Update classpath
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.google.gms:google-services:4.3.2'
}
OneSignal-Gradle-Plugin
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
Use implementation instead of compile.
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
You are using very old versions. If you want to use latest then libraries will not work unless you make the following changes in your app:
Upgrade compileSdkVersion to 28 or later.
Update your app to use Jetpack (AndroidX).
AndroidX replaces the original support library APIs with packages in the androidx namespace. Read official guideline about AndroidX Overview.
compileSdkVersion 29
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
buildToolsVersion '29.0.2'
multiDexEnabled true
}
Your appcompat:appcompat & constraintlayout will
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
I have tried to use ibm tone analyzer api for my project, but if I include the dependency I get this error:
Duplicate class javax.annotation.CheckForNull found in modules
annotations-3.0.1.jar (com.google.code.findbugs:annotations:3.0.1) and
jsr305-3.0.2.jar (com.google.code.findbugs:jsr305:3.0.2) Duplicate
class javax.annotation.CheckForSigned found in modules
annotations-3.0.1.jar (com.google.code.findbugs:annotations:3.0.1) and
jsr305-3.0.2.jar (com.google.code.findbugs:jsr305:3.0.2)
I have tried to delete testing dependencies, but still won't work, please help
App File:
apply plugin: 'com.android.application'
android {
configurations.all{
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
compileSdkVersion 28
defaultConfig {
applicationId "com.example.loginapp"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
compile 'com.ibm.watson:tone-analyzer:7.0.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude module: 'jsr305:3.0.2'
})
implementation 'com.google.firebase:firebase-auth:16.2.1'
}
// Add the following line to the bottom of the file:
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
Gradle Build file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo"
}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
add applicationVariants.all to your gradle.build:
android {
applicationVariants.all { variant ->
variant.getRuntimeConfiguration().exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
}
Actually, it worked but I did not understand and I get an error. How can I fix it?
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example"
minSdkVersion 18
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.:conciseclock:0-SNAPSHOT'
testCompile 'junit:junit:4.12'
}
and
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
maven{ url 'https://dl.bintray.com/spark/maven' }
maven { url "https://jitpack.io" }
mavenCentral()
}
}
task customClean(type: Delete) {
delete rootProject.buildDir
}
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not find com.:conciseclock:0-SNAPSHOT.
Required by:
project :app
Error(37,13) Failed to resolve: com.:conciseclock:0-SNAPSHOT
Try with compile 'com.tomduan.conciseclock:library:0.2.2'
Anyway, where did you get this snapshot, because it looks like you are using custom repository manager, not official git.
easy there is no library on this dependences
com.github.zurnacibatuhan:conciseclock:0-SNAPSHOT
or i recommend to check library version so there is no number version as
0-SNAPSHOT
or replace with this line
compile 'com.tomduan.conciseclock:library:0.2.2'
you are using 25.3.1 version in your dependencies.it means you should first add this to your project gradle repositories like this
allprojects {
repositories {
jcenter()
maven{ url 'https://dl.bintray.com/spark/maven' }
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
}
add line
maven {url "https://maven.google.com"}
after that you should replace this line:
compile 'com.github.zurnacibatuhan:conciseclock:0-SNAPSHOT'
with this line:
compile 'com.tomduan.conciseclock:library:0.2.2'
I have updated Android Studio to 2.3 recently. When I try to open existing project which was running in AS 2.2 giving me below error in gradle:
Error:java.lang.NoClassDefFoundError: Could not initialize class
org.gradle.internal.resource.transport.http.AlwaysRedirectRedirectStrategy
When I restart AS it show's below error
Error:Unable to load class 'org.apache.commons.logging.LogFactory'.
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
My project gradle is :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
repositories {
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My Module level gradle is:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.6.6#aar') {
transitive = true;
}
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:leanback-v17:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId 'com.example.app'
minSdkVersion 15
targetSdkVersion 25
versionCode 3
versionName "1.0.2"
multiDexEnabled true
}
signingConfigs {
release {
keyAlias 'asda'
keyPassword 'asdas'
storeFile file('/home/.playstore/asda/asd.jks')
storePassword 'asda'
}
}
buildTypes {
release {
//shrinkResources true
//minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
useLibrary 'org.apache.http.legacy'
repositories {
mavenCentral()
maven { url "https://repo.commonsware.com.s3.amazonaws.com" }
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:multidex:1.0.1'
compile 'org.apache.commons:commons-io:1.3.2'
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: "httpclient"
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
//compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'joda-time:joda-time:2.9.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.github.Cutta:TagView:1.3'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
}
productFlavors {
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
apply plugin: 'com.google.gms.google-services'
So I'm getting this annoying message(full message at the bottom at the message),and I have no idea which libraries include those bouncycastle files (I didn't include them myself directly),I'm guessing that two of them include different versions of the same files? :P
How can I know which packages/libraries included those? How can I solve the issue?
Here are the build.grade files:
App level:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "dor.only.dorking.android.profilemanager"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
apply plugin: 'com.google.gms.google-services'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:design:23.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.api-client:google-api-client:1.19.1'
compile 'com.google.apis:google-api-services-plus:v1-rev375-1.21.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.gms:google-services:2.1.0-beta3'
}
Project level:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:2.1.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is the error message (Gradle's output, I am using Android Studio):
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/BCKEY.DSA
File1: C:\Program Files\Android\Android Studio\gradle\m2repository\org\bouncycastle\bcpkix-jdk15on\1.48\bcpkix-jdk15on-1.48.jar
File2: C:\Program Files\Android\Android Studio\gradle\m2repository\org\bouncycastle\bcprov-jdk15on\1.48\bcprov-jdk15on-1.48.jar