我试图在Android Studio 3.3中使用okbuck,但是我陷入了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)
我什至可以注释掉所有依赖项,删除-重新初始化okbuck(这样就没有缓存),并且在jetifier仍然打开的情况下,错误不断弹出。
我使用的是okbuck版本0.46.2,据说喷射器自0.44.1起开始工作。
最佳答案
当我从事okbuck示例项目时,遇到了与您类似的问题。我已经通过在根级别build.gradle中添加jetifier块解决了此问题。请参阅已修复AndroidX问题的请求请求here。
这是与okbuck相关的整个代码块。
okbuck {
buildToolVersion = '28.0.3'
lint {
disabled = true
}
externalDependencies {
downloadInBuck = false
}
jetifier {
aarOnly = true
}
}
关于android - OkBuck不适用于零依赖的Android Jetifier,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54345390/