求助:Crashlytics无法存入Kit[]数组引发ArrayStoreException异常
Hey there, let's tackle this ArrayStoreException you're hitting when initializing Crashlytics in your SoberSplash Activity. This error usually boils down to type mismatches from dependency inconsistencies or incorrect setup, so let's walk through the fixes step by step:
Common Causes & Solutions
1. Mismatched Fabric/Crashlytics Dependency Versions
This is the most likely culprit. The error says com.crashlytics.android.Crashlytics can't be stored in an array of io.fabric.sdk.android.Kit[]—that means the Crashlytics version you're using isn't compatible with the underlying Fabric SDK version (or vice versa).
- Fix: Ensure all Fabric-related dependencies use matching versions. For your
crashlytics:2.9@aar, you need to include the corresponding Fabric SDK dependency. Add this to your module-levelbuild.gradle:
Double-check that versions align—Crashlytics 2.9 pairs with Fabric SDK 1.4.0, which is the compatible match for this release.compile('io.fabric.sdk.android:fabric:1.4.0@aar')
2. Correct Your Initialization Code
If you're manually creating a Kit[] array to pass to Fabric.with(), this could be causing the type mismatch (especially with version conflicts). Stick to the standard initialization pattern:
- Incorrect (may trigger the error):
Kit[] kits = new Kit[]{new Crashlytics()}; Fabric.with(this, kits); - Correct:
Even better, move this initialization to yourFabric.with(this, new Crashlytics());Applicationclass'sonCreate()method instead of an Activity—this ensures Crashlytics is set up early and consistently across your entire app.
3. Clean & Rebuild Your Project
Cached build artifacts often cause class loading conflicts that lead to this error. Try these steps:
- Run
Build > Clean Projectin Android Studio - Delete the
buildfolder in your app module - Invalidate caches with
File > Invalidate Caches... > Invalidate and Restart
4. Check for Duplicate Dependencies
You might have conflicting versions of Fabric/Crashlytics being pulled in by other libraries. Use the Gradle dependency tree to spot duplicates:
- Run this command in your project root:
./gradlew app:dependencies - Look for multiple entries of
crashlyticsorfabric-sdk-android, then exclude the older/conflicting versions using Gradle'sexcluderule.
5. Verify Fabric Plugin Setup
Make sure you have the Fabric plugin correctly configured:
- In your project-level
build.gradle:buildscript { repositories { maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'io.fabric.tools:gradle:1.+' } } - Apply the plugin in your module-level
build.gradle:apply plugin: 'io.fabric'
Final Notes
Start with checking dependency versions and cleaning your project—those two fixes resolve 90% of these type mismatch issues with Crashlytics. If you're still stuck, double-check that you're not using any outdated Fabric/Crashlytics APIs that might have changed between versions.
内容的提问来源于stack exchange,提问作者Tarun Sharma

