我们都知道Android中所有应用程序都运行在Android的Dalvik虚拟机上,一般程序不直接与操作系统打交道,即便调用底层的方法也通过JNI技术。不过我们可以直接使用C语言编写二进制文件,直接在底层运行。下面演示其步骤。

1.安装下载编译器和链接器软件.Sourcery G++ Lite Edition for ARM.

arm-none-linux-gnueabi-gcc.exe是编译命令
bin/arm-none-linux-gnueabi-ld.exe是链接命令

2.编写C代码

为了演示方便编写最简单的代码,输出hello,world,例如:我在d:/temp目录写建立hello.c文件

#include<stdio.h>
int main(){
printf("helloworld\n");
return 0;
}

3.编译hello.c文件

cmd---d:/---cd temp进入temp目录下arm-none-linux-gnueabi-gcc hello.c -static -o hello,在目录中生成hello二进制文件

4.将hello文件push到手机

启动模拟器---adb push hello /data/data/hello

5.修改属性

adb shell

cd /data/data/

chmod 777 hello

将hello修改为可执行文件

6.执行文件

./hello

7.显示

helloworld

编写Android中直接可运行的二进制文件

更多相关文章

  1. android 数据库技术 | 文件系统,SDCARD访问,CONTENT PROVIDER,SQLIT
  2. Android studio 使用心得(六)---android studio 如何加载.so文件
  3. # Android文件存储和数据库基本知识
  4. android 在布局文件中报错:This text field does not specify an
  5. 基于android的NFS根文件系统的制作
  6. android 签名文件

随机推荐

  1. android中关于class Build以及如何修改an
  2. Android之Handler用法总结
  3. Android日志收集
  4. 开机动画(闪动的ANDROID字样的动画图片)
  5. textview中加链接
  6. Android中同时选择日期和时间
  7. [Android] AsyncTask使用实例---加载网络
  8. Android(安卓)TextView中文字通过Spannab
  9. Android的SQLite----重新认识Android(10)
  10. Android之TextView