I've add the SDK to the builder.gradle like this
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
compile 'com.kontaktio:sdk:3.0.2'
}
packagingOptions {
exclude 'main/AndroidManifest.xml'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
But it return an error
ERROR: Could not find method compile() for arguments [com.kontaktio:sdk:3.0.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please help me to fix it.
You need to move the following block from your project build.gradle:
dependencies {
compile 'com.kontaktio:sdk:3.0.2'
}
packagingOptions {
exclude 'main/AndroidManifest.xml'
}
to your module build.gradle (usually app module).
your project build.gradle dependencies block must use classpath instead of compile. Your project build.gradle should be something like this:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Please take a look Configure your build for more details.
They change the 'compile' into 'implementation' on latest gradle, so you need to change
dependencies {
compile 'com.kontaktio:sdk:3.0.2'
}
to
dependencies {
implementation 'com.kontaktio:sdk:3.0.2'
}
Related
So I am working on an old project in which I have the following code in the project build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android Studio is warning me to use mavenCentral() instead of jcenter() as jcenter is not being updated. So I have change it to the following code:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
So my question is, if now I am using mavenCentral() instead of jcenter(), do I have to use the " maven { url "https://jitpack.io" }" line of code or I should´t use it? I mean, the correct code
would be the following instead of the previous code? ->
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Or actually I should use the code line of maven jitpack (maven { url "https://jitpack.io" }") although now I am using mavenCentral() instead of jcenter()?
Or actually I should use the code line of maven jitpack (maven { url "https://jitpack.io" }") although now I am using mavenCentral() instead of jcenter()?
The choice of mavenCentral() versus jcenter() has nothing to do with jitpack.io and whether you should be using it as a repository.
You need a repository to obtain artifacts hosted by that repository. So, for example, you need the google() repository for most of Google's artifacts, such as the com.google.gms:google-services that you are using.
Whether you need jitpack.io will depend on whether you have any dependencies that come from that repository. We have no way of telling whether you do or you do not.
A comment on your question suggests removing it and seeing if your build breaks. That will not work immediately, as Gradle caches downloaded artifacts and usually works off of your cached copy. Your build would break in the future if you try updating the version of some dependency and none of the other repositories host that artifact (at least for that version).
The safest thing to do is to go through all your dependencies (everything listed in a dependencies closure in your project-level and module-level build.gradle files) and identify where they come from. Perhaps add comments to your Gradle files to help you keep track. If you find that none of your dependencies seem to come from jitpack.io, you can remove that repository.
I get an error saying "Failed to resolve: com.github.mancj:MaterialSearchBar:0.8.5"
any ideas on how to fix this?
my build gradle proj
buildscript {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath 'com.google.gms:google-services:4.3.10'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build gradle app:
dependencies {
.....
implementation 'com.github.mancj:MaterialSearchBar:0.8.5'
} ```
Try adding this to your project's build.gradle(the one you showed in the first):
allprojects { repositories { google() mavenCentral() jcenter() } }
Edit: Just checked the library you were asking about. It asks you to add that maven { url ....} in the repositories section of allprojects as well:
Try adding maven { url "https://jitpack.io" } in your settings.gradle file:
settings.gradle (Project Settings)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url "https://jitpack.io" } <-- here
}
}
rootProject.name = "StackOverflow"
include ':app'
I think this happens because Build is configured to prefer settings repositories over project repositories
I created a new project and getting following Gradle Sync error.
Gradle 'ProjectX' project refresh failed Error: Cannot find JAR 'kotlin-compiler-embeddable-1.1.3-2.jar' required by module 'gradle-kotlin-dsl' using classpath or distribution.
I am not using 'Kotlin' and using Android 4.0(IceCreamSandwich). Below is my build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.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
}
I have a project that I started in Java on Android Studio and I want to continue it in Kotlin. So I configured my project to integrating Kotlin by this way "Configure Kotlin in Project"
After that Android Studio changed my twice build.gradle files. But from that moment my sync started to fail.
there is my build.gradle file where the error occurs :
before :
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
after :
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
}
repositories {
mavenCentral()
}
allprojects {
repositories {
google()
jcenter()
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I get the following error :
Cannot add task 'clean' as a task with that name already exists.
When I remove the task clean I get the error :
1
After created a new Kotlin project and took a look about the build.gradle file
I adapted mine and it worked as well !
There is my current build.gradle file
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I was messing around with my build.gradle trying to add Google's library into my build.gradle for my project because a random error popped up saying i needed to update my com.google.android.gms to 10.2.0 which gave an error so I tried to input google's maven thing.. anyways here's the code with the error:
// 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.3'
classpath 'com.google.gms:google-services:3.1.2'
// 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
}
}
The error is "Could not find method clean() for arguments [{type=c;ass org.gradle.api.tasks.Delete}, build_djvq5gyz4y6fnevmcpa9beri7$_run_closure1$_closer5#cf00d12] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler." and it's for the task clean(type: Delete) { delete rootProject.buildDir } code.
Please help! I don't know what else to do at this point arg!
There are some errors in your script. Check the missing }
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.2'
}
} // <-- missing
And remove the last one after the clean task.
build.gradle with the clean() method
clean(type: Delete) {
delete rootProject.buildDir}
// delete it and again sync with gradle