将依赖项迁移到 Android Jetpack

Migrating dependencies to Android Jetpack

所以我一直在将我的依赖项从支持库迁移到 Jetpack 映射,如 this link 中所述。

我现在在构建我的应用程序时遇到了一个错误,这让我一头雾水。我不知道是什么原因导致此错误,因为它看起来像是生成的资源。

错误是:

Android resource linking failed
Output:  C:\Users\Ruben\Documents\Bowvie\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:8673: error: expected reference but got (raw string) #000000.
error: failed linking references.

Command: C:\Users\Ruben\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-alpha14-4748712-windows.jarbbfcfb9476bccff8420ad6f86bed60\aapt2-3.2.0-alpha14-4748712-windows\aapt2.exe link -I\
        C:\Users\Ruben\AppData\Local\Android\Sdk\platforms\android-P\android.jar\
        --manifest\
        C:\Users\Ruben\Documents\Bowvie\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
        -o\
        C:\Users\Ruben\Documents\Bowvie\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
        -R\
        @C:\Users\Ruben\Documents\Bowvie\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        C:\Users\Ruben\Documents\Bowvie\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
        --custom-package\
        nl.fdyr.movies\
        -0\
        apk\
        --output-text-symbols\
        C:\Users\Ruben\Documents\Bowvie\app\build\intermediates\symbols\debug\R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.0-alpha14-4748712-windows Daemon #0

错误行(8673)是:

<style name="Widget.Support.CoordinatorLayout" parent="android:Widget">
    <item name="statusBarBackground">#000000</item>
</style>

新迁移的依赖项是:

implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.cardview:cardview:1.0.0-alpha1'
implementation 'androidx.browser:browser:1.0.0-alpha1'
implementation 'androidx.annotation:annotation:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
implementation 'androidx.core:core-ktx:1.0.0-alpha1'
implementation 'androidx.annotation:annotation:1.0.0-alpha1'
implementation 'androidx.slice:slice-core:1.0.0-alpha1'
implementation 'androidx.slice:slice-builders:1.0.0-alpha1'

经过大量的实验和搜索,似乎可以通过覆盖样式并将有问题的值 #000000 设置为 @null

来解决问题

在您的res/values/styles.xml中您可以添加

<style name="Widget.Support.CoordinatorLayout" parent="android:Widget"> <item name="statusBarBackground">@null</item> </style>

应该覆盖原始值并解决问题。