本文介绍了Giphy Android SDK在发布版本中不返回任何数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

giphy的 docs 中的示例代码用于获得趋势gif是

The sample code from giphy's docs for getting trending gif is

/// Trending Gifs
client.trending(MediaType.gif, null, null, null, new 
CompletionHandler<ListMediaResponse>() {
    @Override
    public void onComplete(ListMediaResponse result, Throwable e) {
        if (result == null) {
            // Do what you want to do with the error
        } else {
            if (result.getData() != null) {  //Problem on release build
                for (Media gif : result.getData()) {
                    Log.v("giphy", gif.getId());
                }
            } else {
                Log.e("giphy error", "No results found");
            }
        }
    }
});

此代码在开发环境中可以正常工作.但是在发行版中,构建result.getData()始终返回null.无法弄清楚是什么问题.我也尝试过使用giphy的生产密钥,但是没有运气.

This code works fine on development environment. But in release build result.getData() always returns null. Unable to figure it out whats the issue. I have tried with giphy's production key also but no luck.

推荐答案

需要为giphy添加proguard规则

Need to add proguard rules for giphy

-keepclassmembernames class com.giphy.sdk.core.models.** { *; }
-keepclassmembernames class com.giphy.sdk.core.network.response.** { *; }
-keepattributes *Annotation*
-dontwarn com.giphy.sdk.core.**

这篇关于Giphy Android SDK在发布版本中不返回任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 13:42