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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 国内外12个免费域名解析服务网站推荐

    国内外12个免费域名解析服务网站推荐一般域名使用注册商提供的域名解析服务虽然方便,但功能大多有限,特别是目前国内还会针对某些DNS服务器进行屏蔽,造成网站无法解析的情况出现,因此,使用第三方域名解析服务也是中国网站的必要选择,这里就介绍一些常见的免费域名解析服务。域名注册商提供的免费服务Godaddy :不在Godaddy注册域名,也可以使用Godaddy的域名解析服务,使用方法很简单,登录Godaddy网站后,点击“Add…

    2022年6月18日
    308
  • Group_concat介绍与例子

    Group_concat介绍与例子

    2021年10月18日
    76
  • jupyter notebook和spyder区别_命令行打开spyder

    jupyter notebook和spyder区别_命令行打开spyderPycharm、jupyterlab、jupyternotebook、python的区别Pycharm是开发工具,开发人员修改bug特别方便jupyterlab是jupyternotebook的升级版,特别友好,里面的很多插件对于你做数据分析很是方便jupyternotebook是数据分析师经常用的工具,小白学习数据分析时练习numpy、pandas就在这里进行python这个软件我没有用过,我大学学习python装的是Anaconda里面的spyderspyder刚开始接触pyt

    2022年8月28日
    3
  • nextline函数_在JAVA中Scanner中的next()和nextLine()为什么不能一起使用?

    nextline函数_在JAVA中Scanner中的next()和nextLine()为什么不能一起使用?Java输入一直是一个坑,本来一直用Scanner,但一直搞不懂换行符啥的,就用BufferReader,但前不久大疆笔试需要持续输入,早忘了Scanner怎么写,而那个场景用Scanner很好实现……就继续在这里记录一下Scanner的坑吧一、next&nextLine区别next不能得到带有空格的字符串一定要读到有效字符后才可以结束,结束条件是碰到空格…

    2022年6月2日
    38
  • BZOJ2440(全然平方数)二分+莫比乌斯容斥

    BZOJ2440(全然平方数)二分+莫比乌斯容斥

    2021年12月5日
    45
  • SAP QAS数据增长空间太快

    SAP QAS数据增长空间太快背景:我们是在一台数据库上删除另外的一台数据库上的大量数据,运用的crontab+linuxshell+rman,然后生产了大量的日志。解决方法清除以下的日志deletearchivelog.sh脚本exportORACLE_SID=QASexportORACLE_BASE=/oracleexportORACLE_HOME=/oracle/QAS/112_64/oracle/QAS/112_64/bin/rmantarget/<<EOFrun{cro

    2022年6月28日
    19

发表回复

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

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