【问题标题】:How can i import javax.json.binding in android studio?如何在 android studio 中导入 javax.json.binding?
【发布时间】:2018-10-06 18:44:26
【问题描述】:

我在 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 带参数 {--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/中间体/transforms/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 /用户/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'

}

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

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

      解决方案 2:

      错误:任务执行失败 ':app: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

      【讨论】:

      • 只需清除并重建一次...我认为compile 'javax.json.bind:javax.json.bind-api:1.0.0-M2' 不需要此行...,意味着 lib 本身它将自行处理...
      • 我删除了 compile 'javax.json.bind:javax.json.bind-api:1.0.0-M2' 并再次清除并重建项目,它抛出相同的......
      • 确保 removecompile 'javax.json.bind:javax.json.bind-api:1.0.0- 之后重启你的 Android Studio...就像 文件->无效/缓存...您的项目可能没有正确同步...完成后告诉我
      • 错误:任务 ':app:transformClassesWithDesugarForDebug' 执行失败。从消息 gradle 构建工具栏获取运行时
      • 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" } compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 } }
      猜你喜欢
      • 2015-04-17
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      • 2013-12-09
      • 2023-04-02
      相关资源
      最近更新 更多