Gradle汇编AAR库中的重复类定义

时间:2019-06-26 18:07:01

标签: android android-studio gradle build android-gradle

我正在以完美的调试模式在Android Studio中编译我的AAR库,但是当使用ProGuard发行时,会出现错误:

我的build.gradle

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

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28


    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    externalNativeBuild {
        cmake {
            version '3.10.2'
            path "src/main/cpp/CMakeLists.txt"
        }
    }

    repositories{
        flatDir{
            dirs 'libs'
        }
        /** Following lines are for accessing the TapLinx jars from Repo directly */
        maven {
            credentials {
                username "sdkuser"
                password "taplinx"
            }
            url "http://maven.taplinx.nxp.com/nexus/content/repositories/taplinx/"
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.13-beta-3'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.4.0-b180830.0359'
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
    implementation 'com.google.android.gms:play-services-analytics:15.0.2'
    implementation 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation('taplinx-android:nxpnfcandroidlib:1.6@aar') {
        transitive = true
        changing = true
    }


}

我的错误日志是: ...

Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/android.jar]
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/optional/org.apache.http.legacy.jar]
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/optional/android.test.mock.jar]
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/optional/android.test.base.jar]
Reading library jar [/Users/andresflorespolicarpo/Library/Android/sdk/platforms/android-28/optional/android.test.runner.jar]
Note: there were 1 duplicate class definitions.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: there were 1 classes in incorrectly named files.
         You should make sure all file names correspond to their class names.
         The directory hierarchies must correspond to the package hierarchies.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)
         If you don't mind the mentioned classes not being written out,
         you could try your luck using the '-ignorewarnings' option.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':taplinx:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3s
40 actionable tasks: 32 executed, 8 up-to-date
12:56:13: Task execution finished 'assemble'.

1 个答案:

答案 0 :(得分:0)

这是Taplinx版本1.7中的错误