【问题标题】:Add androidx support for external library添加对外部库的 androidx 支持
【发布时间】: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 的支持?

标签: android external androidx


【解决方案1】:

您可以尝试将 jetifier 和 androidx 标志添加到 gradle.properties 文件。

android.useAndroidX=true android.enableJetifier=true

这里有你的原因:https://stackoverflow.com/a/52034414/12009871

【讨论】:

    猜你喜欢
    • 2020-06-03
    • 1970-01-01
    • 1970-01-01
    • 2020-12-14
    • 2016-05-13
    • 2020-04-21
    • 1970-01-01
    • 1970-01-01
    • 2023-02-20
    相关资源
    最近更新 更多