com.google.android.support:wearable:2.4.0和AndroidX迁移

时间:2019-08-01 22:06:50

标签: android gradle wear-os androidx

我正在尝试将项目迁移到AndroidX,但是遇到与com.google.android.support:wearable:2.4.0相关的问题。

此库未迁移到AndroidX,并且似乎依赖于其他支持库,这会导致Dex合并错误,例如:

Caused by: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
    at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:72)
    at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Caused by: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/os/ResultReceiver$1;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
    at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
    ... 1 more

我尝试通过使用

排除依赖的支持库
implementation ('com.google.android.support:wearable:2.4.0'){
        exclude module: 'support-v4'
        exclude module: 'appcompat-v7'
        exclude module: 'support-compat'
    }

但这只会导致另一个错误,表明它缺少必需的类:

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class android.support.wearable.complications.ComplicationHelperActivity, unresolved supertypes: android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback

请注意,我的gradle属性文件确实包括:

android.useAndroidX=true
android.enableJetifier=true

今天是否无法通过WearOS代码使用AndroidX?

0 个答案:

没有答案