Gradle:构建失败:错误:添加api依赖项后找不到资源android:attr / fontVariationSettings com.microsoft.service

时间:2018-05-31 10:53:36

标签: android android-gradle

我正在尝试为列表构建Microsoft Sharepoint客户端。为此,我使用 Office365 服务库和API。我的gradle依赖项如下所示:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    api 'com.microsoft.aad:adal:2.0.4-alpha'
    api 'com.microsoft.services:sharepoint-services:1.0.0@aar'
    api 'com.microsoft.services.orc:orc-android:1.3.1'
    api 'com.google.guava:guava:25.1-android'
}

在gradle synch期间,它失败并显示错误:

    error: resource android:attr/fontVariationSettings not found.
    Message{kind=ERROR, text=error: resource android:attr/fontVariationSettings not found., sources=[C:\Users\rahul.deshmukh\.gradle\caches\transforms-1\files- 
   1.1\appcompat-v7-27.1.1.aar\014d6f324620f9879a964fbd74e0b4be\res\values\values.xml:251:5-69], 
   original message=, tool name=Optional.of(AAPT)}

Gradle文件显示鼠标错误:

  

implementation 'com.android.support:appcompat-v7:27.1.1'

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes).<br> Found versions 28.0.0-alpha1, 27.1.1. Examples include com.android.support:asynclayoutinflater:28.0.0-alpha1 and com.android.support:animated-vector-drawable:27.1.1 more... (Ctrl+F1)

不确定哪个库与哪个库发生冲突。任何帮助将不胜感激。

谢谢。

2 个答案:

答案 0 :(得分:1)

您的一个依赖项是使用仅在API 28(P)中添加的资源。找到该库并使用旧版本,或将您的编译SDK版本更新为“android P preview”(您可以使用SDK管理器下载它)。

答案 1 :(得分:0)

我必须改变执行顺序,并根据Izabela Orlowska的回答减少某些依赖项的版本。

以下是我的依赖项现在的样子:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    api 'com.google.guava:guava:25.1-android'
    api 'com.microsoft.aad:adal:1.14.0'
    api 'com.microsoft.services:sharepoint-services:1.0.0@aar'
    api 'com.microsoft.services:odata-engine-core:0.11.1'
    api 'com.microsoft.services:odata-engine-android-impl:0.11.1@aar'
    api 'com.microsoft.services.orc:orc-android:1.3.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

我现在摆脱了这个障碍。感谢所有评论和建议的人。