织物库中的畸形异常

Malformed exception in fabric library

最近我在我的日志中看到一个异常,即 fabric (Beta) 试图检查更新,这是错误:

E/Beta: Error while checking for updates from null
io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: java.net.MalformedURLException: Protocol not found: null?instance=

我不知道为什么 fabric 会尝试使用 null URL 检查更新,但我真的想删除该错误。

详细堆栈跟踪:

E/Beta: Error while checking for updates from null
    io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: java.net.MalformedURLException: Protocol not found: null?instance=7f856ab5-12f8-4723-9e84-569dab8e9760&build_version=1030300&display_version=1.3.3&source=3
    at io.fabric.sdk.android.services.network.HttpRequest.encode(HttpRequest.java:722)
    at io.fabric.sdk.android.services.network.HttpRequest.get(HttpRequest.java:865)
    at io.fabric.sdk.android.services.network.DefaultHttpRequestFactory.buildHttpRequest(DefaultHttpRequestFactory.java:85)
    at io.fabric.sdk.android.services.common.AbstractSpiCall.getHttpRequest(AbstractSpiCall.java:137)
    at com.crashlytics.android.beta.CheckForUpdatesRequest.invoke(CheckForUpdatesRequest.java:48)
    at com.crashlytics.android.beta.AbstractCheckForUpdatesController.performUpdateCheck(AbstractCheckForUpdatesController.java:166)
    at com.crashlytics.android.beta.AbstractCheckForUpdatesController.checkForUpdates(AbstractCheckForUpdatesController.java:139)
    at com.crashlytics.android.beta.AbstractCheckForUpdatesController.initialize(AbstractCheckForUpdatesController.java:91)
    at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:78)
    at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:30)
    at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
    at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
    at io.fabric.sdk.android.services.concurrency.AsyncTask.call(AsyncTask.java:311)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.net.MalformedURLException: Protocol not found: null?instance=7f856ab5-12f8-4723-9e84-569dab8e9760&build_version=1030300&display_version=1.3.3&source=3
    at java.net.URL.<init>(URL.java:176)
    at java.net.URL.<init>(URL.java:125)
    at io.fabric.sdk.android.services.network.HttpRequest.encode(HttpRequest.java:720)
    at io.fabric.sdk.android.services.network.HttpRequest.get(HttpRequest.java:865) 
    at io.fabric.sdk.android.services.network.DefaultHttpRequestFactory.buildHttpRequest(DefaultHttpRequestFactory.java:85) 
    at io.fabric.sdk.android.services.common.AbstractSpiCall.getHttpRequest(AbstractSpiCall.java:137) 
    at com.crashlytics.android.beta.CheckForUpdatesRequest.invoke(CheckForUpdatesRequest.java:48) 
    at com.crashlytics.android.beta.AbstractCheckForUpdatesController.performUpdateCheck(AbstractCheckForUpdatesController.java:166) 
    at com.crashlytics.android.beta.AbstractCheckForUpdatesController.checkForUpdates(AbstractCheckForUpdatesController.java:139) 
    at com.crashlytics.android.beta.AbstractCheckForUpdatesController.initialize(AbstractCheckForUpdatesController.java:91) 
    at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:78) 
    at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:30) 
    at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63) 
    at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28) 
    at io.fabric.sdk.android.services.concurrency.AsyncTask.call(AsyncTask.java:311) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
    at java.lang.Thread.run(Thread.java:818) 

我通过更新 crashlytics 库版本解决了很多错误日志和上面的异常。

我还解决了更新 /app/build.gradle 文件中的 Crashlytics 版本的问题。

为了方便起见,我在这里留下修复代码:

dependencies {

    compile('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
        transitive = true;
    }

}