30

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

Cheng
  • 541
  • 5
  • 17

3 Answers3

44

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.

Roman Potapov
  • 531
  • 5
  • 7
  • Thanks for reply. I've tried, but do not fix it. Besides, it works in gradle:3.2.1 so I think this configuration is fine. When update to 3.3.0 there is no AndroidManifest.xml created in intermediates/.../merged, so I guess that's why this error reported. – Cheng Feb 14 '19 at 00:33
6

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.

Community
  • 1
  • 1
Unkn0wn0x
  • 1,031
  • 1
  • 12
  • 14
  • Thanks for reply. It looks like a easier way to accomplished. – Cheng Apr 20 '20 at 05:18
  • Thanks, had exactly the same issue and this fixed it. but now getting AAPT: error: resource color/accent (aka com.flexeventsapp.flex:color/accent) not found. have you run into this by any chance ? – ihor.eth May 22 '20 at 17:26
  • @ihorbond I follow the step to got stuck there, have you been able to fix it yet? – Zen3515 May 28 '20 at 16:09
  • 1
    @Zen3515 yes, I did. I created a color.xml (https://pastebin.com/6SmQYt4H) file and put in \android\app\src\main\res\values – ihor.eth May 28 '20 at 16:16
  • @ihorbond thanks, so I ended up creating the color inside resource. I wanted to add that you must not rebuild the project, it will be reset back. – Zen3515 May 28 '20 at 17:46
  • @Zen3515 yeah it's annoying, I had to add post script that I run after rebuild to copy the manifest again, the color.xml seems to stay though. Is that what you are doing too ? – ihor.eth May 28 '20 at 17:59
  • 1
    You're already on the right way. It seems you have some plugins which require an additional config.xml with (in your case) color definitions. You need to copy this too, may you can create a small script for copying static resources. – Unkn0wn0x May 28 '20 at 18:17
  • Life saver Thanks bro !! – Kishan Oza Jun 29 '20 at 10:39
3

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.

  • 1
    Thanks for the reply. I fix it according to @Roman Potapov 's answer. First, move plugin to app.gradle buildscript { repositories { maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'io.fabric.tools:gradle:1.+' } } apply plugin: ‘io.fabric' Then keep this in my lib.gralde repositories { maven { url "https://jitpack.io" } maven { url 'https://maven.fabric.io/public' } } api('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') { transitive = true } – Cheng Apr 18 '19 at 01:27
  • Yes, that should work as well, my point when providing this solution is that it keeps all of Crashlytics in the library module. My whole reason for using a library module in the first place was to completely decouple my code from firebase / crashlytics. – Evan Debenham Apr 18 '19 at 02:11
  • Yes, That make sense. – Cheng Apr 18 '19 at 03:25