Gradle Sync failed:Could not find method compile() for arguments - android

i am refering this https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started to integrate mopub in my app. I got an error "could not find method compile for arguments" while adding mopub-sdk dependency in my project's build.gradle file.Please help me out.
Build.gradle file:
buildscript {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}}
allprojects {
repositories {
jcenter()
}
dependencies {
compile('com.mopub:mopub-sdk:4.14.0#aar') {
transitive = true
}
// For banners
compile('com.mopub:mopub-sdk-banner:4.14.0#aar') {
transitive = true
}
// For interstitials
compile('com.mopub:mopub-sdk-interstitial:4.14.0#aar') {
transitive = true
}
// For rewarded videos. This will automatically also include
interstitials
compile('com.mopub:mopub-sdk-rewardedvideo:4.14.0#aar') {
transitive = true
}
// For native static (images).
compile('com.mopub:mopub-sdk-native-static:4.14.0#aar') {
transitive = true
}
// For native video. This will automatically also include native static
compile('com.mopub:mopub-sdk-native-video:4.14.0#aar')
{transitive = true}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Actual Error:-
Error:(31, 0) Could not find method compile() for arguments [com.mopub:mopub-sdk:4.14.0#aar, build_7edkg2m28hxg79jomt8w3j8ic$_run_closure1$_closure4$_closure5#1c36532] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

You need to put your dependencies in the other build.gradle. They belong to the individual module build.gradle files.
Also, you are importing com.mopub:mopub-sdk:4.14.0#aar, which contains all of the ad format dependencies you already have below in your Gradle file. You only need com.mopub:mopub-sdk:4.14.0#aar or the modularized artifacts.

Related

Dokka 1.4.20 "Nothing to document"

Dokka 1.4.20 does not generate any documentation and returns the following for all tasks
> Task :dokkaJavadoc
Dokka 1.4.* is an alpha project
Initializing plugins
Validity check
Creating documentation models
Exiting Generation: Nothing to document
build.gradle (Project)
buildscript {
// omitted a bunch of versions here
ext.version_dokka = '1.4.20'//0.9.17//1.4.20
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath("org.jetbrains.dokka:dokka-gradle-plugin:$version_dokka")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id("org.jetbrains.dokka") version "$version_dokka"
}
allprojects {
repositories {
google()
jcenter()
}
// used for testing 0.9.17
// dokka {
// outputFormat = 'html'
// outputDirectory = "$buildDir/documentation "
//
// }
}
task clean(type: Delete) {
delete rootProject.buildDir
}
It does generate the folders when using 1.4.20, but both command-line running as well as running the tasks in the Gradle panel do not work.
The documentation also specifies a bunch of things for configuration, but it is very unclear, and half of it gives me additional errors like setting the output directory.
I have tried version 0.9.17 as well, but with no success.
Seems like you're missing the following in your module level build.gradle (here for version 1.4.20)
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlinx-serialization'
id 'org.jetbrains.dokka'
}
dokkaHtml {
dokkaSourceSets {
named("main") {
includeNonPublic.set(false)
skipEmptyPackages.set(true)
skipDeprecated.set(true)
reportUndocumented.set(true)
jdkVersion.set(8)
}
}
}
android {
compileSdkVersion 30
Just add the dokkaHtml task.
Keep in mind syntax has significantly change since version 1.x. In version prior to 1.4x you will have to use the following syntax
dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/dokka/html"
configuration {
includeNonPublic = false
skipEmptyPackages = true
skipDeprecated = true
reportUndocumented = true
jdkVersion = 8
}
}

Could not find method kotlin() for arguments [gradle-plugin, 1.3.20]

I've copied exactly what the kotlin gradle docs say to implement kotlin gradle plugin, however it's returning the following error:
Could not find method kotlin() for arguments [gradle-plugin, 1.3.20] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
my gradle
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath(kotlin("gradle-plugin", version = "1.3.20"))
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
// ext {
// navigationVersion = '28.0.0'
// }
plugins {
kotlin("<...>")
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Any idea?
build.gradle can be written in Groovy or Kotlin. You're typing your build.gradle in Groovy (not Kotlin), but you have copied the Kotlin code. You should select the Groovy tab on the documentation:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.3.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"
}
}
Here: https://kotlinlang.org/docs/reference/using-gradle.html#targeting-android
You can also find a decent example by creating an empty Android and Kotlin project.

Integrating the Navmii SDK for android

I'm getting error while trying to Add the dependencies of the navmii sdk
I'm following the documentation to add the dependencies:
http://navmii.com/android-sdk-documentation/
In order to add the SDK library to your application insert the following code into your app’s build.gradle:
repositories {
maven {
url 'TODO'
}
}
dependencies {
compile ('com.navmii.android:navmiisdk:1.0.0.36167#aar') // TODO update the version
}
i got error massage says : Error:(18, 0) Could not find method compile() for arguments [com.navmii.android:navmiisdk:1.0.0.36167#aar] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File
My gradle.build file :
buildscript {
repositories {
google()
jcenter()
repositories {
maven {
url 'TODO'
}
}}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
compile ('com.navmii.android:navmiisdk:1.0.0.36167#aar')
// 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
}
What's the problem ?

i keep getting an error when i try to use google crashlytics

I am trying to use Crashlytics in my app but keep getting an error saying
Error:(30, 1) A problem occurred evaluating root project 'CodeX_TeaXt'.
Could not find method buildscripts() for arguments [build_dujqhmp6npuv4v2dkd04dm37r$_run_closure3#30d25365] on root project 'CodeX_TeaXt' of type org.gradle.api.Project.
And here's my code for the build.gradle file :
allprojects {
repositories {
google()
jcenter()}
}
task clean(type: Delete) {
delete rootProject.build``Dir}
buildscripts{
repositories {
// ...
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
// ...
classpath 'io.fabric.tools:gradle:1.24.4'
}
}
And:
allprojects {
// ...
repositories {
// ...
maven {
url 'https://maven.google.com/'
}
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
dependencies {
// ...
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
compile 'com.google.firebase:firebase-core:11.6.2'
}
I am also having a problem using performance, test lab, so help
You should move:
maven {
url 'https://maven.google.com/'
}
from you app-level build.gradle to you project-level build.gradle based on the instructions in: https://firebase.google.com/docs/crashlytics/get-started

Cannot add Tweet Composer dependency

I'm trying to add new TweetComposer to my project at module "app":
dependencies {
compile('com.twitter.sdk.android:tweet-composer:1.0.5#aar') {
transitive = true;
}
}
And I always got error like this:
Error:Could not find com.twitter.sdk.android:tweet-composer:1.0.5.
Required by:
reader-android:app:unspecified
Search in build.gradle files
I found the issue:
add at project level the following code
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
And at application level
dependencies {
compile('com.twitter.sdk.android:tweet-composer:1.0.5#aar') {
transitive = true;
}
}
You should then be able to sync Gradle correctly, let me know if that works for you!
Reference here

Categories

Resources