广告未在发布模式下显示 [英] Ads not showing up in release mode

查看:67
本文介绍了广告未在发布模式下显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应该显示一些广告的应用.在调试模式下,一切正常,广告显示正常.

I have an app which is supposed to show some ads. In debug mode, everything runs fine, ads are showing up as they should be.

但在发布模式下,即使运行完全相同的代码(并且使用相同的 URL),也不会发生任何事情.我也有多个环境(测试/生产),它在测试/调试和生产/调试中运行良好,但在测试/发布和生产/发布中都失败.

But in release mode, nothing happens, even though the exact same code is running (and the same URLs are used). I also have multiple environments (test/production), it works fine in test/debug and production/debug but fails in both test/release and production/release.

请注意,其他一切在发布模式下都可以正常工作.在任何地方都找不到与此类错误相关的主题.

Note that everything else is working fine in release mode. No relevant topic were found anywhere about this kind of bug.

推荐答案

正如您所确认的,这是一个 Proguard 问题.

As you confirmed, this is a Proguard issue.

Proguard 的主要功能是缩小您的代码,将诸如doImportantThing"之类的函数名称替换为a"等,使其重量更轻且更难逆向工程.

Proguard's main function is to minify your code, replacing function names such as "doImportantThing" to "a" etc, making it more light weight and harder to reverse engineer.

一个快速的解决方法是通过在 gradle 发布块中将 minifyEnabled 设置为 false 来禁用缩小,但这意味着 Proguard 被禁用并且不会执行重要的前面提到的功能.

A quick fix would be to disable minification by setting minifyEnabled to false in the gradle release block, however this would mean that Proguard is disabled and does not perform the important functions mentioned earlier.

真正的修复是编辑您的 proguard-rules 文件,并确保 Proguard 从缩小过程中排除某些类.

The real fix would be to edit your proguard-rules file, and make sure Proguard excludes certain classes from the minification process.

这里是关于如何使用 & 的小指南.配置 Proguard,但您可以在网络上找到更多内容.

Here is a small guide on how to use & configure Proguard, but you can find a lot more content on the web.

希望这会有所帮助.

这篇关于广告未在发布模式下显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆