【问题标题】:Google translate.detect crashes after ProguardProguard 后 Google translate.detect 崩溃
【发布时间】:2019-05-10 02:24:32
【问题描述】:

它在调试版本中运行良好,但在 Proguard 之后的发布版本中崩溃。

这是崩溃的代码

TranslateOptions options = TranslateOptions.newBuilder()
                .setApiKey(context.getString(R.string.google_api_key))
                .build();
        Translate translate = options.getService();
        Detection detection = translate.detect(sourceText);

最后一行崩溃。

这是 Proguard 规则

-keep class com.google.**
-keep interface com.google.**
-dontwarn com.google.**

【问题讨论】:

  • 您找到解决问题的方法了吗?我正在使用 Translation Api 并面临类似的问题。

标签: android proguard


【解决方案1】:

检查 Proguard 配置部分。

https://medium.com/@amsanjeev/adding-translate-api-to-android-apps-788c5bca5521

-keepclassmembers class * {
 @com.google.api.client.util.Key <fields>;
}
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault


-dontwarn org.joda.convert.**
-dontwarn com.google.**
-dontwarn com.google.auto.**
-dontwarn autovalue.shaded.com.**
-dontwarn sun.misc.Unsafe
-dontwarn javax.lang.model.element.Modifier

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-09
    • 1970-01-01
    • 1970-01-01
    • 2018-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多