Difference between revisions of "Template:FriendlyThings Installation Guide"
(updated by API) |
(→快速使用入门) |
||
Line 1: | Line 1: | ||
− | == | + | ==Quick Start== |
− | === | + | ===Step 1 Include libfriendlyarm-things.so in APP=== |
− | + | Clone the following library locally: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
git clone https://github.com/friendlyarm/friendlythings-sdk | git clone https://github.com/friendlyarm/friendlythings-sdk | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | 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):<br /> | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
YourProject/ | YourProject/ | ||
Line 26: | Line 26: | ||
│ │ └── WatchDogEnum.java | │ │ └── WatchDogEnum.java | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | Import the following components and the major APIs are included in the HardwareControler.java file: | |
<syntaxhighlight lang="java"> | <syntaxhighlight lang="java"> | ||
import com.friendlyarm.FriendlyThings.HardwareControler; | import com.friendlyarm.FriendlyThings.HardwareControler; |
Revision as of 15:23, 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 (第2步) 让你的app拥有system权限
你的app需要拥有system权限,才能访问硬件资源;
请参考下面的方法修改你 app 的 AndroidManifest.xml 和 Android.mk这两个文件;
并且最好将你的app放到Android源码中去编译,这一步不是必需的,但是建议这么做,如果你的app在外部编译,你需要对apk进行签名才能让你的app拥有system权限(新手不太建议,过程比较繁琐)。
1.2.1 修改AndroidManifest.xml
在应用程序的AndroidManifest.xml中的manifest节点中加入以下属性:
android:sharedUserId="android.uid.system"
1.2.2 修改Android.mk
编写一个Android.mk文件(最简单的方法就是拷贝示例中的Android.mk文件),修改Android.mk文件,加入LOCAL_CERTIFICATE := platform这一行:
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_PACKAGE_NAME := 你的项目名 LOCAL_CERTIFICATE := platform LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := -lfriendlyarm-hardware include $(BUILD_PACKAGE)
1.3 (最后1步) 在 Android源代码中编译你的app
先在 Android源代码根目录调用 setenv.sh 导出环境变量,然后进入你的 app 目录,使用mm命令编译;
例子:编译 GPIO_LED_Demo,以RK3399平台为例:
cd rk3399-android-8.1 . setenv.sh cd vendor/friendlyelec/apps/GPIO_LED_Demo mm