我正在使用具有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$2.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>
有人可以指出我在这里做错了什么吗?请让我知道我是否使用了正确的标签,因为我对这样的东西非常不熟悉。
答案 0 :(得分:1)
我找到了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>
这样做以来,该应用程序每次都会成功启动,并将元数据标签放置在正确的位置。