Android 加载串口通信读取信息时 AndroidStudio loadLibrary失败「建议收藏」

Android 加载串口通信读取信息时 AndroidStudio loadLibrary失败「建议收藏」static{ System.loadLibrary(“serial_port”); }今天想连接串口做一个新功能但是连接串口加载库的时候总是找不到serial_port库1:项目结构是这样的库文件不多说github很多Android.mk##Copyright2009CedricPriscal##LicensedundertheApacheLicense,Version2.0(the”License”);#you…

大家好,又见面了,我是你们的朋友全栈君。

static {
		System.loadLibrary("serial_port");
	}

今天想连接串口做一个新功能 但是连接串口加载库的时候总是找不到serial_port库

1:Android 加载串口通信读取信息时 AndroidStudio loadLibrary失败「建议收藏」

项目结构是这样的

 

Android 加载串口通信读取信息时 AndroidStudio loadLibrary失败「建议收藏」

 

库文件不多说 github很多

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.org/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-3

LOCAL_MODULE    := serial_port
LOCAL_SRC_FILES := SerialPort.c


#LOCAL_MODULE    := serial_port
#LOCAL_SRC_FILES := SerialPort.c
LOCAL_LDLIBS    := -llog

include $(BUILD_SHARED_LIBRARY)

但是写完Android.mk为什么还是不识别呢?

这是什么原因造成的呢?

Android 加载串口通信读取信息时 AndroidStudio loadLibrary失败「建议收藏」

要加上这句话

我项目中的库文件是build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }


        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    

    }

    dependencies {
        api fileTree(dir: 'libs', include: ['*.jar'])
        api fileTree(include: '*.jar', dir: 'libs')
        implementation 'androidx.appcompat:appcompat:1.1.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    }

    repositories {
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/159830.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • arcgis runtime for android 100.13.0 入门系列,一、初步引入与运行

    arcgis runtime for android 100.13.0 入门系列,一、初步引入与运行这是我来到csdn以来写的第一篇文章,希望能通过文字能把我的学习经过与心得分享给大家。我使用的是Kotlin来编写代码,我将默认各位具有一定的Android编程基础。言归正传,我们接下来要做的第一件事情就是使用AndroidStudio来创建一个空的新项目了我接下来的操作都是遵循arcgisandroid官方进行搭建的,读者看到的时候可能已经出了新的版本了,不过应该是小版本,arcgisandroid主体代码结构应该是不会变的,请放心阅读与搭建欢迎加入我们的QQ交流群249819194.

    2022年7月17日
    12
  • 安装LaTeX_如何正确使用

    安装LaTeX_如何正确使用使用优秀的LaTeX工具,让你写作事半功倍;MiKTex+TexStudio+JabRef

    2022年8月3日
    3
  • JAVA面试中的SSM框架基础面试题[通俗易懂]

    JAVA面试中的SSM框架基础面试题[通俗易懂]javaSSM框架基础面试题SSM(Spring+Springmvc+Mybatis)框架面试题SpringSpringmvcMybaits一些基础面试题,对刚刚步入社会的2019届毕业生有帮助

    2022年6月29日
    20
  • oracle declare多个变量_赋值

    oracle declare多个变量_赋值方法1:declare@aint=4declare@bvarchar(100)=’testsql’方法2:declare@aint,@bvarchar(100)set@a=4set@b=’sqltest’方法3:declare@aint=t,@bvarchar(100)=’sqltest’个人感觉方法3好用,减少冗余~~~…

    2022年8月20日
    16
  • qml demo分析(threading-线程任务)

    qml demo分析(threading-线程任务)

    2022年3月2日
    47
  • 常见的十大物联网操作系统介绍(物联网开发技术)

    随着物联网产业的迅猛发展,物联网设备的种类和数量也随之快速增长。据Gartner预测,到2020年全球物联网设备将超过260亿个,物联网市场规模将达到1.9万亿美元。与传统的IT领域不一样,物联网设备分布在各个不同领域,功能和形态各不相同,这对物联网提出了巨大的挑战。嵌入式系统成为关键因素物联网依靠互联网完成信息的传递,嵌入式系统的加入使得信息传递更具有专用性。在物联网出现…

    2022年4月12日
    277

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号