Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crashlytics could not find the manifest when update build:gradle to 3.3.0

Tags:

android

gradle

I use fabric crashlytics in my application and it works fine when com.android.tools.build:gradle is 3.2.1, until I update it to 3.3.0.

Now I meet the 'Crashlytics could not find the manifest', and find out that there is no AndroidManifest.xml created in build/intermediates/merged_manifest/.../merged. I've read this this and this, but did not solve my problem. How do I fix it? Thanks.

Here is the lib.gradle

apply plugin: 'com.android.library'
buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'io.fabric'
repositories {
    maven { url 'https://maven.fabric.io/public' }
    ...
}

dependencies {
    ...
    api('com.crashlytics.sdk.android:crashlytics:2.9.8@aar') {
        transitive = true
    }
}

And here is the project gradle

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        ...
    }
}

And this is the error: enter image description here

like image 785
Cheng.Xia Avatar asked Feb 02 '19 05:02

Cheng.Xia


3 Answers

I had the same issue and fixed it for me like following, using Ionic 5, Capacitor and the Cordova FirebaseX Plugin (which references to Crashlytics) , may you need to adjust some paths to fit your environment:

  1. Running the Gradlew Build Command like ./gradlew assembleDebug.
  2. Waiting for the error you get.
  3. Copy the AndroidManifest.xml from your-app/src/main/AndroidManifest.xml to your-app/build/intermediates/merged_manifests/debug/AndroidManifest.xml.
  4. Re-Run the Gradlew Build Command, ./gradlew assembleDebug`.
  5. Your build process should succeed now.

In my case with Ionic 5 and Capacitor the paths are:

  • android/capacitor-cordova-android-plugins/src/main/AndroidManifest.xml
  • android/capacitor-cordova-android-plugins/build/intermediates/merged_manifests/debug/AndroidManifest.xml

Hope it helps you.

like image 24
Unkn0wn0x Avatar answered Nov 08 '22 16:11

Unkn0wn0x


Have you tried configuring everything exactly as required for a Crashlytics setup with a library module and a base project? It seems the new Gradle plugin doesn't work if the setup is different from the one recommended here.

For me removing "apply plugin: 'io.fabric'" from the library's build.gradle file (but leaving it in the application build.gradle) solved this error.

like image 139
Roman Potapov Avatar answered Nov 08 '22 14:11

Roman Potapov


I've got a fix for this while keeping Crashlytics dependencies out of the app module, but it's very hacky.

From what I can tell the io.fabric plugin primarily exists to generate a build ID for crashlytics, which is important to the Fabric platform but goes unused for Firebase. This, I assume, is vestigial functionality that will eventually be removed when Crashlytics completes its migration to Firebase, but in the meantime it's quite necessary simply because Crashlytics checks for it and crashes your app if it's not there.

So, I simply created a useless dummy build ID and removed all mention of the ui.fabric plugin from my modules, and it works! My code compiles and reports crashes to the firebase console as it did previously, and I can update to android gradle plugin v3.3.0+ with no issues.


The specific steps I took were:

Add this to the main/res/values.xml file in the module that uses crashlytics:

<string name="com.crashlytics.android.build_id" translatable="false">RANDOM_UUID</string>

And remove all usages of the io.fabric gradle plugin, as well as the classpath dependency on the gradle plugin (as you no longer use it).


Note that, as I said, this is very hacky. I'd suggest testing this thoroughly if you take this approach for your project. There might be some functionality that does still use the build ID and this would cause it to break.

EDIT: after further investigation I believe that doing this will prevent crashlytics from uploading your mapping file, which means you will have to manually deobfuscate stack traces. This is still an option at least, but does seem to have drawbacks. Also worth noting that you can also simply use:

<string name="com.crashlytics.RequireBuildId">false</string>

instead of providing a dummy build ID.

like image 3
Evan Debenham Avatar answered Nov 08 '22 14:11

Evan Debenham