我正在使用 Camera2Basic example由 Google 在 Android Studio 中测试应用程序。运行项目时出现此错误:
Error:Execution failed for task ':Application: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: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_55\bin\java.exe'' finished with non-zero exit value 1
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
dependencies {
compile "com.android.support:support-v4:23.3.0"
compile "com.android.support:support-v13:23.3.0"
compile "com.android.support:cardview-v7:23.3.0"
compile 'com.android.support:appcompat-v7:23.0.0'
}
// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
'main', // main sample code; look here for the interesting stuff.
'common', // components that are reused by multiple samples
'template'] // boilerplate code that is generated by the sample template process
android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc3"
defaultConfig {
minSdkVersion 21
targetSdkVersion 23
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
dirs.each { dir ->
java.srcDirs "src/${dir}/java"
res.srcDirs "src/${dir}/res"
}
}
androidTest.setRoot('tests')
androidTest.java.srcDirs = ['tests/src']
}
}
我做了什么
1) 我在 defaultConfig 中添加了 multiDexEnabled true
。
2) 还尝试在依赖项中添加 compile 'com.android.support:multidex:1.0.0'
。
最佳答案
我变了
buildToolsVersion "24.0.0 rc3"
与
buildToolsVersion "23.0.1"
在 build.gradle 文件中。现在,它正在工作。我不知道原因。如果有人知道原因,请编辑此答案。这会很有帮助。
谢谢。
关于java - 相机 2 基本 : Application:transformClassesWithDexForDebug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37075088/