android-mapviewballoons,如果我使用 ProGuard 构建,onBalloonTap 不起作用

发布于 2025-01-03 19:32:44 字数 1766 浏览 0 评论 0原文

我正在使用 android-mapviewballoons (https://github.com/jgilfelt/android-mapviewballoons) 开发一个项目。我使用名为 CustomItemizedOverlay 的自定义类扩展了 com.readystatesoftware.mapviewballoons.BalloonItemizedOverlay,并在该类中重新定义了 onBalloonTap(int index)。

当我在不使用 proguard 的情况下构建签名的 APK 时,一切正常:应用程序运行,我可以点击地图,查看气球,点击气球,然后通过 onBalloonTap 获取有关我点击的点的更多信息。 当我在 proguard 处于活动状态的情况下构建时,除了气球之外,应用程序运行完美:我可以点击地图,看到气球,但当我点击它时什么也没有发生。就像气球本身是透明的一样,如果它后面有东西,它就会被选中,就像气球不在那里一样。

我尝试从 proguard.cfg 中一一删除功能,但找不到发生了什么。我尝试使用 -dontoptimize 但没有成功。我认为问题可能来自于混淆过程,但我无法避免混淆,因为如果我放置 -dontobfuscate 指令,构建会失败并显示“Dalvik Error 1”消息。

在我的 proguard 文件的“库”部分中,我有: (...)

-libraryjars /home/marco/workspace/../Scrivania/android-sdk-linux/add-ons/addon-google_apis-google_inc_-7/libs/maps.jar

-libraryjars /home/marco/workspace/android-mapviewballoons/bin/android-mapviewballoons.jar

在“保留”部分我(除其他外):

-keep public class * extends com.google.android.maps.MapActivity

-keep class com.posteitaliane.postemobile.CoverFlow

-keepclassmembers public class com.readystatesoftware.mapviewballoons.BalloonItemizedOverlay.** {
                public static * ;
        }

-keepclassmembers public class com.posteitaliane.postemobile.CustomItemizedOverlay.** {
                public static * ;
        }

-keepclassmembers public class com.readystatesoftware.mapviewballoons.** {
                public static * ;
        }

有人可以帮助我吗?我只是不知道如何在不破坏 proguard 或丢失此 mapBalloon 功能的情况下创建签名构建。

预先感谢您

编辑 2012/03/19 我通过在项目中导入更高版本的mapviewballoons并修复代码以适应mapviewballoons本身的新功能解决了这个问题。请参阅https://github.com/jgilfelt/android-mapviewballoons/issues/16

I'm developing a project using android-mapviewballoons (https://github.com/jgilfelt/android-mapviewballoons). I extended com.readystatesoftware.mapviewballoons.BalloonItemizedOverlay with a customized class called CustomItemizedOverlay and in this class I redefined onBalloonTap(int index).

When I build a signed APK without using proguard everything works fine: the application runs, I can tap on the map, see the Balloon, tap on the balloon and, via onBalloonTap, get further information about the point I've been tapping on.
When I build with proguard active the application runs flawlessly except for the balloon: I can tap on the map, see the balloon but when I click on it nothing happens. It's just as the balloon itself was transparent, if there's something behind it it gets selected, just as the balloon was not there.

I tried removing features from proguard.cfg one by one, but couldn't find what's happening. I tried with -dontoptimize but didn't work. I think that maybe the issue comes from the obfuscation process, but I can't avoid obfuscation because if I put the -dontobfuscate directive building fails with a "Dalvik Error 1" message.

In the "library" section of my proguard file I have:
(...)

-libraryjars /home/marco/workspace/../Scrivania/android-sdk-linux/add-ons/addon-google_apis-google_inc_-7/libs/maps.jar

-libraryjars /home/marco/workspace/android-mapviewballoons/bin/android-mapviewballoons.jar

In the "keep" section I have (among others):

-keep public class * extends com.google.android.maps.MapActivity

-keep class com.posteitaliane.postemobile.CoverFlow

-keepclassmembers public class com.readystatesoftware.mapviewballoons.BalloonItemizedOverlay.** {
                public static * ;
        }

-keepclassmembers public class com.posteitaliane.postemobile.CustomItemizedOverlay.** {
                public static * ;
        }

-keepclassmembers public class com.readystatesoftware.mapviewballoons.** {
                public static * ;
        }

Could somebody please help me? I just don't know how to create a signed build without breaking proguard or losing this mapBalloon feature.

Thank you in advance

Edit 2012/03/19
I solved the issue by importing a later version of mapviewballoons in the project and fixing the code to fit the new features of mapviewballoons itself. See https://github.com/jgilfelt/android-mapviewballoons/issues/16

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文