使用Material Components和androidX编译Android应用时出错 [英] Error compiling Android app with Material Components and androidX

查看:279
本文介绍了使用Material Components和androidX编译Android应用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android应用程序突然拒绝构建,它返回此错误:

Android application suddenly refuses to build, it returns this error:

Android资源链接失败 错误:资源样式/Theme.MaterialComponents.Light.NoActionBar(又名 it.duemilanet.icircle:style/Theme.MaterialComponents.Light.NoActionBar) 找不到.

Android resource linking failed error: resource style/Theme.MaterialComponents.Light.NoActionBar (aka it.duemilanet.icircle:style/Theme.MaterialComponents.Light.NoActionBar) not found.

D:\ GitLab \ iCircleAndroidRMA \ app \ build \ intermediates \ incremental \ mergeDebugResources \ merged.dir \ values \ values.xml:1440: 错误:样式属性'attr/colorSecondary(aka it.duemilanet.icircle:attr/colorSecondary)找不到. 错误:资源样式/Widget.Design.BottomSheet.Modal(又名it.duemilanet.icircle:style/Widget.Design.BottomSheet.Modal)不 成立. 错误:资源样式/Theme.Design.Light.BottomSheetDialog(又名it.duemilanet.icircle:style/Theme.Design.Light.BottomSheetDialog)不 成立. D:\ GitLab \ iCircleAndroidRMA \ app \ build \ intermediates \ incremental \ mergeDebugResources \ merged.dir \ values \ values.xml:3296: 错误:样式属性'attr/bottomSheetStyle(aka it.duemilanet.icircle:attr/bottomSheetStyle)找不到. 错误:链接引用失败.

D:\GitLab\iCircleAndroidRMA\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1440: error: style attribute 'attr/colorSecondary (aka it.duemilanet.icircle:attr/colorSecondary)' not found. error: resource style/Widget.Design.BottomSheet.Modal (aka it.duemilanet.icircle:style/Widget.Design.BottomSheet.Modal) not found. error: resource style/Theme.Design.Light.BottomSheetDialog (aka it.duemilanet.icircle:style/Theme.Design.Light.BottomSheetDialog) not found. D:\GitLab\iCircleAndroidRMA\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3296: error: style attribute 'attr/bottomSheetStyle (aka it.duemilanet.icircle:attr/bottomSheetStyle)' not found. error: failed linking references.

之前编译很好,几周前我切换到了androidX和材料组件主题,并启用了jetifier

It was compiling just fine before, i switched to androidX and material components theme weeks ago and enabled jetifier without problems

build.gradle:

buildscript {

    repositories {

        google()
        jcenter()

        maven {
            url 'https://maven.fabric.io/public'
        }

    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha09'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
        classpath 'com.google.gms:google-services:4.0.2'
        classpath 'io.fabric.tools:gradle:1.25.4'
    }

}

allprojects {

    repositories {

        google()
        jcenter()

        maven {
            url 'https://maven.google.com/'
        }

    }

}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用程序构建.gradle:

apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "it.duemilanet.icircle"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 3334
        versionName "3.3.3.4"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled true
    }
}

greendao {
    schemaVersion 1
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.6.0'
    implementation 'io.sentry:sentry-android:1.7.5'
    implementation 'org.simpleframework:simple-xml:2.7.1'
    implementation 'org.greenrobot:greendao:3.2.2'
    implementation 'com.synnapps:carouselview:0.1.5'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.bskim:maxheightscrollview:1.0.0@aar'
    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
    implementation 'com.pspdfkit:pspdfkit:4.8.1'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'org.apache.commons:commons-compress:1.18'
    implementation 'androidx.databinding:databinding-runtime:3.3.0-alpha12'
    implementation 'com.jakewharton:butterknife:9.0.0-rc1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }
    maven {
        url 'https://customers.pspdfkit.com/maven/'
        credentials {
            username 'pspdfkit'
            password 'PASSWORD'
        }
    }
}

apply plugin: 'com.google.gms.google-services'

  • 我试图禁用Instant Run并恢复到材料库的先前版本,但是我无法修复该错误.
    • I tried to disable Instant Run and to revert to previous versions of the material library but i couldn't fix the error.
    • 推荐答案

      材料设计文档中引用了多个组件,但尚未在Android的材料设计库的稳定版本中引用这些组件.尝试改用Alpha版本.

      There are several components which are referenced in the material design documentation which aren't yet in a stable release of the material design library for Android. Try using the alpha version instead.

      将以下内容添加到您的build.gradle:

      Add the following to your build.gradle:

      dependencies { 
          ...
          implementation 'com.google.android.material:material:1.2.0-alpha02'
      }
      

      这篇关于使用Material Components和androidX编译Android应用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆