Program type already present: android.support.v4.a

2019-01-16 12:20发布

I have upgraded my android studio .. and I found many problems in the latest version

Although many similar questions exist, I checked the answers to all and none of them worked for me!

Here is the error I'm facing while compiling the code:

Program type already present: android.support.v4.app.BackStackRecord$Op Message{kind=ERROR, text=Program type already present: android.support.v4.app.BackStackRecord$Op, sources=[Unknown source file], tool name=Optional.of(D8)}

Here is my gradle file

project:

// Top-level build file where you can add configuration options common to 

all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
 }

 allprojects {
 repositories {
    google()
    jcenter()
    maven {
        url "https://jitpack.io"
          }
     }
}

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

app:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.alcantara.bugismart"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
            }
           }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.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'
    implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
}

You can tell me if there is anything else to add to understand what I'm doing or where I'm wrong.

9条回答
The star\"
2楼-- · 2019-01-16 13:09

multiDexEnabled true add the line above in android block in gradle-app its work for me ...

查看更多
来,给爷笑一个
3楼-- · 2019-01-16 13:11

In your dependencies section in gradle

Add this Code

implementation 'com.android.support:support-v4:28.0.0'

查看更多
Ridiculous、
4楼-- · 2019-01-16 13:12

Add this code to gradle (According to "SdkVersion")

 implementation 'com.android.support:support-v4:28.0.0-beta01'

for example my SDKVersion is 28 then I use this code :

implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support:support-v4:28.0.0-beta01'
查看更多
登录 后发表回答