【问题标题】:Android studio showing error in build.gradle fileAndroid Studio 在 build.gradle 文件中显示错误
【发布时间】:2018-05-31 13:56:32
【问题描述】:

我有一个工作项目,今天当我在将近 2 周后设置它时,它在 build.gradle 文件中显示错误。我可能已经安装了 android studio 更新。以下是我在 gradle 文件中的内容:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '27.0.3'
    defaultConfig {
    applicationId "com.shaon.myapp"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
    })

    // RecyclerView

    // CardView
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.2.0'
    compile 'com.android.support:recyclerview-v7:25.2.0'
    compile 'com.android.support:cardview-v7:25.2.0'
    testCompile 'junit:junit:4.12'

    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    compile 'org.jsoup:jsoup:1.7.3'

    compile 'com.android.support:palette-v7:+'
}

我从构建选项卡进入的错误是:

../../Users/xxx/.gradle/caches/transforms-1/files-1.1/appcompat-v7-25.2.0.aar/a15b23bb4246ae6c7bb03ff4cce6bf47/res/values/values.xml    
    error: resource android:attr/fontStyle not found.   
    error: resource android:attr/font not found.    
    error: resource android:attr/fontWeight not found.  
    error: resource android:attr/fontVariationSettings not found.   
    error: resource android:attr/ttcIndex not found.    

也在compile 'com.android.support:appcompat-v7:25.2.0' 行的声明中 - 显示错误:

所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 28.0.0-alpha1、26.0.0-alpha1、25.2.0。示例包括 com.android.support:collections:28.0.0-alpha1 和 com.android.support:animated-vector-drawable:26.0.0-alpha1 less... (Ctrl+F1) 有一些库或工具和库的组合是不兼容的,或者可能导致错误。一种这样的不兼容性是使用不是最新版本的 Android 支持库版本进行编译(或者特别是低于您的 targetSdkVersion 的版本)。

我该如何解决?

【问题讨论】:

  • 尝试“build->clean Project”并再次重建

标签: android android-studio android-gradle-plugin build.gradle


【解决方案1】:

使用实际版本而不是加号

support:palette-v7:+'

确保该版本与其他 v7 版本匹配

【讨论】:

  • 谢谢,它成功了。刚改成:compile 'com.android.support:palette-v7:25.2.0'
猜你喜欢
  • 2016-01-01
  • 2020-10-09
  • 1970-01-01
  • 1970-01-01
  • 2016-12-28
  • 1970-01-01
  • 1970-01-01
  • 2019-04-05
相关资源
最近更新 更多