【问题标题】:Error converting byte code to dex:将字节码转换为 dex 时出错:
【发布时间】:2016-08-30 16:35:29
【问题描述】:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72340Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2340Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE
:app:prepareComCouchbaseLiteCouchbaseLiteAndroid121Library UP-TO-DATE
:app:prepareComCouchbaseLiteCouchbaseLiteAndroidSqliteDefault121Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics920Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl920Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase920Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement920Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasks920Library UP-TO-DATE
:app:prepareComJakewhartonButterknife810Library UP-TO-DATE
:app:prepareComMiguelcatalanMaterialsearchview140Library UP-TO-DATE
:app:preparePlTajchertWaitingdots020Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:prePackageMarkerForDebug
:app:transformClassesWithDexForDebug
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
:app:transformClassesWithDexForDebug FAILED
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: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_102\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 2 mins 52.839 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console

【问题讨论】:

    标签: android dex


    【解决方案1】:

    你的 gradle.build 中有几个支持库的声明。 Here 是一个很好的指导如何确定问题的原因。

    你也可以试试这个简单的解决方法:

    android {
        dexOptions {
            preDexLibraries = false
        }
    }
    

    【讨论】:

      【解决方案2】:

      按照以下步骤操作 java.lang.NoClassDefFoundError: okhttp3.internal.Util

      您已启用“multiDexEnabled true”,并且很可能您没有在应用程序类中安装它。

      你应该这样做

      android {
          compileSdkVersion 22
          buildToolsVersion "23.0.0"
      
               defaultConfig {
                   minSdkVersion 14 //lower than 14 doesn't support multidex
                   targetSdkVersion 22
      
                   // Enabling multidex support.
                   multiDexEnabled true       //You have already did this 
               }
      }
      
      
      dependencies {
          compile 'com.android.support:multidex:1.0.1'   // add this in  dependencies
      }
      

      最后扩展应用程序

      public class YouApplication extends Application {
      
          @Override
          protected void attachBaseContext(Context base) {
              super.attachBaseContext(base);
              MultiDex.install(this);
          }
      
      }
      

      这是一个很好的指南https://developer.android.com/studio/build/multidex.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-10
        • 2017-02-27
        • 1970-01-01
        • 1970-01-01
        • 2016-09-02
        • 1970-01-01
        相关资源
        最近更新 更多