Android Studio - 错误:未捕获的翻译错误:com.android.dx.cf.code.SimException:local 0001:invalid

时间:2016-08-22 15:24:09

标签: android android-studio dex android-studio-2.1

我刚刚使用Android Studio设置了一台新计算机,并从bitbucket导入了我的项目。

问题是我在尝试构建项目时遇到此错误:

  

信息:Gradle任务[:app:clean,:app:generateDebugSources,   :app:generateDebugAndroidTestSources,:app:mockableAndroidJar,   :app:prepareDebugUnitTestDependencies,:app:assembleDebug]:app:clean   :app:preBuild UP-TO-DATE:app:preDebugBuild UP-TO-DATE   :app:checkDebugManifest:app:preReleaseBuild UP-TO-DATE   :应用:prepareChAcraAcra470Library   :应用:prepareComAndroidSupportAnimatedVectorDrawable2420Library   :应用:prepareComAndroidSupportAppcompatV72420Library   :应用:prepareComAndroidSupportDesign2420Library   :应用:prepareComAndroidSupportRecyclerviewV72420Library   :应用:prepareComAndroidSupportSupportCompat2420Library   :应用:prepareComAndroidSupportSupportCoreUi2420Library   :应用:prepareComAndroidSupportSupportCoreUtils2420Library   :应用:prepareComAndroidSupportSupportFragment2420Library   :应用:prepareComAndroidSupportSupportMediaCompat2420Library   :应用:prepareComAndroidSupportSupportV132420Library   :应用:prepareComAndroidSupportSupportV42420Library   :应用:prepareComAndroidSupportSupportVectorDrawable2420Library   :应用:prepareComGoogleAndroidGmsPlayServicesBase940Library   :应用:prepareComGoogleAndroidGmsPlayServicesBasement940Library   :应用:prepareComGoogleAndroidGmsPlayServicesTasks940Library   :应用:prepareComGoogleAndroidGmsPlayServicesVision940Library   :应用:prepareComJourneyappsZxingAndroidEmbedded320Library   :app:prepareDebugDependencies:app:compileDebugAidl   :app:compileDebugRenderscript:app:generateDebugBuildConfig   :app:mergeDebugShaders:app:compileDebugShaders   :app:generateDebugAssets:app:mergeDebugAssets   :app:generateDebugResValues UP-TO-DATE:app:generateDebugResources   :app:mergeDebugResources:app:processDebugManifest   :app:processDebugResources:app:generateDebugSources   :app:preDebugAndroidTestBuild UP-TO-DATE   :应用:prepareDebugAndroidTestDependencies   :app:compileDebugAndroidTestAidl:app:processDebugAndroidTestManifest   :应用:compileDebugAndroidTestRenderscript   :应用:generateDebugAndroidTestBuildConfig   :app:mergeDebugAndroidTestShaders:app:compileDebugAndroidTestShaders   :app:generateDebugAndroidTestAssets:app:mergeDebugAndroidTestAssets   :app:generateDebugAndroidTestResValues UP-TO-DATE   :应用:generateDebugAndroidTestResources   :应用:mergeDebugAndroidTestResources   :应用:processDebugAndroidTestResources   :app:generateDebugAndroidTestSources:app:mockableAndroidJar   最新消息:app:preDebugUnitTestBuild UP-TO-DATE   :应用:prepareDebugUnitTestDependencies   :应用:incrementalDebugJavaCompilationSafeguard   :app:compileDebugJavaWithJavac:app:compileDebugJavaWithJavac - 不是   增量(例如输出已更改,之前没有执行等)。   注意:某些输入文件使用或覆盖已弃用的API。注意:   使用-Xlint重新编译:弃用以获取详细信息。注意:一些输入文件   使用未经检查或不安全的操作。注意:重新编译   -Xlint:取消选中以获取详细信息。 :app:compileDebugNdk UP-TO-DATE:app:compileDebugSources:app:buildInfoDebugLoader   :应用:transformClassesWithExtractJarsForDebug   :应用:transformClassesWithInstantRunVerifierForDebug   :app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE   :应用:mergeDebugJniLibFolders   :应用:transformNative_libsWithMergeJniLibsForDebug   :app:processDebugJavaRes UP-TO-DATE   :应用:transformResourcesWithMergeJavaResForDebug   :应用:transformResourcesAndNative_libsWithJavaResourcesVerifierForDebug   UP-TO-DATE:app:transformClassesWithInstantRunForDebug   :app:transformClasses_enhancedWithInstant + reloadDexForDebug UP-TO-DATE   :app:incrementalDebugTasks:app:prePackageMarkerForDebug   :app:fastDeployDebugExtractor:app:generateDebugInstantRunAppInfo   :应用:coldswapKickerDebug   :应用:transformClassesWithInstantRunSlicerForDebug   :app:transformClassesWithDexForDebug错误:未捕获的翻译错误:   com.android.dx.cf.code.SimException:local 0001:invalid错误:1   错误;中止错误:任务执行失败   ':应用程序:transformClassesWithDexForDebug'

     
    

com.android.build.api.transform.TransformException:java.lang.RuntimeException:     com.android.ide.common.process.ProcessException:     java.util.concurrent.ExecutionException:     com.android.ide.common.process.ProcessException:返回dex的代码1     过程信息:BUILD FAILED信息:总时间:1分钟38.347     secs信息:3错误信息:0警告信息:请参阅     控制台中的完整输出

  

以下是Gradle Console窗口的输出:

  

执行任务:[:app:clean,:app:generateDebugSources,   :app:generateDebugAndroidTestSources,:app:mockableAndroidJar,   :app:prepareDebugUnitTestDependencies,:app:assembleDebug]

     

按需配置是一项孵化功能。增量java   编译是一个孵化功能。 :app:clean:app:preBuild   最新消息:app:preDebugBuild UP-TO-DATE:app:checkDebugManifest   :app:preReleaseBuild UP-TO-DATE:app:prepareChAcraAcra470Library   :应用:prepareComAndroidSupportAnimatedVectorDrawable2420Library   :应用:prepareComAndroidSupportAppcompatV72420Library   :应用:prepareComAndroidSupportDesign2420Library   :应用:prepareComAndroidSupportRecyclerviewV72420Library   :应用:prepareComAndroidSupportSupportCompat2420Library   :应用:prepareComAndroidSupportSupportCoreUi2420Library   :应用:prepareComAndroidSupportSupportCoreUtils2420Library   :应用:prepareComAndroidSupportSupportFragment2420Library   :应用:prepareComAndroidSupportSupportMediaCompat2420Library   :应用:prepareComAndroidSupportSupportV132420Library   :应用:prepareComAndroidSupportSupportV42420Library   :应用:prepareComAndroidSupportSupportVectorDrawable2420Library   :应用:prepareComGoogleAndroidGmsPlayServicesBase940Library   :应用:prepareComGoogleAndroidGmsPlayServicesBasement940Library   :应用:prepareComGoogleAndroidGmsPlayServicesTasks940Library   :应用:prepareComGoogleAndroidGmsPlayServicesVision940Library   :应用:prepareComJourneyappsZxingAndroidEmbedded320Library   :app:prepareDebugDependencies:app:compileDebugAidl   :app:compileDebugRenderscript:app:generateDebugBuildConfig   :app:mergeDebugShaders:app:compileDebugShaders   :app:generateDebugAssets:app:mergeDebugAssets   :app:generateDebugResValues UP-TO-DATE:app:generateDebugResources   :app:mergeDebugResources:app:processDebugManifest   :app:processDebugResources:app:generateDebugSources   :app:preDebugAndroidTestBuild UP-TO-DATE   :应用:prepareDebugAndroidTestDependencies   :app:compileDebugAndroidTestAidl:app:processDebugAndroidTestManifest   :应用:compileDebugAndroidTestRenderscript   :应用:generateDebugAndroidTestBuildConfig   :app:mergeDebugAndroidTestShaders:app:compileDebugAndroidTestShaders   :app:generateDebugAndroidTestAssets:app:mergeDebugAndroidTestAssets   :app:generateDebugAndroidTestResValues UP-TO-DATE   :应用:generateDebugAndroidTestResources   :应用:mergeDebugAndroidTestResources   :应用:processDebugAndroidTestResources   :app:generateDebugAndroidTestSources:app:mockableAndroidJar   最新消息:app:preDebugUnitTestBuild UP-TO-DATE   :应用:prepareDebugUnitTestDependencies   :应用:incrementalDebugJavaCompilationSafeguard   :app:compileDebugJavaWithJavac:app:compileDebugJavaWithJavac - 不是   增量(例如输出已更改,之前没有执行等)。

     

注意:某些输入文件使用或覆盖已弃用的API。注意:   使用-Xlint重新编译:弃用以获取详细信息。注意:一些输入文件   使用未经检查或不安全的操作。注意:重新编译   -Xlint:取消选中以获取详细信息。

     

:app:compileDebugNdk UP-TO-DATE:app:compileDebugSources   :app:buildInfoDebugLoader:app:transformClassesWithExtractJarsForDebug   :应用:transformClassesWithInstantRunVerifierForDebug   :app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE   :应用:mergeDebugJniLibFolders   :应用:transformNative_libsWithMergeJniLibsForDebug   :app:processDebugJavaRes UP-TO-DATE   :应用:transformResourcesWithMergeJavaResForDebug   :应用:transformResourcesAndNative_libsWithJavaResourcesVerifierForDebug   UP-TO-DATE:app:transformClassesWithInstantRunForDebug   :app:transformClasses_enhancedWithInstant + reloadDexForDebug UP-TO-DATE   :app:incrementalDebugTasks:app:prePackageMarkerForDebug   :app:fastDeployDebugExtractor:app:generateDebugInstantRunAppInfo   :应用:coldswapKickerDebug   :应用:transformClassesWithInstantRunSlicerForDebug   :app:transformClassesWithDexForDebug AGPBI:   {" kind":"错误","文字":"未捕获的翻译错误:   com.android.dx.cf.code.SimException:local 0001:   无效","来源":[{}]} AGPBI:{"善意":"错误","文字":& #34; 1错误;   中止""来源":[{}]}

     

FAILED

     

失败:构建因异常而失败。

     
      
  • 出了什么问题:任务执行失败':app:transformClassesWithDexForDebug'。

         
        

    com.android.build.api.transform.TransformException:java.lang.RuntimeException:     com.android.ide.common.process.ProcessException:     java.util.concurrent.ExecutionException:     com.android.ide.common.process.ProcessException:返回dex的代码1     过程

      
  •   
  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。

  •   
     

建立失败

为了调查,我已经创建了Android Studio附带的Camera2Basic示例项目并且构建良好,所以这可能是我项目中的设置问题而不是一般配置/设置问题?

我已经尝试过(没有运气):

  1. org.gradle.jvmargs=-Xmx2048m添加到我的gradle.properties文件中。
  2. 在我的应用 minifyEnabled false文件中设置build.gradle(在releasedebug区块中)。
  3. This suggestion
  4. File> Invalidate Cahces / Restart...
  5. NB - Similar question here - 但错误编号不同,目前没有答案。

    更新

    从我的应用程序中删除了第三方库(nxpnfclib.jar)后,我的项目现在可以构建并运行正常。但如果我再尝试重新添加jar,问题又回来了。

    更新#2:

    我创建了一个示例Android Studio项目(Camera2Basic)并添加了nxpnfclib.jar库。出现同样的问题。所以这显然是nxpnfclib.jar库的一个问题。 (今天,我已经通过电子邮件向恩智浦发送了关于这个最新版本的库,因此我将使用他们的解决方案更新此页面 - 当然,除非他们更新它。)

    我正在使用:

    • Windows 7(64位)
    • Android Studio v2.1.3(全新安装)
    • JDK 1.8.0_102
    • Gradle版本2.14.1
    • Android插件版本2.1.3

1 个答案:

答案 0 :(得分:0)

这是我在我的场景中所做的修复:

在android studio的项目级别更新了build.gradle,如下所示:

buildscript {
    ext.kotlin_version = '1.2.31
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'
}

然后在gradle-wrapper.properties上:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip