如何在android studio中导入javax.json.binding?

时间:2018-04-26 06:59:12

标签: java android java-8 android-studio-3.0 jsonb-api

我在build.gradle文件中添加了以下依赖项

compile' javax.json.bind:javax.json.bind-api:1.0.0-M2'它会抛出错误,如

错误:任务':app:transformClassesWithDesugarForDebug'执行失败。

  

com.android.build.api.transform.TransformException:java.lang.RuntimeException:java.lang.RuntimeException:com.android.ide.common.process.ProcessException:使用com.google主类执行java进程时出错.devtools.build.android.desugar.Desugar with arguments {--input /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/11.jar --output / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / desugar / debug / 10.jar --input/Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/6.jar --output / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / desugar / debug / 5.jar --input/Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/19.jar - 输出/Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/desugar/debug/18.jar --input / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transf orms / stackFramesFixer / debug / 18.jar --output /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/desugar/debug/17.jar --input / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer / debug / 26.jar --output /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/desugar/debug/21.jar --input / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer / debug / 4.jar --output /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/desugar/debug/3.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / classes / debug --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/0.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer / debug / 3.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / st ackFramesFixer / debug / 4.jar --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/5.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build /中间体/变换/ stackFramesFixer / debug / 6.jar --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/7.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer / debug / 8.jar --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/9.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer / debug / 10.jar --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/11.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer / debug / 12.jar - classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/13.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer / debug / 14 .jar --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/15.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer /debug/16.jar --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/17.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app / build / intermediates /transforms/stackFramesFixer/debug/18.jar --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/19.jar --classpath_entry / Users / panmoh / Documents / AndroidMockUps / app /build/intermediates/transforms/stackFramesFixer/debug/20.jar --classpath_entry / Users / p anmoh / Documents / AndroidMockUps / app / build / intermediates / transforms / stackFramesFixer / debug / 21.jar --classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/26.jar - classpath_entry /Users/panmoh/Documents/AndroidMockUps/app/build/intermediates/transforms/stackFramesFixer/debug/27.jar --bootclasspath_entry /Users/panmoh/Library/Android/sdk/platforms/android-26/android.jar - bootclasspath_entry /Users/panmoh/Library/Android/sdk/platforms/android-26/optional/org.apache.http.legacy.jar --bootclasspath_entry / Applications / Android Studio.app/Contents/jre/jdk/Contents/Home/ jre / lib / resources.jar --bootclasspath_entry / Applications / Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/rt.jar --bootclasspath_entry / Applications / Android Studio.app/Contents/jre/ jdk / Contents / Home / jre / lib / jsse.jar --bootclasspath_entry / Applications / Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/jce.jar--bootclasspath_entry / Applications / Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/charsets.jar --min_sdk_version 15 --desugar_try_with_resources_if_needed --desugar_try_with_resources_omit_runtime_classes}

这是我的build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.canwin.androidmockups"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.uncopt:android.justified:1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'

}

2 个答案:

答案 0 :(得分:1)

我在build.gradle文件中使用了以下内容:

实现组:“ javax.json.bind”,名称:“ javax.json.bind-api”,版本:“ 1.0”

答案 1 :(得分:0)

转到此链接并下载 jar文件,然后在 app-> libs 文件夹中添加您的项目文件夹。然后 syn 您项目

https://mvnrepository.com/artifact/javax.json.bind/javax.json.bind-api/1.0.0-M2

解决方案2:

  

错误:任务执行失败   ':应用程序:transformClassesWithDesugarForDebug'。

     

com.android.build.api.transform.TransformException:   了java.lang.RuntimeException:   com.android.ide.common.process.ProcessException:执行时出错   主进程的java进程   带参数的com.google.devtools.build.android.desugar.Desugar

打开 build.gradle 并使用下面的

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

然后 Clean-Rebuild-Run