java - Android studio-transformClassesWithDexForDebug 错误

标签 java android android-studio gradle

这是我的梯度:

  apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.xxx.yyy"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/INDEX.LIST'
    }
    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }
}
repositories {
    maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:multidex:1.0.0'
    //Support Library
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    //Test
    androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
    testCompile 'junit:junit:4.12'
    //Google Play Services
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
    //Common Langs 3
    compile 'org.apache.commons:commons-lang3:3.5'
    //Google Cloud Translate
    compile ('com.google.cloud:google-cloud-translate:0.7.0'){
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
        exclude group: 'org.json', module: 'json'
    }
    //Ksoap 2
    compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2'
    //Gson (Shared Preferences)
    compile 'com.google.code.gson:gson:2.7'
    //Loading Animation
    compile 'com.pnikosis:materialish-progress:1.7'
    //Snackbar
    compile 'com.androidadvance:topsnackbar:1.1.1'
    //SVG Animation
    compile 'com.jaredrummler:animated-svg-view:1.0.0'
}

这是 Androidmanifest.xml 部分

<application
        android:name="android.support.multidex.MultiDexApplication"
        android:allowBackup="true"
        android:configChanges="orientation"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".SplashAnimationActivity"

这是 android studio 错误:

   Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug]
Warning:The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.
Error:trouble processing "javax/transaction/HeuristicCommitException.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
Information:Total time: 46.622 secs
Information:34 errors
Information:1 warning
Information:See complete output in console

我正在开发谷歌云翻译应用程序。 我收到错误。

我搜索并尝试了一些解决方案,但对我没有帮助。

问题是什么?

我的 libs 文件夹是空的。

请帮助我。

最佳答案

我也遇到了同样的问题。在我的应用程序中,我使用 guava-retrying 库,该库正在获取 google guava 库版本 21。 Guava 版本 21 需要 JDK 1.8,而不提供向后移植支持,这在我的情况下导致了此错误。

我能够通过包含 guava-retrying 库来解决这个问题,以便它使用 19.0 版本的 guava 库:

compile ("com.github.rholder:guava-retrying:2.0.0") {
    exclude group: 'com.google.guava', module: 'guava'
}
compile 'com.google.guava:guava:19.0'

基本上,您需要检查应用程序的任何依赖项是否需要 JDK 1.8 进行编译,然后删除/降级它们。

关于java - Android studio-transformClassesWithDexForDebug 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40883712/

相关文章:

java - Android Studio - 单击按钮后当前 Activity 重新打开

java - 解析简单的 Json 响应

java - 如何将 Stack 中的 View 添加到 LinearLayout 中?

android - 在 Android Studio 1.4.1 中重置网络监视器统计信息

android - 成员变量前缀 ("m") 在 Android studio 1.1 中的 getters 和 setters

java - 将 HashMap 作为 FitNesse 中的参数传递

java - 什么是 NullPointerException,我该如何解决?

java - Eclipse 中的镜像 API

java - neo4j中限制遍历到特定深度

Android向fragment中的listview添加标题