admin管理员组

文章数量:1575999

开发串口读取项目,遇到在arm64板子上运行找不到native方法依赖

废话不多说,先上链接

链接:https://pan.baidu/s/1aE0xjR6GBmlUICsyhQDajg?pwd=jxqa 
提取码:jxqa

里面包含下面所有版本的so库

原代码位置:GitHub - cepr/android-serialport-api: Accessing serial ports for Android

下载下来因为代码太旧了,改造一番,转成studio项目

公司代码加密所以我就不传代码了,传了你们看也是乱码的,如果有需求,可以邮箱我(972649930@qq)

改造参考博客:

使用Android Studio编译so库_Bruce-Tao的博客-CSDN博客_android studio 编译so

关键修改:

Application.mk

APP_ABI := arm64-v8a armeabi-v7a x86 x86_64

Android.mk

#
# Copyright 2009 Cedric Priscal
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

TARGET_PLATFORM := android-21
APP_ALLOW_MISSING_DEPS=true
LOCAL_MODULE    := serial_port
LOCAL_SRC_FILES := SerialPort.c
LOCAL_LDLIBS    := -llog

include $(BUILD_SHARED_LIBRARY)

 其中TARGET_PLATFORM := android-21 一定要看本地的NDK环境配置。我本地的版本是

所以我配置成21

gradle.properties加上下面开关,如果没有gradle.properties文件,从其他项目拷贝一个过来也是可以的。

android.useDeprecatedNdk=true

 改造好以后,记得配置NDK的路径到环境变量,配置完要重启studio才生效(如果还是不行就重启电脑吧)

然后进入到jni目录(cd app\src\main\jni),执行命令ndk_build:

 

本文标签: 版本libserialport