【发布时间】:2019-09-04 12:17:23
【问题描述】:
我将我的 Android 项目迁移到了 androidX,现在遇到了几个支持 androidX 的问题。我能够通过将外部库升级到其最新版本以支持 androidX 来修复其中的一些问题。但是我还有其他几年没有维护的库。例如,我正在使用 KenBurnsView 并收到以下错误:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val Activity.ivStoryItem: KenBurnsView! defined in kotlinx.android.synthetic.main.fragment_story_item
public val Dialog.ivStoryItem: KenBurnsView! defined in kotlinx.android.synthetic.main.fragment_story_item
public val android.app.Fragment.ivStoryItem: KenBurnsView! defined in kotlinx.android.synthetic.main.fragment_story_item
public val android.support.v4.app.Fragment.ivStoryItem: KenBurnsView! defined in kotlinx.android.synthetic.main.fragment_story_item
public val View.ivStoryItem: KenBurnsView! defined in kotlinx.android.synthetic.main.fragment_story_item.view
我已经尝试排除 support.v4。 KenBurnsView 中的库,但没有帮助。我该如何解决这个错误?
【问题讨论】:
-
你是否在 gradle.properties 中添加了这些行:android.useAndroidX=true android.enableJetifier=true
-
这将强制第三方库使用 AndroidX。
-
是的,它通过迁移到 android X 自动完成
-
像变体一样,您可以下载库的源代码并将其迁移到 AndroidX。然后将其添加到您的应用程序(如 apk 或 android 库)
-
@MaratZangiev 所以你的意思是唯一的解决方案是分叉每个库并自己添加对 androidX 的支持?