【问题标题】:Why Android studio is giving error after implementing 'constraintlayout:2.0.0-beta1'为什么Android Studio在实施'constraintlayout:2.0.0-beta1'后会出错
【发布时间】:2019-05-17 10:20:30
【问题描述】:

我正在尝试使用 Android Motion 布局并为此实现 androidx.constraintlayout:constraintlayout:2.0.0-beta1

但是在构建期间我遇到了这个错误。

我已经尝试降级到约束布局的 alph4 版本

Android 资源编译失败 E:\Users\avinash91625\StudioProjects\StanBuzzAndroid\app\build\intermediates\incremental\mergeFreemiumDebugResources\merged.dir\values\values.xml:5753:错误:资源 'attr/circleRadius' 的重复值与配置 ''。 E:\Users\avinash91625\StudioProjects\StanBuzzAndroid\app\build\intermediates\incremental\mergeFreemiumDebugResources\merged.dir\values\values.xml:5753: 错误:资源先前定义在这里。 E:\Users\avinash91625\StudioProjects\StanBuzzAndroid\app\build\intermediates\incremental\mergeFreemiumDebugResources\merged.dir\values\values.xml:错误:文件编译失败。

我的应用程序 gradle 文件 -

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId 'com.stanbuzz.android'
        minSdkVersion 21
        targetSdkVersion 28
        versionName '1.17'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        versionCode 17
        renderscriptTargetApi 25
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    freemium {
        dimension = 'release'
        minSdkVersion 21
        versionCode = 21
    }
    }
    flavorDimensions 'release'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.mikhaellopez:circularimageview:3.2.0'
    implementation 'info.hoang8f:android-segmented:1.0.6'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.github.ybq:Android-SpinKit:1.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.firebase:firebase-firestore:19.0.0'
    implementation 'com.google.firebase:firebase-inappmessaging-display:17.1.1'
    implementation 'com.google.firebase:firebase-storage:17.0.0'
    implementation 'com.google.firebase:firebase-perf:17.0.0'
    implementation 'com.firebaseui:firebase-ui-firestore:4.3.0'
    implementation 'com.firebaseui:firebase-ui-storage:4.3.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.scottyab:aescrypt:0.0.1'
    implementation 'com.budiyev.android:code-scanner:2.0.1'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.msg91.sendotp.library:library:3.1'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
    implementation 'com.google.firebase:firebase-dynamic-links:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.google.firebase:firebase-functions:17.0.0'
    implementation 'com.github.siyamed:android-shape-imageview:0.9.3@aar'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.yarolegovich:discrete-scrollview:1.4.9'
    implementation 'com.algolia:algoliasearch-android:3.26.1'
    implementation 'com.google.android.gms:play-services-gcm:16.1.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.squareup.okhttp:okhttp:2.7.5'
    implementation 'io.smooch:core:5.16.2'
    implementation 'io.smooch:ui:5.16.2'
    implementation 'com.github.javiersantos:MaterialStyledDialogs:2.1'
    implementation 'com.razorpay:checkout:1.5.2'
    implementation 'com.github.takusemba:spotlight:1.8.0'
    implementation 'com.github.sujithkanna:smileyrating:1.6.8'
    implementation 'com.orhanobut:dialogplus:1.11@aar'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.ncorti:slidetoact:0.6.0'
    implementation 'com.github.canner:android-stepsview:1.2'
    implementation 'pl.bclogic:pulsator4droid:1.0.3'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
     // Temporary fix begin
    implementation 'com.android.support:support-annotations:27.1.1'
    annotationProcessor 'com.android.support:support-annotations:27.1.1'
    androidTestImplementation 'androidx.test:rules:1.1.2-alpha01'
    // Temporary fix end
}
apply plugin: 'com.google.gms.google-services'

E:\Users\avinash91625\StudioProjects\StanBuzzAndroid\app\build\intermediates\incremental\mergeFreemiumDebugResources\merged.dir\values\values.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="orange">#fffaaa00</color>
    <color name="primary">#03A9F4</color>
    <color name="white">#fff</color>
    <color name="yellow">#ffff981e</color>
    <declare-styleable name="StepsView"><attr format="integer" name="numOfSteps"/><attr format="integer" name="completePosition"/><attr format="reference" name="labels"/><attr format="reference" name="barColor"/><attr format="reference" name="progressColor"/><attr format="reference" name="labelColor"/><attr format="reference" name="progressTextColor"/><attr format="boolean" name="hideProgressText"/><attr format="float" name="labelSize"/><attr format="float" name="progressMargin"/><attr format="float" name="circleRadius"/><attr format="float" name="progressStrokeWidth"/></declare-styleable>
    <string name="app_name">StepsView</string>
</resources>

我认为这个库导致了这个问题 - new AndroidX support

【问题讨论】:

  • 删除您的构建文件夹,使缓存无效并重新启动。
  • 嗨@sanjeev,我刚刚这样做了,但是没有用。

标签: java android


【解决方案1】:

@Avinash,您是否清理并构建/使缓存无效的项目?如果是这样,此资源编译错误意味着有两个资源共享相同的属性。简单来说,你应该删除android.support.constraint.ConstraintLayout 在导入 androidx.constraintlayout:constraintlayout:2.0.0-beta1 之前。希望这会有所帮助

【讨论】:

  • 是的,我尝试清理并构建项目,但没有任何结果,我也没有在我的应用程序 gradle 文件中看到另一个重复的实现,我已将其包含在编辑中。
  • @AvinashKumar,你能分享这个文件吗,E:\Users\avinash91625\StudioProjects\StanBuzzAndroid\app\build\intermediates\incremental\mergeFreemiumDebugResources\merged.dir\values\values.xml:5753。问题可能与此文件有关。检查资源 attr/circleRadius,你在 values.xml 中声明过两次吗?
  • 是的,我已经在编辑中添加了。但我没有在我的项目中的任何地方使用 attr/circleRadius,它似乎是非项目文件,并且在我尝试编辑时给出相同的警告。
【解决方案2】:

您正在使用 androidx 库以及支持库

支持库

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-annotations:27.1.1'
annotationProcessor 'com.android.support:support-annotations:27.1.1'

移除不需要的支持库并替换为对应的androidx库。

有关工件映射,请参阅this

【讨论】:

  • 我尝试用相应的 androidx 替换它们但没有用,我认为这更多地与那个冲突的 StepView 库有关
  • @AvinashKumar 你在gradle.properties 文件中启用了android.useAndroidX=trueandroid.enableJetifier=true 吗?
猜你喜欢
  • 2017-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-14
相关资源
最近更新 更多