2010-05-02 10:35:00 RQG 阅读数 2853
  • Android手机内存管理与性能优化&JNI;、NDK编程

    JNI,从Java1.1开始,Java Native Interface(JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的代码进行交互。Android NDK 是在SDK前面又加上了“原生”二字,即Native Development Kit,因此又被Google称为“NDK”。

    2049 人正在学习 去看看 张勇

Android is the first free, open-source, and fully customizable mobile platform. Android provides a full stack including an operating system, middleware, and key mobile applications. It also contains a rich set of APIs that allows third-party developers to develop more applications. Android relies on Linux version 2.6 for core system services, such as security, memory management, process management, network stack, and driver model, and the minimum requirement for hardware is a 200MHz ARM processor. Therefore, if Android application developers want to build performance-critical portions of their apps in native code, they should build a set of cross-toolchains (compilers, linkers, etc.) that can generate native ARM binaries on Linux.

Android applications run in the Dalvik virtual machine, which limits the development of applications; however, Android official website has released a native development kit (Android NDK), which allows developing part of your applications using native-code languages such as C and C++. This is beneficial for developing certain classes of application in the terms of reusing existing codes and accelerating apps running speed. The NDK, however, only supports the ARMv5TE machine instruction set and provides stable headers for libc (the C library), libm (the Math library), and OpenGL ES (3D graphics library). If you desire an in-depth development on Android, a much more open and flexible native development tool is requested.

 

Android NDK provides toolchain source code, which can be downloaded fromhttp://android.git.kernel.org/. All we have to do is to rebuild it (to avoid troublesome compiling warnings and errors, you better to replace binutils-2.17 with binutils-2.18) and install it on Linux. To build the native development tool on Windows platform, Cygwin is highly recommended. Cygwin is a Linux-like environment for Windows. It provides a collection of tools that provide Linux-like look and functions. For Cygwin installation, please go to Cygwin websitehttp://www.cygwin.com/. During the installation, please make sure you select gcc, make, termcap, Flex, bison, gettext, gettext-devel, Texinfo, libiconv, and git. Git is a free open-source distributed version control system for downloading Android source code from http://android.git.kernel.org/. Generally, not all Android source code packages are needed. The core packages include 1) Android.platform.bionic, 2) Android.platform.build, 3) Android.platform.system.core, and 4) Android.platform.system.base. With toolchain installed and Android source code downloaded, it is time to configure our gcc compile environment. In common cases, gcc will search head files in the following paths:
$toolchain/lib/gcc/arm-eabi/4.2.1/include
$toolchain/arm-eabi/sys-include
$toolchain/arm-eabi/include
Therefore, for different development purpose, we only need to copy different head files from Android source code fold to the above paths. For example, to develop Bluetooth tools on Android, we should copy Bluetooth head files to $toolchain/lib/gcc/arm-eabi/4.2.1/include.

However, Android does not support glibc. It uses bionic Libc, which is written by Google, so we have to copy all bionic Libc head files to $toolchain/lib/gcc/arm-eabi/4.2.1/include. Bionic Libc head files are in the following paths:
bionic/libc/arch-arm/include
bionic/libc/include
bionic/libstdc++/include
bionic/libc/common
bionic/libm/include
bionic/libthread_db/include
and also copy AndroidConfig.h file from system/core/include/arch/linux-arm to $toolchain/lib/gcc/arm-eabi/4.2.1/include.

Now everything is ready but the most important thing—library files. How can we get precompiled library files? Here is a trick. As we know, Android emulator has all Android precompiled library files on it. We have to pull them from the emulator. We can use a tool like Busybox to do so following the example steps:
$adb push busybox /dev/tool/busybox
$adb shell chmod 777 /dev/ tool /busybox
$adb shell ./dev/ tool /busybox tar -cf /dev/ tool /libs.tar /system/lib
$adb pull /dev/ tool /libs.tar libs.tar
Unzip libs.tar, and copy all files to $toolchain/arm-eabi/lib. Meanwhile, please copy Makefiles, armelf.x and armelf.xsc, from build/core to it.

By now, toolchain setup is finished. Write a helloworld.c to test it.

int main(int argc, char **argv) {

printf(“Hello world!/n”);

return 0;
}

Compile it.
$ arm-eabi-gcc -nostdlib -Bdynamic -Wl,-T,armelf.x -Wl,-dynamic-linker,/system/bin/linker -include AndroidConfig.h -lc -o helloworld helloworld.c
Run it on Android emulator.
Bang! Warning: cannot find entry symbol _start; defaulting to 000082c8.
Bang! Bang! Error: Segmentation fault!

What is the problem? According to Android NDK makefile, the executable binary is dynamically linked. Therefore, crtbegin_dynamic.o and crtend.o are needed. If you could find Crtbegin_dynamic.S and crtend.S in $android_src/bionic/libc/arch-arm/bionic, you would get the answer. Use the following command to compile them.
arm-eabi-gcc -mthumb-interwork -o crtbegin_dynamic.o -c crtbegin_dynamic.S
arm-eabi-gcc -mthumb-interwork -o crtend.o -c crtend.S

Now compile your helloworld.c again.
$arm-eabi-gcc -nostdlib -Bdynamic -Wl,-T,armelf.x -Wl,-dynamic-linker,/system/bin/linker -include AndroidConfig.h -lc -o hello hello.c crtbegin_dynamic.o crtend.o
And then, push it to Android emulator and run it.
$adb push hello /dev/sample/helloworld
$adb shell chmod 777 /dev/sample/helloworld
$adb shell ./dev/sample/helloworld

See, life is wonderful now!

Reference:

http://developer.android.com/guide/index.html

http://benno.id.au/blog/

http://developer.android.com/sdk/ndk/index.html

P.S. About how to compile,run and package C programs in Android, please check this out.

2019-04-26 23:24:26 s4hana 阅读数 35
  • Android手机内存管理与性能优化&JNI;、NDK编程

    JNI,从Java1.1开始,Java Native Interface(JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的代码进行交互。Android NDK 是在SDK前面又加上了“原生”二字,即Native Development Kit,因此又被Google称为“NDK”。

    2049 人正在学习 去看看 张勇

Deploy UI5 Development Tool: Eclipse

1. Download Eclipse Package
1.1. Access the Eclipse download site.
https://www.eclipse.org/downloads/packages/
1.2. Choose the download link based on your operation system
在这里插入图片描述
1.3. Choose Download
在这里插入图片描述
1.4. When the installation package is downloaded, extract it to a directory.
在这里插入图片描述
2. Starting Eclipse Development Tool
2.1. Double-click the eclipse.exe file to run Eclipse IDE.
在这里插入图片描述
2.2. Select a directory as workspace, and choose Launch.
在这里插入图片描述
3. Configuring Eclipse Preferences
3.1. Choose the Windows > Preferences menu.
在这里插入图片描述
3.2. On the left panel, choose the Java > Installed JREs node and add the JDK.
在这里插入图片描述
3.3. On the left panel, choose the Server > Runtime Environments node and add the Tomcat.
在这里插入图片描述
4. Adding Web Server
4.1. Choose the File > New > Other menu.
在这里插入图片描述
4.2. Select the Sever > Sever wizard and choose Next.
在这里插入图片描述
4.3. Select the Server Type as Tomcat v8.0 Server, and choose Finish.
在这里插入图片描述
4.4. A server has been added.
在这里插入图片描述
5. Setting Web Server
5.1. Start the Tomcat v8.0 server.
在这里插入图片描述
5.2. Double-click the Tomcat v8.0 to edit parameters.
在这里插入图片描述
5.3. Choose Save.
6. Installing SAPUI5 Development Package
6.1. Access the SAP Development Tools website to get the link of downloading package.
https://tools.hana.ondemand.com/
6.2. Node down the link of downloading package.
在这里插入图片描述
6.3. Launch the Eclipse IDE, choose the Help > Install New Software menu.
在这里插入图片描述
6.4. Paste the text of link and press enter. And then select the UI Development Toolkit for HTML5 and choose Next.
在这里插入图片描述
6.5. Choose Next.
在这里插入图片描述
6.6. Check the I accept the terms of the license agreements radio button and choose Finish.
在这里插入图片描述
6.7. Waiting for the download to complete.
7. Testing SAPUI5 Development Environment
7.1. Right-click in the Project Explorer area and select the New > Project menu.
在这里插入图片描述
7.2. Select the SAPUI5 Application Development > Application Project and choose Next.
在这里插入图片描述
7.3. Enter the Project Name and choose Next.
在这里插入图片描述
7.4. Enter the View Name and choose Finish.
在这里插入图片描述
7.5. A test project has been created.
在这里插入图片描述
7.6. Choose the Run As > Run on Server menu.
在这里插入图片描述
7.7. Select the Server and choose Finish.
在这里插入图片描述
7.8. Application page is shown.
在这里插入图片描述
8. Sharing SAPUI5 Project to the SAP Repository
8.1. Sharing project to the SAP Repository
8.1.1. Select a project and choose Term > Share Project menu.
在这里插入图片描述
8.1.2. Select a repository type and choose Next.
在这里插入图片描述
8.1.3. Select an SAP System Connection and choose Next.
在这里插入图片描述
8.1.4. Select a Connection Type and choose Next.
在这里插入图片描述
8.1.5. Enter the corresponding parameters value and choose Next.
在这里插入图片描述
8.1.6. Enter the corresponding parameters value and choose Next.
在这里插入图片描述
8.1.7. Select the Create a New Request radio button and choose Finish.
在这里插入图片描述
8.1.8. This Project has been shared success.
在这里插入图片描述
8.2. Submitting project to the SAP Repository
8.2.1. Select a project and choose Term > Submit menu.
在这里插入图片描述
8.2.2. Select resource to submit and choose Finish.
在这里插入图片描述
8.3. Showing application in the SAP Repository
8.3.1. On the ABAP Front-End server, access the transaction: SE80.
8.3.2. Choose the Repository Browser and the BSP Application.
在这里插入图片描述
8.3.3. On the ABAP Front-End server, access the transaction: SICF.
8.3.4. Navigation to the ICF Service Node: default_host/sap/bc/ui5_ui5/sap/ztst01.
在这里插入图片描述
8.4. Testing application in the SAP Repository
8.4.1. Choose the Run As > Run on ABAP Server menu.
在这里插入图片描述
8.4.2. Enter the User ID and Password and application page is shown.
在这里插入图片描述
8.5. Cancel Sharing project to the SAP Repository
8.5.1. Select a project and choose Term > Share Project menu.
在这里插入图片描述
8.5.2. This Project doesn’t have been shared.
在这里插入图片描述

2019-08-24 10:19:44 tony2278 阅读数 1119
  • Android手机内存管理与性能优化&JNI;、NDK编程

    JNI,从Java1.1开始,Java Native Interface(JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的代码进行交互。Android NDK 是在SDK前面又加上了“原生”二字,即Native Development Kit,因此又被Google称为“NDK”。

    2049 人正在学习 去看看 张勇

 

ERROR: unable to find the development tool 'cc' in your path

 

(base) tony2278@tony2278:~$ which cc
(base) tony2278@tony2278:~$ which gcc
/usr/bin/gcc
(base) tony2278@tony2278:~$ echo $PATH
。。。。。。

已经安装了 gcc,  但Unable to find the tool cc in your path

 

Solution

sudo apt-get gcc

 

2015-08-17 16:44:00 zzpf2007 阅读数 365
  • Android手机内存管理与性能优化&JNI;、NDK编程

    JNI,从Java1.1开始,Java Native Interface(JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的代码进行交互。Android NDK 是在SDK前面又加上了“原生”二字,即Native Development Kit,因此又被Google称为“NDK”。

    2049 人正在学习 去看看 张勇

  最近在学习Android开发, 搭载了Android Studio的环境,参考书选取的是"Android Application Development For Dummies".

  上传了源代码到地址:

http://download.csdn.net/detail/zzpf2007/9015781

2010-07-27 12:22:00 zstsoft 阅读数 101
  • Android手机内存管理与性能优化&JNI;、NDK编程

    JNI,从Java1.1开始,Java Native Interface(JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的代码进行交互。Android NDK 是在SDK前面又加上了“原生”二字,即Native Development Kit,因此又被Google称为“NDK”。

    2049 人正在学习 去看看 张勇

REAL Software

 

http://realsoftware.com/

 

 

没有更多推荐了,返回首页