java - 程序类型已存在 : android. support.v4.R

标签 java android android-gradle-plugin

我正在尝试生成签名的 apk,但收到错误:

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

我尝试从某些依赖项中排除 support-v4 。但这没有帮助。我已经寻找过答案,但没有一个能解决我的问题。 但应用程序在 Debug模式下运行良好。

非常感谢您在此事上花费的时间和提供的帮助。

这是我的 gradle 应用程序文件:

apply plugin: 'com.android.application'

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


    }


    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        //noinspection GradleCompatible
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.0'
        implementation 'com.facebook.fresco:fresco:1.9.0'
        implementation 'com.facebook.android:facebook-android-sdk:4.33.0'
        implementation 'com.squareup.picasso:picasso:2.71828'
        implementation 'com.google.android.gms:play-services-auth:15.0.1'
        implementation 'ai.api:sdk:2.0.7'
        implementation 'ai.api:libai:1.6.12'
        implementation 'com.android.support:cardview-v7:27.1.1'
        implementation 'com.android.support:design:27.1.1'
        implementation 'com.dnkilic.waveform:waveform:0.9.3'
    }
    apply plugin: 'com.google.gms.google-services'

gradle项目文件

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.3.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

最佳答案

您需要从此 dependency 中排除对 appcompat-v7 的支持:

implementation 'com.dnkilic.waveform:waveform:0.9.3'

这样:

implementation ('com.dnkilic.waveform:waveform:0.9.3') {
     exclude group: 'com.android.support'
     exclude module: 'appcompat-v7'
}

关于java - 程序类型已存在 : android. support.v4.R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50549530/

相关文章:

android - 使用 Completable.timer 对 RxJava 进行单元测试

android - 使用不同的来源测试和发布 Android Studio

android - buildConfigField、resValue 和 manifestPlaceholders 之间有什么区别?

java - PaintComponent() 函数调用

java - Glide 不从云存储加载图像

android - phonegap build android 什么都不做

android - 如何使用Gradle将其他参数传递给transformClassesWithDexForDebug?

java - WebView 向下滚动时自动向上滚动

java - 如何逐行扫描输入整数?

java - 简单的旋转项目不可点击