如果我将我的 Fabric API 键放在应用程序标签中,则会发生未满足的依赖性异常

UnmetDependencyException occurs if I put my Fabric API key in the application tag

我正在使用具有 Fabric SDK 的新代码库。我认为我们 AndroidManifest.xml 的问题导致某些 android 设备上的应用程序崩溃。我们不断收到此错误:

04-30 21:25:05.770 E/Fabric  (31863): Error dealing with settings
04-30 21:25:05.770 E/Fabric  (31863): java.lang.IllegalArgumentException: Fabric could not be initialized, API key missing from AndroidManifest.xml. Add the following tag to your Application element 
04-30 21:25:05.770 E/Fabric  (31863):   <meta-data android:name="io.fabric.ApiKey" android:value="YOUR_API_KEY"/>
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.services.common.ApiKey.logErrorOrThrowException(ApiKey.java:130)
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.services.common.ApiKey.getValue(ApiKey.java:67)
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.services.settings.Settings.initialize(Settings.java:78)
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.Onboarding.retrieveSettingsData(Onboarding.java:124)
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.Onboarding.doInBackground(Onboarding.java:99)
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.Onboarding.doInBackground(Onboarding.java:45)
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
04-30 21:25:05.770 E/Fabric  (31863):   at io.fabric.sdk.android.services.concurrency.AsyncTask.call(AsyncTask.java:311)
04-30 21:25:05.770 E/Fabric  (31863):   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-30 21:25:05.770 E/Fabric  (31863):   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
04-30 21:25:05.770 E/Fabric  (31863):   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-30 21:25:05.770 E/Fabric  (31863):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
04-30 21:25:05.770 E/Fabric  (31863):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
04-30 21:25:05.770 E/Fabric  (31863):   at java.lang.Thread.run(Thread.java:761)

我注意到 <application> 节点中没有我们的元数据标记,而是它的同级标记。当我将元数据标签放入其中时,我在应用程序启动时看到此错误(并且应用程序崩溃):

Bindings.FabricSdk.Services.Concurrency.UnmetDependencyException <timeout occurred getting exception details>

这是我的 AndroidManifest.xml 的内容,不包括任何敏感信息。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="My Obfuscated Package Name" android:versionName="3.0.5" android:versionCode="6" android:installLocation="auto">
    <uses-sdk android:targetSdkVersion="27" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application android:hardwareAccelerated="true" android:largeHeap="true" android:label="Obfuscated" android:icon="@mipmap/ic_launcher">
        <meta-data android:name="io.fabric.ApiKey" android:value="My Obfuscated Fabric API Key" />
    </application>
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>
</manifest>

谁能指出我在这里做错了什么?请让我知道我是否使用了正确的标签,因为我对这样的东西非常不熟悉。

我找到了this solution,但一开始没看懂。经过更多的挖掘,我发现我必须将 Crashlytics 构建 ID 字符串变量放在一个名为 strings.xml 的文件中。我没有这个文件,所以我在 Xamarin.Droid 项目的 Resources/values 文件夹中创建了它:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="com.crashlytics.android.build_id">e9e6beb9c4284289ac68b9ab76a9ee56</string>
</resources>

执行此操作后,应用程序每次都成功启动,并且元数据标记位于正确的位置。