Encountering two errors when building unity for android, firebase SDK - android

I'm receiving both errors:
Could not create task ':processDebugGoogleServices'.
Cannot create a proxy class for abstract class 'GoogleServicesTask'.
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.3.4'
**BUILD_SCRIPT_DEPS**}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
// Android Resolver Repos Start
([rootProject] + (rootProject.subprojects as List)).each {
ext {
it.setProperty("android.useAndroidX", true)
it.setProperty("android.enableJetifier", true)
}
}
([rootProject] + (rootProject.subprojects as List)).each { project ->
project.repositories {
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
maven {
url "https://maven.google.com"
}
maven {
url "https://deltadna.bintray.com/android" // Assets/DeltaDNA/Editor/Android/Dependencies.xml:8
}
maven {
url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22
}
mavenLocal()
jcenter()
mavenCentral()
}
}
// Android Resolver Repos End
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.deltadna.android:deltadna-sdk-notifications:4.10.0' // Assets/DeltaDNA/Editor/Android/Dependencies.xml:8
implementation ('com.facebook.android:facebook-applinks:[5,6)') {
exclude group: 'com.google.zxing'
}// Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:6
implementation ('com.facebook.android:facebook-core:[5,6)') {
exclude group: 'com.google.zxing'
}// Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:5
implementation ('com.facebook.android:facebook-login:[5,6)') {
exclude group: 'com.google.zxing'
} // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:7
implementation ('com.facebook.android:facebook-share:[5,6)') {
exclude group: 'com.google.zxing'
} // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:8
implementation 'com.google.android.gms:play-services-base:17.4.0' // Assets/Firebase/Editor/AppDependencies.xml:17
implementation 'com.google.firebase:firebase-analytics:17.6.0' // Assets/Firebase/Editor/AppDependencies.xml:15
implementation 'com.google.firebase:firebase-analytics-unity:6.16.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
implementation 'com.google.firebase:firebase-app-unity:6.16.0' // Assets/Firebase/Editor/AppDependencies.xml:22
implementation 'com.google.firebase:firebase-common:19.3.1' // Assets/Firebase/Editor/AppDependencies.xml:13
implementation 'com.parse.bolts:bolts-android:1.4.0' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:4
// Android Resolver Dependencies End
// ** revenuecat **
implementation ('com.revenuecat.purchases:purchases-hybrid-common:1.2.0') {
exclude group: 'com.android.billingclient', module: 'billing'
}
implementation 'com.android.support:multidex:1.0.3'
**DEPS**}
// Android Resolver Exclusions Start
android {
packagingOptions {
exclude ('/lib/armeabi/*' + '*')
exclude ('/lib/mips/*' + '*')
exclude ('/lib/mips64/*' + '*')
exclude ('/lib/x86/*' + '*')
exclude ('/lib/x86_64/*' + '*')
}
}
// Android Resolver Exclusions End
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
multiDexEnabled true
applicationId '**APPLICATIONID**'
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**SIGN**
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
useProguard **PROGUARD_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
useProguard **PROGUARD_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
}
}**PACKAGING_OPTIONS****SPLITS**
**BUILT_APK_LOCATION**
**EXTERNAL_SOURCES**
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
}
}**SPLITS_VERSION_CODE****REPOSITORIES****SOURCE_BUILD_SETUP**
I saw several threads that said i should remove apply plugin: 'com.google.gms.google-services'
or to update classpath 'com.android.tools.build:gradle:3.4.0' to classpath 'com.android.tools.build:gradle:4.0.0' but that didn't do it for me and only caused more problems.
Also running ./gradlew :dependencies didn't show anything.

It's difficult to exactly say what's happening, but I have a few suggestions that should work.
First, get rid of classpath 'com.google.gms:google-services:4.3.4' under dependencies and apply plugin: 'com.google.gms.google-services'. The reason is that the purpose of this is to read a google-services.json file in your project directory and generate a res/values/google-services.xml file (more information here). The Firebase SDK for Unity will do this automatically placing this file under Assets/Plugins/FirebaseApp.androidlib/res/values/google-services.xml. Anything in a Plugins/*.androidlib file is now automatically pulled into the Android project, rendering this step redundant (and often causing errors both on the Unity and Android side).
Since you've used Unity to generate a mainTemplate.gradle file and you're using a newer version of Unity (2019.3 and above), you'll also need to generate a gradleTemplate.properties file. This way we can enable AndroidX (the replacement for the Android Support libraries now used by Firebase) and enable Jetifier (which will upgrade Google Support dependencies that it looks like Facebook is pulling in).
From here, since you mentioned disabling the External Dependency Manager for Unity (EDM4U), you will want to force resolve your Android dependencies.
You will want to have "Patch mainTemplate.gradle", "Use Jetifier.", and "Patch gradleTemplate.properties" all checked in your Android Resolver Settings for this to work:
If you're running into issues or you don't want to run EDM4U, I'm trying to do is add android.useAndroidX=true and android.enableJetifier=true to gradleTemplate.properties. For my own game, this file now looks like:
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
**ADDITIONAL_PROPERTIES**
android.useAndroidX=true
android.enableJetifier=true
To recap, at this point you should have removed the play services plugin and enabled AndroidX and Jetifier support. You should be able to either build from Unity or export a gradle project and build from the command line (this latter is always a challenge in Unity since they opt to not use gradlew, so you may run into incompatibility with your system gradle).
If this doesn't help, I'd like to see a more complete error log to try to suss out the actual cause.

In your root-level (project-level) Gradle file (build.gradle), add rules to include the Google Services Gradle plugin. Check that you have Google's Maven repository, as well.
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.android.tools.build:gradle:3.3.1'
}
And then:
In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin:
apply plugin: 'com.google.gms.google-services'

I had issue with combo Firebase+Unity+gradle. Solved by downgrading gradle.
Unity -> Edit -> Preference -> Gradle to version 6.7.1
It seems that Firebase could not work with newer gradle versions.
Download: Gradle

Related

Gradle Project Sync Failing

My Project Sync is failing with the below errors -
Unable to resolve dependency for ':app#debug/compileClasspath': Could not download exoplayer-core.aar (com.google.android.exoplayer:exoplayer-core:r2.4.2)
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not download exoplayer-core.aar (com.google.android.exoplayer:exoplayer-core:r2.4.2)
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not download exoplayer-core.aar (com.google.android.exoplayer:exoplayer-core:r2.4.2)
Unable to resolve dependency for ':app#release/compileClasspath': Could not download exoplayer-core.aar (com.google.android.exoplayer:exoplayer-core:r2.4.2)
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not download exoplayer-core.aar (com.google.android.exoplayer:exoplayer-core:r2.4.2)
My Project build.grade looks like this -
// 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.2.1'
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 {
jcenter()
google()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And my App gradle file looks like -
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.android.application"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
implementation 'com.google.android.gms:play-services-analytics:16.0.6'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.facebook.android:audience-network-sdk:5.1.0'
}
Any help in this regard would be appreciated!!!
How do I resolve this??
I have tried Invalidate Caches/Restart option and also tried to rebuild the project but it didn't help..
It seems that Exoplayer-core and Exoplayer-dash are broken since today
https://github.com/google/ExoPlayer/issues/5225
By this Gradle configuration it works fine :
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 27
defaultConfig {
...
targetSdkVersion 27
...
}
}
ext {
exoplayer_version = '2.9+'
}
dependencies {
...
//exoplayer
implementation ('com.google.android.exoplayer:exoplayer-core:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer-dash:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer-hls:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer-smoothstreaming:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer-ui:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer:' + exoplayer_version)
So for sure if you didn't include exoplayer library in your
build.gradle, your project won't synch.
UPDATE:
Okay, sorry, now I got the problem you all using com.facebook.android:audience-network-sdk have experienced these days, and why in your build.gradle file there is not exoplayer dependency set.
Using com.facebook.android:audience-network-sdk that depends on exoplayer, if you didn't explicitly specify exoplayer-core and exoplayer-dash, gradle try to download the necessary dependency as for docs.
So, as #laylakn pointed out (upvoted for that) there where an issue between repository mirroring between bintray and jcenter.
So, specifically to your problem, since you have told me that you have tried adding the libraries and synch without success, that's because the version of exoplayer you are looking for (r2.4.2) is in the spring plugin repository.
So you should add it as your maven repo (because of the mirroring error of repositories stated before):
maven {
url "https://repo.spring.io/plugins-release/"
}
Or as explain on main GitHub repo, just pointing directly to bintray.
maven {
url 'https://google.bintray.com/exoplayer/'
}
and you should synch your project adding this two libraries:
implementation 'com.google.android.exoplayer:exoplayer:r2.4.2'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.4'
So now I'm glad to here from you that the mirroring problem has been resolved and are you able to sync right now, without doing any changes to your build.gradle files.
I've left and updated my answer to better explain this situation.
Also some other famous repo take precautions: [-:

Android Studio 3 gradle sync issue

i'm working on a project with Android Studio but i have no idea about the Android Studio..
can't solve the gradle sync error for hours. my build.gradle is like this: (not the wrong one, it's the app build.gradle)
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId 'com.kofax.sdk.samples.easysnap'
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
buildTypes {
release
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
def sdkRef
project.getRootProject().allprojects.each { proj ->
if (proj.name.toLowerCase().equals('sdk')) {
sdkRef = proj;
return true;
}
}
if (sdkRef) {
println "SDK present in project; using project reference as dependency"
compile sdkRef
} else {
println "SDK is not present in project; dependency reference"
repositories {
flatDir { dirs 'libs' }
}
compile (name: 'sdk-release', ext: 'aar')
}
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
}
i tried to clean project it's not about it, is it about the plugins or the missing filesor libs?
i've keep getting this error:
Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
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.
Please help...
If you work on Android Studio 3.0. Change "2.0.0" to "3.0.0" in your project gradle :
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
In your gradle-wrapper.properties :
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
In your app gradle : "compile" become "implementation" :
dependencies {
implementation 'com.android.support:appcompat-v7:27.0.0'
}
You should read that :
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
Android plugin 3.0.0 requires Gradle version 4.1 or higher. If you're opening an existing project using Android Studio 3.0 or later, follow the prompts to automatically update an existing project to the compatible version of Gradle.
To update Gradle manually, edit the URL in gradle-wrapper.properties to the following: distributionUrl=\https\://services.gradle.org/distributions/gradle-4.1-all.zip
And include the maven repo and change the plugin version in your project-level build.gradle file as follows:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}

How I can separate version of libraries in "build.gradle" app

I'm trying to separate versions of the libraries to have all of them in one location in order to save time and complexity.
I saw a guy in some comment in some blog that sais the way he use to do this. He posted the next screens.
I can't use this way to construct the gradle, but I think that is a good way.
My Project build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Definition of versions of libraries
ext {
toolVersions = [
android :[
versionCode : 1,
versionName : "0.0.1",
minSdk : 16,
targetSdk : 26,
compileSdk : 26,
buildTools : "26.0.2",
support : "26.1.0"
],
espressoCore : "2.2.2",
junit : "4.12"
]
libVersions = [
glide : "4.2.0",
flubber : "1.0.1"
]
}
My app build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion toolVersions.android.compileSdk
buildToolsVersion toolVersions.android.buildTools
defaultConfig {
applicationId "com.maol.brastlewark"
minSdkVersion toolVersions.android.minSdk
targetSdkVersion toolVersions.android.targetSdk
versionCode toolVersions.android.versionCode
versionName toolVersions.android.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:' + toolVersion.espressoCore, {
exclude group: 'com.android.support', module: 'support-annotations'
})
// SUPPORT LIBRARIES
compile 'com.android.support:appcompat-v7:' toolVersion.support
compile "com.android.support:support-core-utils:$rootProject.toolVersion.support"
testCompile "junit:junit:$rootProject.toolVersion.junit"
// IMAGE LOADER LIBRARY
compile "com.github.bumptech.glide:glide:$rootProject.libVersions.glide"
annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.libVersions.glide"
// VIEW ANIMATIONS
compile "com.appolica:flubber:$rootProject.libVersions.flubber"
}
I don't know how to used this in the build.gradle (app). Anyone in the room can advised me something?
Thank you
You can create a file (for example gradleScript/dependencies.gradle):
ext {
//Version
supportLibrary = '26.1.0'
//Support Libraries dependencies
supportDependencies = [
design : "com.android.support:design:${supportLibrary}",
recyclerView : "com.android.support:recyclerview-v7:${supportLibrary}",
cardView : "com.android.support:cardview-v7:${supportLibrary}",
appCompat : "com.android.support:appcompat-v7:${supportLibrary}",
supportAnnotation: "com.android.support:support-annotations:${supportLibrary}",
]
}
In the top level file build.gradle add:
// Load dependencies
apply from: 'gradleScript/dependencies.gradle'
In the module1/build.gradle:
// Module build file
dependencies {
//......
compile supportDependencies.appCompat
compile supportDependencies.design
}
Solution that preserves lint update checks
You can use the same construct as in your question. To preserve the lint update checks you'd only include the version number (rather than the entire dependency name).
Create an ext block in your project level build.gradle file
Each item in the ext block acts like a map so we can organize dependency versions in an array.
ext {
playServicesVersions = [
base : '17.6.0',
location: '18.0.0',
maps : '17.0.0'
]
supportVersions = [
nameHere: '3.0.0'
]
}
Access dependency versions
Note that curly braces are used here because more than one variable is accessed.
dependencies {
implementation "com.google.android.gms:play-services-base:${playServicesVersions.base}"
implementation "com.google.android.gms:play-services-location:${playServicesVersions.location}"
implementation "com.google.android.gms:play-services-maps:${playServicesVersions.maps}"
}
Lint checks still active
To make that possible you can declare ext{} block in your build.gradle file.
ext {
def AAVersion = '4.0-SNAPSHOT' // change this to your desired version
}
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
If you want to work with arrays:
ext {
supportDependencies = [
design : "com.android.support:design:${supportLibrary}",
// whatever lib...
]
}
then when you want to call it:
dependencies {
compile supportDependencies.design
}
You can declare the dependencies in your settings.gradle:
dependencyResolutionManagement {
versionCatalogs {
libs {
alias('protobuf').to('com.google.protobuf:protobuf-java:3.15.8')
alias('snappy').to('org.xerial.snappy:snappy-java:1.1.8.4')
alias('junit').to('junit:junit:4.13.2')
}
}
}
And then use them in build.gradle:
dependencies {
api libs.protobuf
api libs.snappy
testImplementation libs.junit
}
It works for multi-project builds as well.
Please refer to official docs for details.

'dependencies' cannot be applied to '(groovy.lang.Closure)'

I am unable to fix this error:
dependencies cannot be applied to '(groovy.lang.Closure)
This is my gradle file:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':FRNDzTER_core')
compile project(':cropper')
compile project(':stickyListHeaders')
compile "com.nostra13.universalimageloader:universal-image-loader:${rootProject.universalImageLoaderVersion}"
compile "com.google.android.gms:play- services:${rootProject.googlePlayServicesVersion}"
compile "de.keyboardsurfer.android.widget:crouton:${rootProject.croutonVersion}"
compile "com.nineoldandroids:library:${rootProject.nineoldandroidsVersion}"
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.crashlytics.android:crashlytics:1.+'
}
android{
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {
debuggable rootProject.prodDebug
proguardFile 'proguard.cfg'
}
}
dependencies {
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
}
You can go to Preferences and select "use default gradle wrapper" then rebuild the project. It worked well for me:
Go to
Windows
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
Mac
Preference -> Build, Execution, Deployment -> Build Tools -> Gradle
and select Use default gradle wrapper
Based on what Android Studio generates, you need to have a top-level project file build.gradle, and another for your app build.gradle.
Top-level:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
}
Application level:
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
android{
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {
debuggable rootProject.prodDebug
proguardFile 'proguard.cfg'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
} `
dependencies {
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':FRNDzTER_core')
compile project(':cropper')
compile project(':stickyListHeaders')
compile "com.nostra13.universalimageloader:universal-image- l loader:${rootProject.universalImageLoaderVersion}"
compile "com.google.android.gms:play- services:${rootProject.googlePlayServicesVersion}"
compile " "de.keyboardsurfer.android.widget:crouton:${rootProject.croutonVersion}"
compile "com.nineoldandroids:library:${rootProject.nineoldandroidsVersion}"
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.crashlytics.android:crashlytics:1.+'
}
But even without all that, your problem is that you have a dependencies within your android plugin config.
android {
dependencies {
}
}
remove that empty dependencies block.
EDIT: I also started getting this error with the latest Android Studio, all I had to do was add a newer version of the Gradle plugin, and compileSdkVersion 22.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
If you already are using the "default gradle wrapper" and it doesn't help:
In Menu click: File -> Invalidate Caches / Restart...
If it also doesn't help try in 2 steps:
1) Delete ".gradle" folder (and "build" folder if you have it already)
2) In Menu click: File -> Invalidate Caches / Restart...
After restarting the warning should disappear.
(For me it worked and for Android Studio and for IntelliJ Idea)
My problem is that the whole build.setting file were occupied with cannot be applied to '(groovy.lang.Closure)' warning messages instead of happening on any particular variable.
I have tried all solutions provided by others but none of them works for me.
I ended out doing these steps then it works like a charm. If you are encountering the same issue then give it a try.
Open and edit file: yourproject/gradle/wrapper/gradle-wrapper.properties. Edit content to update the gradle distribution version as shown in the image below then save.
Delete this folder: yourproject/.gradle.
Click Sync project with gradle files, then you are good to go.
I went into the preferences to try one of the other answers when I noticed a warning that my gradle home directory was wrong. So I opened up the file browser and chose the newer gradle version, and all the errors went away. Image shown below.
I bet you the problem is totally unrelated to the piece of code that is giving you warnings, most likely it's your proguard file. I had the following in my code and got the same warning:
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
By commenting out runProguard false, all of my problems go away, go figure :)
I have same problem in android studio 2.2,it work for me:
original:
android {
...
}
dependencies {
...
}
move dependencies in android:
android {
...
dependencies {
...
}
}
I solved the problem in Android Studio by Invalidating the cache and restart.
File-> Invalidate Caches / Restart..
I ran into a similar problem to this in IntelliJ for a Kotlin project. It looks like the issue was that in my project, even though it was set to use JDK 8, the language and API versions somehow got set to 1.3. See Project Preferences > Facets. In my case, I ticked "use project settings," but manually setting them per facet may work as well.
Close the project (File / Close project),
Select “Open an existing Android Studio project” on the start menu and select the folder that contains your Android project.
This work for me.
Gradle files can be made explicit in several places to avoid such errors. E.g. Change
configurations {
to
project.configurations {
or
task {
description 'foo'
to
task {
setDescription 'foo'
To fix the issue simply close the project, then select “Open an existing Android Studio project” on the start menu and select the folder that contains your Android project. Beware, select the folder, not the .iml project file.
Cut and then paste the "buildTypes" at the same place in "android" section and Re-Sync (refresh) Project
For people with M1 Intellij IDEA just add in build.gradle(:app)
//noinspection GroovyAssignabilityCheck
buildFeatures {
viewBinding
}
I fixed this issue with gradle 2.10.
Download it here : http://gradle.org/gradle-download/
And set your local gradle distribution like this :

configuration issue. "Configuration with name 'default' not found"

I am relatively new to Android development and VERY new to Android Studio (much more experienced with Eclipse + android plugin). I am trying to edit a github project, but I can't seem to get it to even compile! I have been reading up, and my error seems to have to do with the build.gradle/locations of libraries themselves.
My error is:
Error:Configuration with name 'default' not found.
It also says "Gradle project sync failed, but I think its related to the above error…whatever that means.
My outer build.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:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
And my inner build.gradle file is:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
defaultConfig {
applicationId "com.wisely.loyalty"
minSdkVersion 14
targetSdkVersion 18
versionCode 17
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':facebook')
compile project(':cwac')
// 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.
// 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.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
compile('org.apache.httpcomponents:httpmime:4.3.5') {
exclude module: "httpclient"
}
compile 'com.android.support:support-v13:20.0.0'
compile 'com.google.android.gms:play-services:5.0.+'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'com.makeramen:roundedimageview:1.3.0'
compile 'com.crashlytics.android:crashlytics:1.+'
}
EDIT:
General file hierarchy
root
.idea
app
libs
cwac
fb
utils
src
… all source files
gradle
build.gradle
settings.gradle
External Libraries
Android API 20 Platform
JDK
EDIT: Settings.gradle:
include ':app', ':facebook', ':cwac', ':utils'
project(':facebook').projectDir = new File('app/libs/facebook')
project(':cwac').projectDir = new File('app/libs/cwac')
project(':utils').projectDir = new File('app/libs/utils')
Progress Update:
I've tried moving the library files around in the directory to no avail. I also tried using my eclipse environment which just seemed to have even more issues. I really need to get this project configured properly!
UPDATE #2:
I have a strong feeling that this has to do with the gradle version since the file configuration seems fine, and its likely my computer that is lacking something. I am new to using gradle. Is there a way to update it? Or is it simply updated through the support libraries in the sdk manager?
Add your library folder in your root location of your project and copy all the library files there. For ex YourProject/library then sync it

Categories

Resources