当前位置: 首页 > news >正文

洛阳鼎和电力建设有限公司网站企业专属空间登录

洛阳鼎和电力建设有限公司网站,企业专属空间登录,免费优化关键词,坪地网站建设怎么样#xff11;#xff12;年的时候写过#xff2a;#xff2e;#xff29;但是又忘记得差不多了#xff0c;现在重新写了一次#xff0c;发现碰到了几个问题#xff0c;写下来记录一下 第一步 应用程序java代码 package com.example.helloworld;import java.util.Calend…年的时候写过但是又忘记得差不多了现在重新写了一次发现碰到了几个问题写下来记录一下 第一步 应用程序java代码 package com.example.helloworld;import java.util.Calendar;import android.os.Bundle; import android.app.Activity; import android.app.AlarmManager; import android.util.Log;public class AlarmTest extends Activity {AlarmManager aManager;Calendar currentTime Calendar.getInstance();public static final int POWER_OFF_WAKE_UP 8;//用来设置关机启动的参数 平台这边已经设置好了Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Log.e(weiqifa, test());}public native String test();static {try{Log.i(JNI, Trying to load libhelloworld.so);System.loadLibrary(helloWorld);}catch(UnsatisfiedLinkError ule){Log.e(JNI, Warning : could not load the libhelloworld.so);}} }编译一下可以是eclipse编译也可以是java命令编译 编译后有下面的代码结构和目录 weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ ls AndroidManifest.xml  classes  classes.dex  dexedLibs  helloWorld.apk  res  resources.ap_ weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ 第二步 生成共享头文件 这一步是最关键的关系到成功和失败 weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ javah -d header -classpath classes -jni com.example.helloworld.AlarmTest weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ 这个命令比较关键 javah -d header 指的是在当前目录下面生成这个头文件-classpath是指定classes的目录就是第一步里面生成的 -jni指的是生成jni头文件 com.example.helloworld这个是包名 AlarmTest是类名 这些都不能有错 生成后如下 weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ ls AndroidManifest.xml  classes  classes.dex  dexedLibs  header  helloWorld.apk  res  resources.ap_ weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ ls header/ com_example_helloworld_AlarmTest.h weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ cat header/com_example_helloworld_AlarmTest.h /* DO NOT EDIT THIS FILE - it is machine generated */ #include jni.h /* Header for class com_example_helloworld_AlarmTest */#ifndef _Included_com_example_helloworld_AlarmTest #define _Included_com_example_helloworld_AlarmTest #ifdef __cplusplus extern C { #endif #undef com_example_helloworld_AlarmTest_POWER_OFF_WAKE_UP #define com_example_helloworld_AlarmTest_POWER_OFF_WAKE_UP 8L /** Class: com_example_helloworld_AlarmTest* Method: test* Signature: ()Ljava/lang/String;*/ JNIEXPORT jstring JNICALL Java_com_example_helloworld_AlarmTest_test(JNIEnv *, jobject);#ifdef __cplusplus } #endif #endif刚开始不知道运行经常出错如下weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ javah -jni com.example.helloworld error: cannot access com.example.helloworld class file for com.example.helloworld not found javadoc: error - Class com.example.helloworld not found. Error: No classes were specified on the command line.  Try -help. weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/bin$ 可以看到自动生成对应的函数Java_com_example_helloworld_AlarmTest_test Java_ 包名com_example_helloworld 类名(AlarmTest) 接口名(test)必须要按此JNI规范来操作 第三步 通过.h来制作.c 看看我们的.c 我们只是需要.h里面那个函数名字.h没有被引用也没有参与编译和预编译 helloworld.c如下 #include string.h #include jni.hJNIEXPORT jstring JNICALL Java_com_example_helloworld_AlarmTest_test(JNIEnv *env, jobject thiz) {return (*env)-NewStringUTF(env,weiqifa hello for JNI); }第四步 生成so文件 看一下我们的mk文件 LOCAL_PATH : $(call my-dir) include $(CLEAR_VARS)LOCAL_MODULE : helloWorld LOCAL_SRC_FILES : helloWorld.cinclude $(BUILD_SHARED_LIBRARY)会生成如下的so文件 weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/libs/armeabi$ ls libhelloWorld.so weiqifaweiqifa-Inspiron-3847:~/workspace/helloWorld/libs/armeabi$ 第五步 执行验证 直接用eclipse安装 或者用 adb push 进去 用adb的话要手动安装so 文件并且改一下权限 10-20 03:06:45.241: E/weiqifa(12194): weiqifa hello for JNI 10-20 03:06:45.241: V/ActivityThread(12194): activityCreated rActivityRecord{41e7a890 tokenandroid.os.BinderProxy41e7a060 {com.example.helloworld/com.example.helloworld.AlarmTest}} 问题 刚开始的时候我在Android.mk里面写的LOCAL_MODULE生成的模块名称是大写WhelloWorld LOCAL_MODULE : helloWorld但是在android源码里面我写的 System.loadLibrary(helloWorld);里面的helloworld是小写w然后运行一直加载不成功后面有个朋友帮我看了一下找到原因粗心大意啊。
http://www.pierceye.com/news/772114/

相关文章:

  • 网站后台管理系统源代码沧州市宇通网站建设公司
  • 郴州网站设计公司阜新网站设计
  • 成都网站制作中国互联个人做电影网站赚钱吗
  • 如何做自己的影视网站惠州惠城网站建设
  • 温州网站推广外包推推蛙网站建设
  • 北京百度网站排名优化四川公共资源交易网招标网
  • 上海网站制作商多用户网上商城
  • 四川建设网电子招投标网站莱芜金点子电话
  • 深圳科技网站建设网站怎么做跳站
  • 做网站需要多少人全国物流货运平台
  • 温州建网站用自己的电脑做网站
  • 综合性门户网站有哪些高端网站建设 房产
  • 百度做的网站能优化吗如何在jsp上做网站页面代码
  • 广州市品牌网站建设公司营销型网站开发推广
  • 甜品网站首页设计用php做的网站模版
  • 怎样做企业的网站百度下载安装免费版
  • 常州市网站优化汕头网站建设和运营
  • wordpress 同分类评论调用seo排名是什么
  • 网站建设推广怎么玩软件开发模型是什么
  • 网站开发报价表格海口注册公司代理公司地址电话
  • 西宁好的网站建设视频网站文案
  • 郑州网站优化网络建设有限公司网站建设 交单流程
  • 网站搬家内页打不开重庆市建设工程信息网怎么进不去
  • 深圳 做公司网站网站用什么建设
  • 网站更换空间对优化的影响营销号视频生成器手机版
  • 南宁大型网站推广公司昆山网站制作哪家好
  • 格尔木哪里有做网站的wordpress编辑器排版
  • 怎样开电商襄阳抖音seo找哪家
  • 个人网站 域名舞阳专业做网站
  • 做国外购物网站凤山网站seo