Difference between revisions of "Template:FriendlyThings Installation Guide"
(→快速使用入门) |
(→Quick Start) |
||
Line 1: | Line 1: | ||
==Quick Start== | ==Quick Start== | ||
− | ===Step 1 Include libfriendlyarm-things.so in APP=== | + | ===Step 1: Include libfriendlyarm-things.so in APP=== |
Clone the following library locally: | Clone the following library locally: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 34: | Line 34: | ||
import com.friendlyarm.FriendlyThings.BoardType; | import com.friendlyarm.FriendlyThings.BoardType; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | ===Step 2: Give APP System Right=== |
− | + | Your app needs the system right to access hardware resources;<br /> | |
− | + | Give your app the system right by making changes in the AndroidManifest.xml file and the Android.mk file;<br /> | |
− | + | It is better to include your app in your Android source code and compile them together. If your app is not compiled together with your Android source code you have to go through tedious steps to compile your app and sign your app to give it the system right.<br /> | |
− | ==== | + | ====Modify AndroidManifest.xml==== |
− | + | Add the following line in the manifest node in the AndroidManifest.xml file: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
android:sharedUserId="android.uid.system" | android:sharedUserId="android.uid.system" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | ==== | + | ====Modify Android.mk==== |
− | + | Create an Android.mk file(the simplest way is to copy a sample Android.mk file), modify the Android.mk file by adding a line LOCAL_CERTIFICATE := platform : | |
<syntaxhighlight lang="java"> | <syntaxhighlight lang="java"> | ||
LOCAL_PATH:= $(call my-dir) | LOCAL_PATH:= $(call my-dir) | ||
Line 51: | Line 51: | ||
LOCAL_SRC_FILES := $(call all-subdir-java-files) | LOCAL_SRC_FILES := $(call all-subdir-java-files) | ||
− | LOCAL_PACKAGE_NAME := | + | LOCAL_PACKAGE_NAME := Project Name |
LOCAL_CERTIFICATE := platform | LOCAL_CERTIFICATE := platform | ||
Line 59: | Line 59: | ||
include $(BUILD_PACKAGE) | include $(BUILD_PACKAGE) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | ===Final Step: Compile Your APP Together with Android Source Code=== |
先在 Android源代码根目录调用 setenv.sh 导出环境变量,然后进入你的 app 目录,使用mm命令编译; <br /> | 先在 Android源代码根目录调用 setenv.sh 导出环境变量,然后进入你的 app 目录,使用mm命令编译; <br /> | ||
例子:编译 GPIO_LED_Demo,以RK3399平台为例: <br /> | 例子:编译 GPIO_LED_Demo,以RK3399平台为例: <br /> |
Revision as of 15:38, 28 December 2018
Contents
1 Quick Start
1.1 Step 1: Include libfriendlyarm-things.so in APP
Clone the following library locally:
git clone https://github.com/friendlyarm/friendlythings-sdk
Copy all the files under the libs directory to your working directory and create a "com/friendlyarm" directory in your Android project's src directory, copy the whole "java/FriendlyThings" to your newly created "com/friendlyarm" directory. The whole project directory will look like this(Note:AndroidStudio's project may be a little bit different):
YourProject/
├── AndroidManifest.xml
├── libs
│ ├── arm64-v8a
│ │ └── libfriendlyarm-things.so
│ └── armeabi
│ └── libfriendlyarm-things.so
├── src
│ └── com
│ └── friendlyarm
│ ├── FriendlyThings
│ │ ├── BoardType.java
│ │ ├── FileCtlEnum.java
│ │ ├── GPIOEnum.java
│ │ ├── HardwareControler.java
│ │ ├── SPIEnum.java
│ │ ├── SPI.java
│ │ └── WatchDogEnum.java
Import the following components and the major APIs are included in the HardwareControler.java file:
import com.friendlyarm.FriendlyThings.HardwareControler; import com.friendlyarm.FriendlyThings.SPIEnum; import com.friendlyarm.FriendlyThings.GPIOEnum; import com.friendlyarm.FriendlyThings.FileCtlEnum; import com.friendlyarm.FriendlyThings.BoardType;
1.2 Step 2: Give APP System Right
Your app needs the system right to access hardware resources;
Give your app the system right by making changes in the AndroidManifest.xml file and the Android.mk file;
It is better to include your app in your Android source code and compile them together. If your app is not compiled together with your Android source code you have to go through tedious steps to compile your app and sign your app to give it the system right.
1.2.1 Modify AndroidManifest.xml
Add the following line in the manifest node in the AndroidManifest.xml file:
android:sharedUserId="android.uid.system"
1.2.2 Modify Android.mk
Create an Android.mk file(the simplest way is to copy a sample Android.mk file), modify the Android.mk file by adding a line LOCAL_CERTIFICATE := platform :
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_PACKAGE_NAME := Project Name LOCAL_CERTIFICATE := platform LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := -lfriendlyarm-hardware include $(BUILD_PACKAGE)
1.3 Final Step: Compile Your APP Together with Android Source Code
先在 Android源代码根目录调用 setenv.sh 导出环境变量,然后进入你的 app 目录,使用mm命令编译;
例子:编译 GPIO_LED_Demo,以RK3399平台为例:
cd rk3399-android-8.1 . setenv.sh cd vendor/friendlyelec/apps/GPIO_LED_Demo mm