Guide to porting Android ndk-based applications (android ndk-based libs/x86)

Source: Internet
Author: User

Summary

  • Introduction
  • Learn about Android for x86
  • Ndk compilation tool
  • Compile
  • Check apk
  • Install a simulator
  • Debug apk

Introduction
Dear developers, Android tablets Based on INTEL x86 architecture are coming soon. Please read this article carefully to make your applications run properly on x86 devices.

Understanding Android for x86 (1)
 

  • And TraditionalAndroid Application Development?
  • Development methods and ideas
  • Development Tool Set
  • Development Process
  • Use of sdks, virtual machines, and related documents
  • Android SDK supports x86 Android Emulation since V12. It comes with IA Android Simulator "emulator-x86" and supports different Android platforms.
  • Currently, google's official SDK does not contain x86 image simulators. It will appear in future SDK versions.
  • Applications based only on Dalvik:
  • In addition to adjusting the display adaptation (including the resolution, orientation, UI, and other aspects), you can deploy applications on Android for x86 devices without any effort.


Understanding Android for x86 (2)

  • What is the difference from traditional Android Application Development?
  • Simulators and real target devices are x86-based instruction sets (IA Architecture)
  • Compared with traditional technologies, the x86 Instruction Set and KVM technologies allow simulators to provide higher performance support.
  • Libraries implemented based on NDK need to be re-compiled
  • If an assembly language is used, these assembly commands must belong to the x86 Instruction Set (IA architecture instruction set)
  • Android for x86 has made a lot of and in-depth optimizations for Dalvik virtual machines, Javascript Engines, C libraries, media libraries, graphics, sdks, NDK, simulators, and kernels.
  • Many Intel's special optimization technologies can be applied to the development of Android for x86 applications.
  • Provide better compatibility between x86 platforms

Which applications need to be transplanted?

  • Applications that contain ARM libraries. You need to port to an x86 library to run on Android devices in the x86 architecture.
  • For applications with lower resolution. You need to re-adjust the UI for a large-resolution tablet to achieve better results.


Procedure
 

  • First, download the latest NDK compilation tool;
  • Then, compile the x86 library files in the NDK;
  • Finally, generate a new APK and test it;


Ndk compilation tool

  • Download windows or linux based on your operating system
  • The latest NDK compilation tool supports generating so libraries for both arm and x86 versions by setting them in your Application. mk
  • APP_ABI: = armeabi x86

Compile
 

  • Take the ubuntu operating system as an example. When using the ndk compilation tool for the first time, decompress the tool first ~ /Android-ndk-r6b/directory
  • Assume that your jni project is in ~ The/myjni/directory contains Application. mk, Android. mk, And. c and. H files. Only two steps are required for compilation.

1, cd ~ /Myjni/2 ,~ /Android-ndk-r6b/ndk-build
Check compilation results

  • If yes, A ~ is generated ~ /Libs/directory. Its structure is

Libs/| -- armeabi | '-- libyourjni. so | -- x86' -- libyourjni. so

  • Keep the directory structure unchanged and compile the libs Directory into the apk file. You can use unzip to decompress the apk file and check whether it contains the x86 library file.


Test and submit
After the compilation is successful, test on the x86 simulator ,:
After downloading and decompressing the SDK, you must create an AVD. Note that the resolution is 1280*800 and must be manually entered;

Simulator speed-up
If the simulator is slow, you can enable VT (Visualization Technology) in the BIOS and execute the following command after the system is started (Ubuntu is used as an example)

  • Sudo apt-get install kvm qemu
  • Modprobe kvm
  • Modprobe kvm-intel

Summary
Dear developer, I believe you have some knowledge about porting x86 native applications. Please take actions to start porting.

 

Reproduced in: http://blog.china.alibaba.com/article/i28331796.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.