【问题标题】:Exception, Error converting bytecode to dex, Exception parsing classes, Return code 1 for dex process异常、字节码转dex时出错、解析类异常、dex进程返回码1
【发布时间】:2017-09-15 06:43:53
【问题描述】:

注意这个问题不匹配,因为我找不到任何可行的解决方案。

我已经使用了几乎所有过程来解决这个问题,但仍然面临同样的问题。

第一multiDexEnabled true

第二compile 'com.android.support:multidex:1.0.1'

第三org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m(在Local.properties

第四android:name="android.support.multidex.MultiDexApplication"(在manifest.xml)

第五Clean & Rebuild

第六File Invalidate cache & Restart

如果有人正在寻找解决方案,这些可能对您有用。但对我来说,没有一个工作。

我该怎么办? (我正在做数字钱包项目)。

错误:1:

Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes

错误 2:Error:1 error; aborting

错误3:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.example.intuition.paytmprogress"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
//        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'

//    PayTm
    compile files('libs/PGSDK_V2.0.jar')
    compile files('libs/paytm-checksum_2.0.jar')
    compile files('libs/jackson-databind-2.9.1.jar')

    //Freecharge
//    compile 'com.android.support:support-v4:+'
//    compile 'in.freecharge.checkout.android:freecharge-checkout-android-sdk:2.2@aar'
//    compile 'in.juspay:godel:0.6.12.1423'
}

【问题讨论】:

  • 发布你的 gradle 文件
  • 当然。给我 2 秒。
  • @BhuvaneshBs 完成..

标签: java android dex


【解决方案1】:

对于您的应用程序不需要 Multidex。

在依赖版本中不要使用 + 运算符。

试试这个新配置:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.example.intuition.paytmprogress"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
}

从清单中删除 multiDex 应用程序。

2) 我可以看到一些已注释的依赖项。

如果您使用这些依赖项,请遵循这些说明。

  • 从中删除compile 'com.android.support:support-v4:+'。因为 support-v7 库包含 v4 支持库。

  • 确保您的库使用相同版本的支持库。如果您的支持库下有一条红线,说明找到了多个版本的支持库。您必须降级您的支持库版本以匹配它。

  • 仅在超过单个 Dex 时添加 multidex。

清理并重建您的项目。

【讨论】:

  • 如果我添加外部 Jar 文件,我会再次看到同样的问题。 :(
  • 仍然出现错误............错误:任务':app:transformClassesWithDexForDebug'的执行失败。 > com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: ProcessException: 使用带有参数的主类 com.android.dx.command.Main 执行 java 进程时出错 {- -dex --num-threads=4-output C:\AndroidStudioProjects\app\build\intermediates\pre-dexed\debug\paytm-checksum_2.0_0927f64182307d227e049.jar C:\AndroidStudioProjects\app\libs\paytm-checksum_2.0。罐子}
【解决方案2】:

您需要使用与compileSdkVersionbuildToolsVersionsupport library 相同的版本。因此,您需要使用版本 26。因此,您需要进行如下更改:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26 // need version 26
    buildToolsVersion "26.0.3" // need version 26
    defaultConfig {
        applicationId "com.example.intuition.paytmprogress"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    ...
}

dependencies {
    ...
    // Need version 26.
    compile 'com.android.support:appcompat-v7:26.1.0'  
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

不要使用 multidex,因为你还不需要它。

-- 已更新--

对于支持版本26.1.0,您需要将 google maven 添加到您的根 build.gradle 中,如下所示:

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

阅读更多Failed to resolve: com.android.support:appcompat-v7:26.0.0

【讨论】:

  • compile 'com.android.support:appcompat-v7:26.0.3'
  • 错误:将字节码转换为dex时出错:原因:解析错误:类名(com/paytm/pg/AppTest)与路径不匹配(target/test-classes/com/paytm/pg/AppTest .class) ...同时解析target/test-classes/com/paytm/pg/AppTest.class --------------------------- --------------------------这是我遇到的错误。
  • 这是另一种错误。您需要查看com/paytm/pg/AppTest 的课程。
猜你喜欢
  • 1970-01-01
  • 2016-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-22
  • 1970-01-01
相关资源
最近更新 更多