3

我正在尝试将 okbuck 与 Android Studio 3.3 一起使用,但我被困在了 AndroidX 上。当我将所有依赖项转换为 androidx 并设置时:

android.enableJetifier=true
android.useAndroidX=true

运行时出现以下错误:

./buckw install --run //app:bin_debug
Exception in thread "main" java.lang.IllegalArgumentException: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx. 
at com.android.tools.build.jetifier.processor.transform.bytecode.CoreRemapperImpl.rewriteString(CoreRemapperImpl.kt:91)
        at com.android.tools.build.jetifier.processor.transform.bytecode.asm.CustomRemapper.mapValue(CustomRemapper.kt:75)
        at org.objectweb.asm.commons.ClassRemapper.visitField(ClassRemapper.java:113)
        at org.objectweb.asm.ClassReader.readField(ClassReader.java:883)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:694)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
        at com.android.tools.build.jetifier.processor.transform.bytecode.ByteCodeTransformer.runTransform(ByteCodeTransformer.kt:39)
        at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:366)
        at com.android.tools.build.jetifier.processor.archive.ArchiveFile.accept(ArchiveFile.kt:41)
        at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:348)
        at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:70)
        at com.android.tools.build.jetifier.processor.Processor.transformLibrary(Processor.kt:344)
        at com.android.tools.build.jetifier.processor.Processor.transform(Processor.kt:207)
        at com.android.tools.build.jetifier.processor.Processor.transform$default(Processor.kt:194)
        at com.android.tools.build.jetifier.standalone.Main.run(Main.kt:147)
        at com.android.tools.build.jetifier.standalone.Main$Companion.main(Main.kt:101)
        at com.android.tools.build.jetifier.standalone.Main.main(Main.kt)

我什至可以注释掉所有依赖项,delete-reinit okbuck(所以没有缓存)并且在 jetifier 仍然打开的情况下,错误不断弹出。

我使用 okbuck 版本 0.46.2,jetifier 据称从 0.44.1 开始工作。

4

1 回答 1

1

我在处理我的 okbuck 示例项目时遇到了与您类似的问题。我已经通过在根级 build.gradle 中添加一个 jetifier 块解决了这个问题。请参阅此处已修复 AndroidX 问题的拉取请求。

这是与okbuck相关的整个代码块。

okbuck {

    buildToolVersion = '28.0.3'

    lint {
       disabled = true
    }
    externalDependencies {
        downloadInBuck = false
    }
    jetifier {
        aarOnly = true
    }
}
于 2019-04-08T17:44:43.930 回答