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


相关推荐

  • Eclipse断点调试

    Eclipse断点调试作为开发人员,掌握开发环境下的调试技巧十分有必要。去年就想把关于Eclipse断点调试总结下了,由于对时间的掌控程度仍需极大提高,结果拖到今年才写了此篇博文。关于java调试技术还有很多,如JavaDebugInterface等,依据具体项目的需要,还有很多值得去研究和学习的。该博文仅就Eclipse断点调试技巧做下总结,不足够的地方还请大牛们指点。1 Debug视图1.1线程堆栈

    2022年5月21日
    93
  • 七、springboot整合flowable(工作流)

    七、springboot整合flowable(工作流)springboot整合flowable(工作流)简介Flowable适用于开发人员,系统管理员和业务用户的紧凑且高效的工作流程和业务流程管理(BPM)平台。Flowable的发布包里包含了大部分源码,以JAR文件方式提供。Flowable的源码也可以通过以下链接获得:https://github.com/flowable/flowable-engine准备工作pom….

    2022年5月21日
    92
  • c# 递归算法

    c# 递归算法c#题目如下:要求输出:1,2,3,5,8,13,21,34,55,89写法一:publicclassMyClass{ publicstaticvoidMain() { int[]cSu

    2022年7月3日
    32
  • IDEA热部署设置

    IDEA热部署设置转载位置:https://blog.csdn.net/nihao12323432/article/details/82664601

    2022年6月13日
    33
  • J2ME开发站点资源「建议收藏」

    J2ME开发站点资源「建议收藏」英文站点,英文好的开发者应该收藏的站点。SUNJ2MEWebSite:http://java.sun.com/j2me/诺基亚开发论坛:http://discussion.forum.nokia.com/forum/IBMalphaworks:http://alphaworks.ibm.com/wirelessIBM新兴技术资源网站,这里有各种最新的技术,当然也有非常丰富的J2ME开发资

    2022年7月27日
    3
  • PyCharm – 自动缩进代码 (Auto-Indent Lines)

    PyCharm – 自动缩进代码 (Auto-Indent Lines)PyCharm-自动缩进代码(Auto-IndentLines)1.Ctrl+A全选代码。2.Code->Auto-IndentLines自动缩进快捷键Ctrl+Alt+I。Referenceshttps://yongqiang.blog.csdn.net/

    2025年7月7日
    2

发表回复

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

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