我在 Android 应用程序 .apk 中使用的库是否会与另一个应用程序中使用的库发生冲突?

发布于 2024-10-16 08:42:27 字数 2999 浏览 1 评论 0原文

我将 jets3t 链接到一个测试应用程序中,并得到了我在安装过程中尚未看到的日志猫。

02-08 12:21:11.825: DEBUG/PackageParser(1086): Scanning package: /data/app/vmdl28891.tmp
02-08 12:21:12.059: DEBUG/PackageManager(1086): Scanning package org.jets3t
02-08 12:21:12.075: INFO/PackageManager(1086): /data/app/org.jets3t-1.apk changed; unpacking
02-08 12:21:12.082: DEBUG/installd(1009): DexInv: --- BEGIN '/data/app/org.jets3t-1.apk' ---
02-08 12:21:12.481: DEBUG/dalvikvm(26867): creating instr width table
02-08 12:21:12.715: DEBUG/dalvikvm(26867): DexOpt: 'Lorg/apache/commons/codec/Decoder;' has an earlier definition; blocking out
02-08 12:21:12.715: DEBUG/dalvikvm(26867): DexOpt: 'Lorg/apache/commons/codec/BinaryDecoder;' has an earlier definition; blocking out
02-08 12:21:12.715: DEBUG/dalvikvm(26867): DexOpt: 'Lorg/apache/commons/codec/Encoder;' has an earlier definition; blocking out
02-08 12:21:12.715: DEBUG/dalvikvm(26867): DexOpt: 'Lorg/apache/commons/codec/BinaryEncoder;' has an earlier definition; blocking out
... many more ...
'Lorg/apache/commons/logging/impl/WeakHashtable$Entry;': multiple definitions
02-08 12:21:12.973: DEBUG/dalvikvm(26867): DexOpt: not verifying 'Lorg/apache/commons/logging/impl/WeakHashtable$Referenced;': multiple definitions
02-08 12:21:12.973: DEBUG/dalvikvm(26867): DexOpt: not verifying 'Lorg/apache/commons/logging/impl/WeakHashtable$WeakKey;': multiple definitions
02-08 12:21:12.973: DEBUG/dalvikvm(26867): DexOpt: not verifying 'Lorg/apache/commons/logging/impl/WeakHashtable;': multiple definitions
02-08 12:21:13.168: INFO/dalvikvm(26867): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/logging/LogFactory;'
... many more ...
02-08 12:21:13.364: INFO/dalvikvm(26867): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/logging/LogFactory;'
02-08 12:21:13.387: DEBUG/libgps(1086): GpsInterface_inject_location( 37.378289, -122.059655, 897.000 )
02-08 12:21:13.387: DEBUG/dalvikvm(26867): DexOpt: load 111ms, verify 540ms, opt 21ms
02-08 12:21:13.543: DEBUG/installd(1009): DexInv: --- END '/data/app/org.jets3t-1.apk' (success) ---
02-08 12:21:13.551: INFO/ActivityManager(1086): Force stopping package org.jets3t uid=10084
02-08 12:21:13.559: DEBUG/PackageManager(1086):   Activities: org.jets3t.MainActivity
02-08 12:21:13.832: INFO/installd(1009): move /data/dalvik-cache/data@[email protected]@classes.dex -> /data/dalvik-cache/data@[email protected]@classes.dex
02-08 12:21:13.832: DEBUG/PackageManager(1086): New package installed in /data/app/org.jets3t-1.apk

我正在将其视为共享库覆盖。如果是的话,我想知道这是否是我做错了什么的结果?如果我覆盖,其他应用程序崩溃的可能性有多大?当然,任何正确创建的库都将向后兼容..我猜Android包mgr不会用旧版本替换包?

加上“多重定义”? “没有解决模糊类”?

哦是的..测试应用程序到目前为止似乎工作正常:)

谢谢。我想我需要去阅读 pkg 安装、加载和链接,哈哈。

I linked jets3t into a test app and got logcats I've not yet seen during install ..

02-08 12:21:11.825: DEBUG/PackageParser(1086): Scanning package: /data/app/vmdl28891.tmp
02-08 12:21:12.059: DEBUG/PackageManager(1086): Scanning package org.jets3t
02-08 12:21:12.075: INFO/PackageManager(1086): /data/app/org.jets3t-1.apk changed; unpacking
02-08 12:21:12.082: DEBUG/installd(1009): DexInv: --- BEGIN '/data/app/org.jets3t-1.apk' ---
02-08 12:21:12.481: DEBUG/dalvikvm(26867): creating instr width table
02-08 12:21:12.715: DEBUG/dalvikvm(26867): DexOpt: 'Lorg/apache/commons/codec/Decoder;' has an earlier definition; blocking out
02-08 12:21:12.715: DEBUG/dalvikvm(26867): DexOpt: 'Lorg/apache/commons/codec/BinaryDecoder;' has an earlier definition; blocking out
02-08 12:21:12.715: DEBUG/dalvikvm(26867): DexOpt: 'Lorg/apache/commons/codec/Encoder;' has an earlier definition; blocking out
02-08 12:21:12.715: DEBUG/dalvikvm(26867): DexOpt: 'Lorg/apache/commons/codec/BinaryEncoder;' has an earlier definition; blocking out
... many more ...
'Lorg/apache/commons/logging/impl/WeakHashtable$Entry;': multiple definitions
02-08 12:21:12.973: DEBUG/dalvikvm(26867): DexOpt: not verifying 'Lorg/apache/commons/logging/impl/WeakHashtable$Referenced;': multiple definitions
02-08 12:21:12.973: DEBUG/dalvikvm(26867): DexOpt: not verifying 'Lorg/apache/commons/logging/impl/WeakHashtable$WeakKey;': multiple definitions
02-08 12:21:12.973: DEBUG/dalvikvm(26867): DexOpt: not verifying 'Lorg/apache/commons/logging/impl/WeakHashtable;': multiple definitions
02-08 12:21:13.168: INFO/dalvikvm(26867): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/logging/LogFactory;'
... many more ...
02-08 12:21:13.364: INFO/dalvikvm(26867): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/logging/LogFactory;'
02-08 12:21:13.387: DEBUG/libgps(1086): GpsInterface_inject_location( 37.378289, -122.059655, 897.000 )
02-08 12:21:13.387: DEBUG/dalvikvm(26867): DexOpt: load 111ms, verify 540ms, opt 21ms
02-08 12:21:13.543: DEBUG/installd(1009): DexInv: --- END '/data/app/org.jets3t-1.apk' (success) ---
02-08 12:21:13.551: INFO/ActivityManager(1086): Force stopping package org.jets3t uid=10084
02-08 12:21:13.559: DEBUG/PackageManager(1086):   Activities: org.jets3t.MainActivity
02-08 12:21:13.832: INFO/installd(1009): move /data/dalvik-cache/data@[email protected]@classes.dex -> /data/dalvik-cache/data@[email protected]@classes.dex
02-08 12:21:13.832: DEBUG/PackageManager(1086): New package installed in /data/app/org.jets3t-1.apk

I'm reading that as shared library overwrites. If it is, I'm wondering if this is a result of something I did wrong? If I overwrite, what are the chances that other apps could break? Of course any properly created library will be backward compatible .. and I guess Android package mgr would not replace a package with an older variant?

Plus "multiple definitions"? "not resolving ambiguous class"?

Oh yeah.. the test app seems to work fine so far :)

Thanks. Guess I need to go read up on pkg install, load, and link lol.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵你的手,一向走下去 2024-10-23 08:42:27

我相信,真正损坏正确保护的设备上的另一个应用程序的唯一方法是替换它所依赖的 .apk。

在我看来,您正在安装一个 .apk,其中包含与该设备的平台库中的某些内容重复的类。新的重复项将被忽略。这并不罕见,因为平台中有各种极具吸引力的“私有”功能,但 SDK 中没有“标头”(抱歉,术语错误,但传达了这个想法)。如果不包含存根来满足编译器的要求(或使用反射在运行时查找真正的类),这使得编写代码变得困难。在安装时,这些存根会被忽略,并显示您所看到的警告消息。

这不一定是好的做法,但只要设备上的私有功能继续按预期工作,它往往就会起作用 - 即,它可能会在操作系统升级或程序安装在不同的设备上时中断。由于这个原因,Android 人员非常坚持地告诉你不要使用私有功能。

尽管存在错误/警告消息,但仍能正常工作的代码中保留的错误/警告消息也不是很好的做法,而且不幸的是,这确实是 Android 堆栈本身特有的东西。

I believe the only way you'd actually damage another application on a properly secured device is if you replace an .apk it depends on.

It looks to me more like you are installing an .apk which contains classes that duplicate some in the platform libraries of that device. The new duplicates are being ignored. This is not uncommon, as there is a variety of highly attractive 'private' functionality in the platform which doesn't have "headers" (sorry, wrong term, but conveys the idea) in the sdk. This makes it hard to write against without including stubs to satisfy the compiler (or using reflection to find the real classes at runtime). At install time those stubs get ignored with warning messages as you are seeing.

This is not necessarily good practice, but it tends to work as long as the private functionality on the device continues to work as expected - ie, it can break in an an OS upgrade or when the program is installed on a different device. The Android people are pretty persistent in telling you not to use private functionality for that reason.

Error/warning message remaining in shipping code that works despite them is also not great practice, and is unfortunately something really endemic to the android stack itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文