Android Material Design库错误-程序类型已存在:android.support.v4.app.INotificationSideChannel $ Stub

时间:2018-06-19 23:53:50

标签: android android-studio material-design

当尝试使用新的Material Design库运行我的应用程序时遇到此问题,请提供解决方案的人?

日志:

  

执行任务:[:app:assembleProdDebug]

     

:app:preBuild UP-TO-DATE:app:preProdDebugBuild UP-TO-DATE   :app:compileProdDebugAidl更新日期:app:compileProdDebugRenderscript   UP-TO-DATE:app:checkProdDebugManifest UP-TO-DATE   :app:generateProdDebugBuildConfig截止日期:app:prepareLintJar   UP-TO-DATE:app:mainApkListPersistenceProdDebug UP-TO-DATE   :app:generateProdDebugResValues截止日期   :app:generateProdDebugResources最新   :app:mergeProdDebugResources最新   :app:createProdDebugCompatibleScreenManifests截止日期   :app:processProdDebugManifest截止日期   :app:splitsDiscoveryTaskProdDebug截止日期   :app:processProdDebugResources:app:generateProdDebugSources   :app:javaPreCompileProdDebug注意:某些输入文件使用未经检查的或   不安全的操作。注意:使用-Xlint:unchecked重新编译以获取详细信息。   :app:compileProdDebugJavaWithJavac:app:compileProdDebugNdk NO-SOURCE   :app:compileProdDebugSources:app:mergeProdDebugShaders截止日期   :app:compileProdDebugShaders更新日期:app:generateProdDebugAssets   UP-TO-DATE:app:mergeProdDebugAssets UP-TO-DATE   :app:transformClassesWithDexBuilderForProdDebug AGPBI:   {“种类”:“错误”,“文本”:“程序类型已存在:   android.support.v4.app.INotificationSideChannel $ Stub“,”源“:[{}],”工具“:” D8“}   :app:transformDexArchiveWithExternalLibsDexMergerForProdDebug失败

     

失败:构建失败,并出现异常。

我正在使用Android Studio 3.1.3

最重要的事情:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'

        // 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
}

// Define versions in a single place
ext {
    // Sdk and tools
    minSdkVersion = 15
    targetSdkVersion = 27
    compileSdkVersion = 'android-P'
    buildToolsVersion = '28.0.0-rc2'

    // App dependencies
    supportLibraryVersion = '28.0.0-alpha1'
    constraintLayout = '1.1.0'
    volley = '1.0.0'
    gson = '2.7'
    butterKnife = '8.8.1'
    analytics = '16.0.0'
    guavaVersion = '18.0'
    picassoVersion = '2.5.2'
    junitVersion = '4.12'
    mockitoVersion = '1.10.19'
    powerMockito = '1.6.2'
    hamcrestVersion = '1.3'
    runnerVersion = '1.1.0-alpha1'
    rulesVersion = '1.1.0-alpha1'
    espressoVersion = '3.1.0-alpha3'
}

App Gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.test.bnl"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        debug {
            // Run code coverage reports by default on debug builds.
            // testCoverageEnabled = true
            applicationIdSuffix ".debug"
            debuggable true
        }

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

    // Specifies flavor dimensions.
    flavorDimensions "default"

    // If you need to add more flavors, consider using flavor dimensions.
    productFlavors {
        mock {
            applicationIdSuffix ".mock"
            versionNameSuffix "-mock"
        }

        prod {
            applicationIdSuffix ".prod"
            versionNameSuffix "-prod"
        }
    }

    // Remove mockRelease as it's not needed.
    android.variantFilter { variant ->
        if (variant.buildType.name == 'release' && variant.getFlavors().get(0).name == 'mock') {
            variant.setIgnore(true)
        }
    }

    // Always show the result of every unit test, even if it passes.
    testOptions.unitTests.all {
        testLogging {
            events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
        }
    }

}

/*
 Dependency versions are defined in the top level build.gradle file. This helps keeping track of
 all versions in a single place. This improves readability and helps managing project complexity.
 */
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // App's dependencies, including test
    implementation 'com.google.android.material:material:1.0.0-alpha3'

    implementation "com.google.guava:guava:$rootProject.guavaVersion"
    implementation "com.squareup.picasso:picasso:$rootProject.picassoVersion"
    implementation "androidx.test.espresso:espresso-idling-resource:$rootProject.ext.espressoVersion"

    implementation "com.android.volley:volley:$rootProject.ext.volley"
    implementation "com.google.code.gson:gson:$rootProject.ext.gson"
    implementation "com.google.android.gms:play-services-analytics:$rootProject.ext.analytics"

    // Dependencies for local unit tests
    testImplementation "junit:junit:$rootProject.ext.junitVersion"
    testImplementation "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
    testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
    testImplementation "org.powermock:powermock-module-junit4:$rootProject.ext.powerMockito"
    testImplementation "org.powermock:powermock-api-mockito:$rootProject.ext.powerMockito"

    // Android Testing Library's runner and rules
    androidTestImplementation "androidx.test:runner:$rootProject.ext.runnerVersion"
    androidTestImplementation "androidx.test:rules:$rootProject.ext.rulesVersion"

    // Espresso UI Testing dependencies.
    androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-intents:$rootProject.ext.espressoVersion"
    implementation 'junit:junit:4.12'
}

Gradle.properties:

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useAndroidX=true
android.enableJetifier=false

如果需要更多信息,请告诉我!

2 个答案:

答案 0 :(得分:0)

Android Studio 3.2+解决了此问题。还会在“重构”菜单下添加“迁移到AndroidX”项。

答案 1 :(得分:0)

迁移到androidx或升级您的build.gradle版本