Fabric / Crashlytics : gradle needs to run twice - android-gradle-plugin

I am working on an app, and when building it using gradle in command line ("clean build" or even "clean installRelease"), I am facing the issue where Crashlytics fails to start :
java.lang.RuntimeException: Unable to create application XXXXXXXX: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: com.crashlytics.android.core.CrashlyticsMissingDependencyException:
This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
install an Android build tool and ask a team member to invite you to this app's organization.
After trying many things presented on SO, I found out that if I ran :
./gradlew clean installRelease
./gradlew installRelease
my application starts without any issue.
It's a bit of a pain, as I have to build the app twice before publishing it (and if I ever forget to do it, I am publishing an unusable app :/
My gradle file is set up correctly (at least, the plugin does not complain about it), and gradle is up to date (gradle 2.9, android plugin 1.5.0, crashlytics 2.5.4, ...)
Here are a few lines from my build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.20.1'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'io.fabric'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
std {
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "XXXXXXXXXXX"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.std
}
debug {
signingConfig signingConfigs.std
}
}
productFlavors {
stubbed {
buildConfigField "boolean", "STUBBED", "true"
}
real {
buildConfigField "boolean", "STUBBED", "false"
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
dataBinding {
enabled = true
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.4#aar') {
transitive = true;
}
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.jakewharton:butterknife:7.0.1'
}
If anyone has ever faced and fixed this kind of problem, I'd love to hear about it :)
Thanks !

Related

Could not find method dependenciesInfo() for arguments Android

App Build Android Studio Error
Could not find method dependenciesInfo() for arguments
[build_7pycm2rxdjt52mhv3k1evqwie$_run_closure1$_closure9#1e56c29c] on
object of type
com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
Open File
Bulid failed
this is my build.gradle (App level)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.xxx.xxx.xxx"
minSdkVersion 17
targetSdkVersion 29
versionCode 3011
versionName "1.2.02"
vectorDrawables.useSupportLibrary = true
resConfigs "en"
multiDexEnabled true
}
aaptOptions {
cruncherEnabled false
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
debuggable false
jniDebuggable false
renderscriptDebuggable false
pseudoLocalesEnabled false
zipAlignEnabled true
}
debug {
debuggable true
jniDebuggable true
renderscriptDebuggable true
minifyEnabled false
zipAlignEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependenciesInfo {
// Disables dependency metadata when building APKs.
includeInApk = false
// Disables dependency metadata when building Android App Bundles.
includeInBundle = false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Android X dependencies
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
implementation 'androidx.browser:browser:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
//Android Architecture Components
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
//Firebase dependencies
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.3'
//com.google dependencies
implementation 'com.google.android.gms:play-services-ads-lite:16.0.0'
implementation "com.google.android.material:material:1.1.0"
//other library gradle
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation 'com.android.volley:volley:1.1.1'
kapt 'androidx.room:room-compiler:2.2.5'
implementation 'androidx.room:room-runtime:2.2.5'
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'
}
apply plugin: 'com.google.gms.google-services'
My build.gradle (Project level) is as below:
buildscript {
ext.kotlin_version = '1.3.40'
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Please suggest how to solve this issue.
I am using Android Studio 4.0.
I have tried restarting the Android Studio with "Invalidate cache" option but did not help.
dependenciesInfo DSL block appears only in 4.0 Gradle plugin version. You use 3.5.2
classpath 'com.android.tools.build:gradle:3.5.2'
Update it to 4.0

transformClassesWithJarMergingForDebug TransformException

After updating to android studio 2.1 and while i tried to use new gradle my project started crashing with kinda that:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException: java.util.zip.ZipException: >duplicate entry: org/objectweb/asm/tree/AbstractInsnNode.class
Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "application.id.is.here"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding
{
enabled = true
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = true
}
}
repositories {
mavenCentral()
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.mikepenz:materialdrawer:4.6.4#aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1+'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:design:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.vk:androidsdk:+'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.tools.build:gradle:2.1.0+'
compile ('com.google.android.gms:play-services-maps:8.3.0'){
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.7.2+'
}
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
}
and Top-level build:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha1'
}
}
allprojects {
repositories {
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If you have any ideas - please help. None of solvations i found for this problem worked out for me.
Igor's answer worked for me. I had the exact same issue (after getting all those exclusions in there). Kind of a pain getting Android Studio 2.1 running.
Quit Android Studio then clear caches:
cd ~/.gradle/caches
rm -r *
Restart Android Studio and now it should work.

Gradle Failed to resolve: commons-io:commons-io:+

When syncing Android project with gradle in android studio , it fails resolving
the packages shown in the screeshot below .
here's my build.gradle :
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' }
}
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.dmbteam.cityguide"
minSdkVersion 10
targetSdkVersion 22
versionCode 4
versionName '4.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'commons-io:commons-io:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile('org.simpleframework:simple-xml:2.7.+') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile project(':pinterest_lib')
compile('com.crashlytics.sdk.android:crashlytics:2.4.0#aar') {
transitive = true;
}
compile 'com.google.android.gms:play-services-maps:7+'
compile 'com.google.android.gms:play-services-location:7+'
compile 'com.google.android.gms:play-services:7+'
}
under repositories, I usually find that I end up having to have a chain something like this:
repositories {
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
In other words, it 1st tries to use your local maven repo, then the specific maven repo/mirror, and then falls back to jcenter as a last resort.

Error in Android Studio Build (version 1.2.1.1) and Gradle (version 1.2.3)

Since upgrading to AS 1.2.x I cannot build my project.
Every time I build (or clean or Invalidate Caches/Restart) I get the following error message:
My gradle build files are as follows:
// 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:1.2.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android
{
signingConfigs {
config { keyAlias 'ScoularAndroidKey'
keyPassword 'password'
storeFile file('C:/Users/bschmiedeler/.AndroidStudio/scoularkeystore.jks')
storePassword 'password'
}
}
name="Scoular"
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.scoular.scoular"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug{
debuggable true
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/commons-lang-2.3.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile files('src/main/assets/library-1.0.10.jar')
}
Any help would be greatly greatly appreciated.

Crashlytics Error:(11, 0) Plugin with id 'io.fabric' not found compile lib

I am getting the error,
Error:(11, 0) Plugin with id 'io.fabric' not found
when trying to run crashlytics on my project.
I faced the same issue, when tried to use Fabric plugin for android studio(automated code generation by plugin).I followed this documentation also.
And finally, I could see there were some missed lines in build.gradle.
So this is the top level project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'java'
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
and this is the build.gradle for app module
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "your application package name"
minSdkVersion 10
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:support-v4:22.0.0'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
}
and at last "clean build" and all was set for me.
I ended up creating an empty project and using the plugin on it and then I compared the gradle file and realized that this was not being added
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
in your project gradle file:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'java'
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
in your app gradle file:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "your application package name"
minSdkVersion 10
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:support-v4:22.0.0'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
}
You just forget to add below mentioned line in Project level gradle file.
maven { url 'https://maven.fabric.io/public' }
Also please add below mentioned line in dependencies (in project level gradle file)
classpath 'io.fabric.tools:gradle:1.26.1'
I think you lost "google()" in repositories of buildscript.
buildscript {
repositories {
jcenter()
google()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
repositories {
jcenter()
}
}
I have faced this issue while working with Android + Cordova + Angularjs Hybrid project.
apply plugin: 'io.fabric'
By commenting this line at the path /app/build.gradle solved the issue.
Hope it helps someone!!