I have the following error :
org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method classpath() for arguments [com.github.dcendents:android-maven-gradle-plugin:1.4.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Here's my build.gradle (App)
apply plugin: 'com.android.application'
repositories {
google()
jcenter()
}
dependencies {
implementation 'com.google.firebase:firebase-appindexing:11.6.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.android.tools.build:gradle:4.1.0'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.xxx"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "0.01"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
And the build.gradle
// 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.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
allprojects {
repositories {
google()
jcenter()
}
}
}
what did I do wrong ?
Thank you for your help.
Related
I am trying to add exoplayer dependency version 2.12.2 and getting the below error
Failed to resolve: com.google.android.exoplayer:exoplayer:2.12.2
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
Gradle version 7.2
Top level build gradle
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level build gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.ext.line"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation "com.google.android.exoplayer:exoplayer:2.12.2"
}
And the settings gradle file
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "My Application"
include ':app'
Try adding maven {url 'https://jitpack.io'} in settings.gradle.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Solved by using jcenter()
Applicable to exoplayer versions below 2.13.3
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
}
}
I'm trying to add in-app billing as described here:
https://developer.android.com/google/play/billing/integrate
and think I have set up dependencies as instructed, but still, both the BillingClient and PurchasesUpdateListener classes as in the code example on the page are not available.
My project's build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.myproject"
minSdkVersion 17
targetSdkVersion 26
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:19.5.0'
implementation 'com.android.billingclient:billing:3.0.1'
}
My top-level build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
How to fix this?
Changing my global build.gradle as follows helped me to resolve the missing dependencies:
buildscript {
repositories {
jcenter()
google()
mavenLocal()
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://maven.springframework.org/release" }
maven { url "https://maven.restlet.com" }
maven { url "https://jcenter.bintray.com" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
Hopefully this helps someone.
Make sure the global build.gradle is using the latest versions.
Then resyncing will resolve all the issues.
I have an Android project with a main module plus multiple other sub-modules. I integrated Crashlytics in the project successfully, by updating the project-level build.gradle and the main module build.gradle:
Project-level gradle:
buildscript {
repositories {
jcenter()
maven {url 'https://maven.google.com'}
maven {url 'https://maven.fabric.io/public'}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
jcenter()
google()
maven {url 'https://maven.fabric.io/public'}
}
}
Main-module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
...
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
implementation project(':modules:sensordata:collection:ambient:module-wifinetwork')
...
}
repositories {
maven { url 'https://dl.bintray.com/rvalerio/maven' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
jcenter()
}
build.gradle for module module-wifinetwork (similar for every module):
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility = 1.8
sourceCompatibility = 1.8
}
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
}
My problem is that crash reports from the main-module are correctly sent to the firebase backend, while crash reports in other modules are not, even though they are correctly identified, because if I put this command in a class in the sub-module:
Crashlytics.getInstance().crash();
I receive the following:
2019-12-18 10:19:54.328 29944-30002/it.unitn.disi.witmee.sensorlog E/EventBus: Could not dispatch event: class it.unitn.disi.witmee.modules.core.systembus.model.BusObject to subscribing class class it.unitn.disi.witmee.modules.core.systembus.core.SensorlogMainBus
java.lang.ArrayIndexOutOfBoundsException: length=2; index=10
at com.crashlytics.android.core.CrashTest.indexOutOfBounds(CrashTest.java:30)
at com.crashlytics.android.core.CrashlyticsCore.crash(CrashlyticsCore.java:635)
at com.crashlytics.android.Crashlytics.crash(Crashlytics.java:340)
at it.unitn.disi.witmee.modules.sensordatacollection.ambient.wifinetwork.runnables.SensorRunnable.run(SensorRunnable.java:38)
at it.unitn.disi.witmee.modules.sensordatacollection.sensormodule.receivers.StartAllBroadcastReceiver.busEventCallback(StartAllBroadcastReceiver.java:23)
at it.unitn.disi.witmee.modules.core.systembus.core.SensorlogMainBus.onEvent(SensorlogMainBus.java:219)
at java.lang.reflect.Method.invoke(Native Method)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:507)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:501)
at org.greenrobot.eventbus.BackgroundPoster.run(BackgroundPoster.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Any clue why this is not working in the sub-module? Thank you
I found the issue, just had to rebuild the project. So the solution is to add the following elements to the project-level build.gradle and to the main-module build.gradle, nothing to be added to individual modules build.gradle. And then clean and rebuild your project.
Project-level build.gradle:
buildscript {
repositories {
...
maven {url 'https://maven.fabric.io/public'}
...
}
dependencies {
...
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
...
maven {url 'https://maven.fabric.io/public'}
}
}
Main-module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
...
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
repositories {
...
}
I use this following script under my current android project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
android {
compileSdkVersion 11
buildToolsVersion "11.0"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 11
targetSdkVersion 11
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
But then found this error message.
How to solve this ?
The android block should be within a module build.gradle that contains apply plugin: 'com.android.application', and not in the root build.gradle file.
Example:
root build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}
module build.gradle (could be within the app folder):
apply plugin: 'com.android.application'
android {
compileSdkVersion 11
buildToolsVersion "11.0"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 11
targetSdkVersion 11
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
i am using studio 2.0 every time in new project it shows error(26,17) failed to resolve junit:junit:4.12.
after reading on stackover flow i added repository in build.gradle
but it still not work for me.
here is code:
(project:myapplication)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
//jcenter{url 'http://jcenter.bintray.com/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
repositories{
maven{url 'http://repo1.maven.org/maven2'}
jcenter { url 'http://jcenter.bintray.com/' }}
allprojects {
repositories {
jcenter()
// jcenter{url 'http://jcenter.bintray.com/'}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
(module:app)
apply plugin: 'com.android.application'
repositories{
maven{url 'http://repo1.maven.org/maven2'}
jcenter { url 'http://jcenter.bintray.com/' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.akshay.myapplication"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.1.1'
}