程序类型已经存在:android.support.constraint.BuildConfig [英] Program type already present: android.support.constraint.BuildConfig

查看:154
本文介绍了程序类型已经存在:android.support.constraint.BuildConfig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

build.gradle(模块:应用)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-P'
    buildToolsVersion '27.0.3'
    defaultConfig {
        multiDexEnabled true
        applicationId "tk.megh.myapplication"
        minSdkVersion 'P'
        targetSdkVersion 'P'
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        preDexLibraries = false
    }
}



dependencies {
    implementation 'com.android.support:multidex:1.0.1'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:+'
    testImplementation 'junit:junit:4.12'

}

好吧,我想我知道是什么原因引起的错误,如果您查看依赖关系,则有两个名称不同的冗余包

Well i think i know what's causing the error, if you look at the dependencies there are two redundant packages with different names

com.android.support.constraint:constraint-layout:1.1.0 androidx.constraintlayout:constraintlayout:1.1.0

com.android.support.constraint:constraint-layout:1.1.0 androidx.constraintlayout:constraintlayout:1.1.0

但是我无法删除它们中的任何一个,因为它们被某些软件包使用.我是android开发的新手,所以我对任何解决方法都不了解.

But i can't remove either of them because they are used by some packages. I'm a novice in android development, so i don't have much idea about any workarounds.

如果我删除

implementation 'com.android.support.constraint:constraint-layout:1.1.0'

我在调试时收到此错误:

i get this error while debugging:

    java.lang.RuntimeException: Unable to start activity 
ComponentInfo{tk.megh.myapplication/tk.megh.myapplication.MainActivity}: 
android.view.InflateException: Binary XML file line #2: Binary XML file 
line #2: Error inflating class android.support.constraint.ConstraintLayout

如果我删除

implementation 'androidx.constraintlayout:constraintlayout:1.1.0'

调试时出现以下错误:

 java.lang.RuntimeException: Unable to start activity 
ComponentInfo{tk.megh.myapplication/tk.megh.myapplication.DisplayMessageActivity}: 
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: 
Error inflating class androidx.constraintlayout.widget.ConstraintLayout

其他详细信息:

MainActivity.java 的导入:

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;

DisplayMessageActivity.java 的导入:

imports of DisplayMessageActivity.java:

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;   

谢谢.

推荐答案

错误表明您在布局xml文件中使用了ConstraintLayout.

The errors indicate that you're using the ConstraintLayout in your layout xml files.

仅保留该库的一个版本,并确保您在xml中使用该版本的ConstraintLayout.

Keep only one version of the library and make sure, that you are using that version's ConstraintLayout in your xmls.

因此,如果保留androidx,请检查布局文件,并确保在那里使用了androidx.constraintlayout.ConstraintLayout,而不是不是 android.support.constraint.ConstraintLayout.

So, if you keep androidx, check your layout files and make sure, you are using androidx.constraintlayout.ConstraintLayout there, and not android.support.constraint.ConstraintLayout.

这篇关于程序类型已经存在:android.support.constraint.BuildConfig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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