代码之家  ›  专栏  ›  技术社区  ›  lacas

Android realm无法构建javax/annotation/CheckForNull。班

  •  0
  • lacas  · 技术社区  · 7 年前
    classpath "io.realm:realm-gradle-plugin:4.2.0"
    

    然后

    apply plugin: 'realm-android'
    

    然后构建

    错误:任务执行失败 “:app:transformDexArchiveWithDexMergerForDebug”。

    通用域名格式。安卓建筑应用程序编程接口。使改变TransformException:com。安卓工具。r8.错误。编译错误:程序类型已存在 演示:javax。注释。检查返回值

    更多信息:

    Caused by: java.io.IOException: Duplicate zip entry [32.jar:javax/annotation/CheckForNull.class]
        at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
        at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
        at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
        at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
    

    我的Gradle

    dataBinding.enabled = true
    
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    
    implementation "com.android.databinding:compiler:3.1.0-alpha04"
    annotationProcessor 'com.android.databinding:compiler:3.1.0-alpha04'
    
    implementation 'com.android.support:exifinterface:27.0.2'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    implementation 'com.android.support:cardview-v7:27.0.2'
    implementation 'com.android.support:design:27.0.2'
    
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:multidex:1.0.2'
    
    implementation 'io.reactivex.rxjava2:rxjava:2.0.0-RC2'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.0-RC1'
    
    implementation 'com.squareup.retrofit2:retrofit:2.1.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.0.0'
    implementation 'com.squareup.retrofit2:converter-jackson:2.0.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.3.1'
    
    implementation 'org.greenrobot:eventbus:3.0.0'
    implementation 'com.github.bumptech.glide:glide:4.3.1'
    
    implementation 'com.google.firebase:firebase-core:11.6.2'
    implementation 'com.google.firebase:firebase-messaging:11.6.2'
    implementation 'com.google.firebase:firebase-crash:11.6.2'
    
    implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
    implementation 'com.wrapp.floatlabelededittext:library:0.0.6'
    implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3'
    

    一些信息: 在我想将领域库导入到我的项目之前,一切都很顺利

    2 回复  |  直到 7 年前
        1
  •  2
  •   EpicPandaForce Jigar Joshi    7 年前

    你有同样的依赖 com.android.databinding:compiler:3.1.0-alpha04 两者都有 implementation annotationProcessor

    使用较新的android gradle插件版本,您只需添加

    dataBinding {
        enabled = true
    }
    

    在您的android配置中,无需添加任何依赖项 in the official guide


    尝试删除 implementation "com.android.databinding:compiler:3.1.0-alpha04" annotationProcessor 'com.android.databinding:compiler:3.1.0-alpha04' 然后离开 android.dataBinding = true ,然后清理并重建项目。

        2
  •  1
  •   EpicPandaForce Jigar Joshi    7 年前

    您可以尝试向构建中添加以下代码行。格拉德尔:

    configurations.all {
        resolutionStrategy.force "com.google.code.findbugs:jsr305:3.0.2"
    }
    

    如果仍然不起作用,您还可以添加以下内容

    implementation 'com.google.code.findbugs:jsr305:3.0.2'