【问题标题】:Migrate annotation processor to androidX将注释处理器迁移到 androidX
【发布时间】:2018-09-27 13:19:06
【问题描述】:

我有一个带有以下依赖项的 android 注释处理器:

compile 'com.squareup:javapoet:1.10.0'
compile 'com.google.android:android:4.1.1.4'
compile 'com.google.android:support-v4:r7'

在我的处理器中,我访问 ActivityFragment 类。我现在需要哪些内容才能使用新的 android x Fragment?我找不到任何关于这个的...

我天真地尝试添加

implementation 'androidx.fragment:fragment:1.0.0'
// or
implementation 'androidx.appcompat:appcompat:1.0.0'

但这无济于事......

【问题讨论】:

    标签: android androidx annotation-processor


    【解决方案1】:

    在新的 AndroidX 项目上,Fragments 的导入是这样的:

    import androidx.fragment.app.Fragment
    

    这意味着,您应该已经添加了依赖项并迁移到 AndroidX,这将显示如下所示的依赖项:

    implementation 'androidx.appcompat:appcompat:1.0.0'
    

    所以,你可能不需要这个:

    implementation 'androidx.fragment:fragment:1.0.0'
    

    【讨论】:

    • 我试过androidx.appcompat:appcompat:1.0.0,但这在我的java项目中不起作用。在我的 android 项目中,我使用它,但它们应该是一些仅声明用于注释处理器的类的最小库...
    • 你没有使用 Migrate to Androidx by Android Studio 吗?或者您只是自己添加了依赖项?如您所知,我们以前和现在都不习惯为Fragments 使用另一个依赖项,这就像同样的情况。
    猜你喜欢
    • 1970-01-01
    • 2012-03-22
    • 1970-01-01
    • 2020-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多