JNI_OnLoad returned bad version (-1) 问题解决 proguard

原创 2014年01月07日 19:31:35

添加jni时出现如下问题

log 如下

01-07 17:34:51.406 W/dalvikvm( 2032): JNI_OnLoad returned bad version (-1) in /system/lib/libengfetch_jni.so 0x423fcc30

01-07 17:34:51.406 D/wll     ( 2032): load libtesterstatus_jni error!
01-07 17:34:51.406 W/dalvikvm( 2032): No implementation found for native Lcom/huaqin/runtime/engtools/engfetch;.engf_writephasecheck:(II)V
01-07 17:34:51.406 D/AndroidRuntime( 2032): Shutting down VM
01-07 17:34:51.406 W/dalvikvm( 2032): threadid=1: thread exiting with uncaught exception (group=0x41cdc378)
01-07 17:34:51.406 I/        ( 2032): JNI_OnLoad
01-07 17:34:51.406 E/        ( 2032): RegisterNatives failed for 'com/huaqin/runtime/engtools/engfetch'
01-07 17:34:51.406 E/        ( 2032): ERROR: registerNatives failed
01-07 17:34:51.406 E/AndroidRuntime( 2032): FATAL EXCEPTION: main
01-07 17:34:51.406 E/AndroidRuntime( 2032): java.lang.UnsatisfiedLinkError: Native method not found: com.huaqin.runtime.engtools.engfetch.engf_writephasecheck:(II)V
01-07 17:34:51.406 E/AndroidRuntime( 2032): at com.huaqin.runtime.engtools.engfetch.engf_writephasecheck(Native Method)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at com.huaqin.runtime.engtools.engfetch.engwritephasecheck(engfetch.java:124)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at com.huaqin.runtime.RuntimeTestTesting.RuntimeTestTestingResultSave(RuntimeTestTesting.java:196)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at com.huaqin.runtime.RuntimeTestTesting.access$2000(RuntimeTestTesting.java:42)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at com.huaqin.runtime.RuntimeTestTesting$3.onReceive(RuntimeTestTesting.java:316)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:755)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at android.os.Handler.handleCallback(Handler.java:615)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at android.os.Handler.dispatchMessage(Handler.java:92)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at android.os.Looper.loop(Looper.java:137)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at android.app.ActivityThread.main(ActivityThread.java:4990)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:807)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:574)
01-07 17:34:51.406 E/AndroidRuntime( 2032): at dalvik.system.NativeStart.main(Native Method)

01-07 17:34:51.416 W/ActivityManager(  449):   Force finishing activity com.huaqin.runtime/.RuntimeTestTesting

.........

网上搜索可能是proguard问题引起的。

判断出在编译的时候系统做了优化,把无用的代码做了过滤(engf_writephasecheck )。好,那我就在编译时强制保留此方法,了解到Android系统编译是用ProGuard来进行代码优化和混淆工作的,OK,参照别的Android.mk文件加了参数:

   LOCAL_PROGUARD_FLAG_FILES := proguard.flags


又创建了proguard.flags文件,内容如下:

   -keep class com.huaqin.runtime.engtools.engfetch {static *;}
    }

保留engfentch所有的static方法.测试有效

参考 http://www.cnitblog.com/zouzheng/archive/2011/01/12/72639.html


利用IE浏览器的Com组件在WinForm中显示资源中的HTML文件

  /// 利用IE浏览器的Com组件在WinForm中显示资源文件中的HTML文件.  ///   /// 这里重点有两个:  /// 1. 调用IE的COM组件  /// 2. 调用编译到exe文...
  • steeven
  • steeven
  • 2002-08-28 08:57:00
  • 1181

JNI java.lang.UnsatisfiedLinkError

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.mingspy.jseg.JSegJNI.MaxSplit(Ljava/l...
  • mingspy
  • mingspy
  • 2014-04-09 14:04:39
  • 12518

java.lang.UnsatisfiedLinkError解决方法汇集(转载)

 J2EE引擎出现java.lang.UnsatisfiedLinkError: CC错误的原因(2008-03-04 11:03:29)标签:报表软件 报表工具 web报表 软件 下载 it 如意报...
  • niuxinlong
  • niuxinlong
  • 2009-05-13 12:42:00
  • 290235

Error loading RS jni library: java.lang.UnsatisfiedLinkError

Error loading RS jni library: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/...
  • yypccc
  • yypccc
  • 2017-04-30 11:52:55
  • 1307

JNI_Onload 的用法 版本返回一定要添加

http://liview.cn/discuz/forum.php?mod=viewthread&tid=5 Java JNI有两种方法,一种是通过javah,获取一组带签名函数,然后实现这些函...
  • hardccyy
  • hardccyy
  • 2013-07-30 16:40:14
  • 1798

[bug小记]System.loadLibrary加载so库时报警告JNI_OnLoad returned bad version(-1)并且crash

public class SVideoEngineController{ static{ System.loadLibrary("arcplatform"); System.loadLi...
  • shirleyxiao
  • shirleyxiao
  • 2014-08-05 16:53:07
  • 8257

Android源码分析实战之JNI so库加载System.loadLibrary流程分析

JNI so库加载流程之System.loadLibrary流程分析最近在学习jni相关的知识,很多博客都说,jni***动态注册*时可以调用System.loadLibrary或者System.lo...
  • zhangmingbao2016
  • zhangmingbao2016
  • 2017-06-21 17:50:41
  • 2840

Android NDK 运行错误:java.lang.UnsatisfiedLinkError: Couldn't load XXX indLibrary returned null

今天将一个带有C++的android混合项目倒出的Android Studio,运行起来出现了如下错误: 5-31 18:45:52.320 10741-10741/com.example.hell...
  • yy1300326388
  • yy1300326388
  • 2015-05-31 20:27:27
  • 29566

"Caused by: java.lang.UnsatisfiedLinkError: Library hello-jni not found“问题解决

现象: 调用libhello-jni.so时,出现“Caused by: java.lang.UnsatisfiedLinkError: Library hello-jni not found”问题。...
  • liranke
  • liranke
  • 2013-11-20 09:41:32
  • 5255

No JNI_OnLoad found in /data/data/

最近,又用到ndk去ji
  • liranke
  • liranke
  • 2014-11-13 14:39:25
  • 31177
收藏助手
不良信息举报
您举报文章:JNI_OnLoad returned bad version (-1) 问题解决 proguard
举报原因:
原因补充:

(最多只允许输入30个字)