我使用 gradle 生成 apk。安装后,发布的版本出现错误: java.lang.UnsatisfiedLinkError: Native method not found: com.fss.e.b.a:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
但是调试的看起来不错。我写的 build.gradle 如下:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':fss:libs:actionbarsherlock')
compile project(':fss:libs:library')
compile project(':library')
}
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
signingConfigs {
myConfig{
}
}
buildTypes{
release {
signingConfig signingConfigs.myConfig
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
tasks.withType(Compile) {
options.encoding = "UTF-8"
}
task copyNativeLibs(type: Copy) {
from fileTree(dir: 'libs', include: '**/*.so' )
into 'build/native-libs'
}
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
clean.dependsOn 'cleanCopyNativeLibs'
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniDir new File('build/native-libs')
}