我是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库路径,但是如何?
由于
答案 0 :(得分:0)
将文件夹添加到类路径中,如下所示:https://discuss.gradle.org/t/how-to-add-to-a-test-classpath/7083