【问题标题】:Android studio show this error during run. Error: Program type already present: androidx.concurrent.futures.DirectExecutorAndroid Studio 在运行期间显示此错误。错误:程序类型已经存在:androidx.concurrent.futures.DirectExecutor
【发布时间】:2018-12-13 16:59:34
【问题描述】:

我试图通过/使用 android studio 3.1.4 版运行我的 android 应用程序,但我不知道在运行我的程序时会发生什么,它一直显示此错误

Error: Program type already present: androidx.concurrent.futures.DirectExecutor

我尝试快速搜索其答案,但仍未找到与我的问题相关的答案。

根据我发现的与类名冲突相关的问题?如果我错了,请纠正我。

下面是我的 build.gradle

            apply plugin: 'com.android.application'
            apply plugin: 'com.google.protobuf'

            android {
            compileSdkVersion 28
            defaultConfig {
                applicationId "com.ikan.elogbook"
                minSdkVersion 24
                targetSdkVersion 28
                versionCode 1
                versionName "1.0"

            testInstrumentationRunner"androidx.test.runner.AndroidJUnitRunner"


            }


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

            lintOptions {

            disable'GoogleAppIndexingWarning','HardcodedText','InvalidPackage'
                textReport true
                textOutput "stdout"
            }

            allprojects {
                repositories {
                    maven { url 'https://jitpack.io' }

                    //this line added to resolve issue some grpc package / 
            library are not found
                    //reference bug url https://github.com/grpc/grpc- 
            java/issues/4460
                    mavenCentral()
                }
            }
}

    ext {
        supportLibraryVersion = "25.3.1"
    }


        protobuf {
            protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
            plugins {
            javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
            grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.17.1' // CURRENT_GRPC_VERSION
            }
        }
        generateProtoTasks {
            all().each { task ->
                task.plugins {
                    javalite {}
                    grpc { // Options added to --grpc_out
                        option 'lite' }
                }
            }
        }
}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
    implementation 'com.github.jkwiecien:EasyImage:1.3.1'
    implementation 'com.mikepenz:materialdrawer:6.1.1'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.annotation:annotation:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'de.codecrafters.tableview:tableview:2.8.0'
    implementation 'com.pixplicity.easyprefs:library:1.9.0'
    // You need to build grpc-java to obtain these libraries below.
    implementation 'io.grpc:grpc-okhttp:1.17.1'
    // CURRENT_GRPC_VERSION
    implementation 'io.grpc:grpc-protobuf-lite:1.17.1'
    // CURRENT_GRPC_VERSION
    implementation 'io.grpc:grpc-stub:1.17.1'
    // CURRENT_GRPC_VERSION
    implementation 'javax.annotation:javax.annotation-api:1.2'
    protobuf 'com.google.protobuf:protobuf-java:3.5.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1-alpha01'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1-alpha01'
}

【问题讨论】:

  • 请添加build.gradle;否则这个问题无法回答。
  • @MartinZeitler 我通过输入build.gradle 编辑了我的帖子。谢谢

标签: java android android-studio-3.0 grpc-java


【解决方案1】:

当 build.gradle 文件中存在不同类型的依赖时 喜欢

implementation 'com.android.support:appcompat-v7:27.1.0'

implementation 'com.android.support:design:28.0.0'

或版本冲突。

为避免这种情况,您需要维护依赖项的版本 像这样

  implementation 'com.android.support:appcompat-v7:27.1.0'
  implementation 'com.android.support:design:28.0.0'

您也可以参考此链接了解为什么会出现此错误

What is "Program type already present"?

【讨论】:

  • 我的错是我没有详细说明我在做什么。我已经通过输入build.gradle 编辑了我的帖子,并感谢上述解释。
猜你喜欢
  • 2018-06-29
  • 2019-04-22
  • 1970-01-01
  • 1970-01-01
  • 2021-11-26
  • 2019-04-05
  • 1970-01-01
  • 1970-01-01
  • 2019-05-26
相关资源
最近更新 更多