我刚刚使用 Android Studio 设置了一台新计算机,并从 bitbucket 导入了我的项目。
问题是我现在在尝试构建项目时遇到此错误:
Information:Gradle tasks [: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 :app:prepareChAcraAcra470Library :app:prepareComAndroidSupportAnimatedVectorDrawable2420Library :app:prepareComAndroidSupportAppcompatV72420Library :app:prepareComAndroidSupportDesign2420Library :app:prepareComAndroidSupportRecyclerviewV72420Library :app:prepareComAndroidSupportSupportCompat2420Library :app:prepareComAndroidSupportSupportCoreUi2420Library :app:prepareComAndroidSupportSupportCoreUtils2420Library :app:prepareComAndroidSupportSupportFragment2420Library :app:prepareComAndroidSupportSupportMediaCompat2420Library :app:prepareComAndroidSupportSupportV132420Library :app:prepareComAndroidSupportSupportV42420Library :app:prepareComAndroidSupportSupportVectorDrawable2420Library :app:prepareComGoogleAndroidGmsPlayServicesBase940Library :app:prepareComGoogleAndroidGmsPlayServicesBasement940Library :app:prepareComGoogleAndroidGmsPlayServicesTasks940Library :app:prepareComGoogleAndroidGmsPlayServicesVision940Library :app: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 :app:prepareDebugAndroidTestDependencies :app:compileDebugAndroidTestAidl :app:processDebugAndroidTestManifest :app:compileDebugAndroidTestRenderscript :app:generateDebugAndroidTestBuildConfig :app:mergeDebugAndroidTestShaders :app:compileDebugAndroidTestShaders :app:generateDebugAndroidTestAssets :app:mergeDebugAndroidTestAssets :app:generateDebugAndroidTestResValues UP-TO-DATE :app:generateDebugAndroidTestResources :app:mergeDebugAndroidTestResources :app:processDebugAndroidTestResources :app:generateDebugAndroidTestSources :app:mockableAndroidJar UP-TO-DATE :app:preDebugUnitTestBuild UP-TO-DATE :app:prepareDebugUnitTestDependencies :app:incrementalDebugJavaCompilationSafeguard :app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). 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:buildInfoDebugLoader :app:transformClassesWithExtractJarsForDebug :app:transformClassesWithInstantRunVerifierForDebug :app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE :app:mergeDebugJniLibFolders :app:transformNative_libsWithMergeJniLibsForDebug :app:processDebugJavaRes UP-TO-DATE :app:transformResourcesWithMergeJavaResForDebug :app:transformResourcesAndNative_libsWithJavaResourcesVerifierForDebug UP-TO-DATE :app:transformClassesWithInstantRunForDebug :app:transformClasses_enhancedWithInstant+reloadDexForDebug UP-TO-DATE :app:incrementalDebugTasks :app:prePackageMarkerForDebug :app:fastDeployDebugExtractor :app:generateDebugInstantRunAppInfo :app:coldswapKickerDebug :app:transformClassesWithInstantRunSlicerForDebug :app:transformClassesWithDexForDebug Error:Uncaught translation error: com.android.dx.cf.code.SimException: local 0001: invalid Error:1 error; aborting Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
block 引用>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: Return code 1 for dex process Information:BUILD FAILED Information:Total time: 1 mins 38.347 secs Information:3 errors Information:0 warnings Information:See complete output in console
这是 Gradle 控制台窗口的输出:
Executing tasks: [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
Configuration on demand is an incubating feature. Incremental java compilation is an incubating feature. :app:clean :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareChAcraAcra470Library :app:prepareComAndroidSupportAnimatedVectorDrawable2420Library :app:prepareComAndroidSupportAppcompatV72420Library :app:prepareComAndroidSupportDesign2420Library :app:prepareComAndroidSupportRecyclerviewV72420Library :app:prepareComAndroidSupportSupportCompat2420Library :app:prepareComAndroidSupportSupportCoreUi2420Library :app:prepareComAndroidSupportSupportCoreUtils2420Library :app:prepareComAndroidSupportSupportFragment2420Library :app:prepareComAndroidSupportSupportMediaCompat2420Library :app:prepareComAndroidSupportSupportV132420Library :app:prepareComAndroidSupportSupportV42420Library :app:prepareComAndroidSupportSupportVectorDrawable2420Library :app:prepareComGoogleAndroidGmsPlayServicesBase940Library :app:prepareComGoogleAndroidGmsPlayServicesBasement940Library :app:prepareComGoogleAndroidGmsPlayServicesTasks940Library :app:prepareComGoogleAndroidGmsPlayServicesVision940Library :app: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 :app:prepareDebugAndroidTestDependencies :app:compileDebugAndroidTestAidl :app:processDebugAndroidTestManifest :app:compileDebugAndroidTestRenderscript :app:generateDebugAndroidTestBuildConfig :app:mergeDebugAndroidTestShaders :app:compileDebugAndroidTestShaders :app:generateDebugAndroidTestAssets :app:mergeDebugAndroidTestAssets :app:generateDebugAndroidTestResValues UP-TO-DATE :app:generateDebugAndroidTestResources :app:mergeDebugAndroidTestResources :app:processDebugAndroidTestResources :app:generateDebugAndroidTestSources :app:mockableAndroidJar UP-TO-DATE :app:preDebugUnitTestBuild UP-TO-DATE :app:prepareDebugUnitTestDependencies :app:incrementalDebugJavaCompilationSafeguard :app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
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:buildInfoDebugLoader :app:transformClassesWithExtractJarsForDebug :app:transformClassesWithInstantRunVerifierForDebug :app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE :app:mergeDebugJniLibFolders :app:transformNative_libsWithMergeJniLibsForDebug :app:processDebugJavaRes UP-TO-DATE :app:transformResourcesWithMergeJavaResForDebug :app:transformResourcesAndNative_libsWithJavaResourcesVerifierForDebug UP-TO-DATE :app:transformClassesWithInstantRunForDebug :app:transformClasses_enhancedWithInstant+reloadDexForDebug UP-TO-DATE :app:incrementalDebugTasks :app:prePackageMarkerForDebug :app:fastDeployDebugExtractor :app:generateDebugInstantRunAppInfo :app:coldswapKickerDebug :app:transformClassesWithInstantRunSlicerForDebug :app:transformClassesWithDexForDebug AGPBI: {"kind":"error","text":"Uncaught translation error: com.android.dx.cf.code.SimException: local 0001: invalid","sources":[{}]} AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]}
FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':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: Return code 1 for dex process
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。
构建失败
block 引用>为了进行调查,我创建了 Android Studio 附带的 Camera2Basic 示例项目,并且构建良好,所以这可能是我的项目中的设置问题,而不是一般配置/设置问题?
我已经尝试过(没有运气):
- 已将
org.gradle.jvmargs=-Xmx2048m
添加到我的gradle.properties
文件中。- 在我的应用
minifyEnabled false
文件中设置build.gradle
(在release
和debug
block 中)。- This suggestion。
File
>Invalidate Cahces / Restart...
注意 - 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
最佳答案
这是我在我的场景中所做的修复:
在 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
关于Android Studio - 错误 :Uncaught translation error: com. android.dx.cf.code.SimException:本地 0001:无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39083338/