【问题标题】:stream was reset: null流被重置:空
【发布时间】:2017-05-04 23:31:07
【问题描述】:

我遇到了一个很难找到的奇怪错误 :-(

在我的 Android 应用程序中,我使用 Retrofit2Moshi 访问 API。我还使用proguard-android-optimize.txt 使我的应用程序干净而小巧。在我的proguard-rules.pro 我有:

-assumenosideeffects class timber.log.Timber { *; }
-assumenosideeffects class android.util.Log { *; }

使用这种组合,当我尝试访问 api 时收到此错误 stream was reset: null

要修复它,我必须从我的 proguard 配置中删除此 assumenosideeffects 行。但为什么?有谁知道为什么当 proguard 删除日志记录方法时我会遇到这个网络问题?

【问题讨论】:

    标签: android proguard retrofit2 android-proguard


    【解决方案1】:

    通配符* 匹配所有方法,包括超类中的方法,例如Object#wait()。您真的不想删除这些调用,因此您应该明确列出要删除调用的方法:

    -assumenosideeffects class android.util.Log {
        public static boolean isLoggable(java.lang.String, int);
        public static int v(...);
        public static int i(...);
        public static int w(...);
        public static int d(...);
        public static int e(...);
    }
    

    如果您指定通配符,ProGuard 已经打印出警告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-01
      • 2018-08-10
      • 1970-01-01
      • 1970-01-01
      • 2014-11-28
      • 1970-01-01
      • 2015-01-14
      • 2014-03-13
      相关资源
      最近更新 更多