gpt4 book ai didi

android - 使用Robolectric运行JUnit测试时出现Gradle和Android Studio问题

转载 作者:行者123 更新时间:2023-12-03 06:17:07 26 4
gpt4 key购买 nike

该应用程序的build.gradle为:

    apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.0"

defaultConfig {
applicationId "myapp.robolectricexample2"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'org.robolectric:robolectric:3.0-rc2'
compile 'junit:junit:4.12'
}

因此,出现以下错误:

Error:Gradle: Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 2

最佳答案

试试这个build.gradle

android {
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1" // <-- was 22.0.0

defaultConfig {
applicationId "myapp.robolectricexample2"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.android.support:appcompat-v7:22.1.1' // <-- was 22.0.0
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.0-rc2'
}

现在,您可以运行 gradlew testDebug

将您的测试放入 src/test 中。

关于android - 使用Robolectric运行JUnit测试时出现Gradle和Android Studio问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29584361/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com