[英]Set up build.gradle Junit Android tests
我是Android測試的初學者。 我正在嘗試執行Junit測試,但是在加載本機庫時崩潰。
這是我的build.gradle文件:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
minSdkVersion 18
targetSdkVersion 24
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:24.0.0'
// Unit testing dependencies
testCompile 'junit:junit:4.12'
// Set this dependency if you want to use the Hamcrest matcher library
testCompile 'org.hamcrest:hamcrest-library:1.3'
// more stuff, e.g., Mockito
testCompile 'org.mockito:mockito-core:1.10.19'
}
repositories {
flatDir {
dirs 'libs'
}
}
當我這樣做
static
{
System.loadLibrary("a");
}
我獲得了java.lang.UnsatisfiedLinkError: no a in java.library.path
我的測試在"src/test/java"
,本機庫在"src/test/jniLibs"
。 我想比必須在build.gradle中指定Jni庫路徑,但是如何?
謝謝
將該文件夾添加到類路徑,如下所示: https : //discuss.gradle.org/t/how-to-add-to-a-test-classpath/7083
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.