1 下载Android Studio

https://developer.android.com/studio/archive?hl=zh-cn

2 安装Android Studio

安装完成,下载SDK NDK LLIB  Cmake

FIle-Setting

3  开始建立工程使用

4 配置

CMakeLists.txt

1 包括三个三方库test1.so test.so gnustl_shared.so

2 加入opencv的支持

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html # Sets the minimum version of CMake required to build the native library. cmake_minimum_required(VERSION 3.4.) #step1 ##################### OpenCV 环境 ############################
#参考https://www.jianshu.com/p/6e16c0429044
#设置OpenCV-android-sdk路径
set(OpenCV_STATIC ON)
set(OpenCV_DIR C:/software/opencv-4.0.-android-sdk/OpenCV-android-sdk/sdk/native/jni ) find_package(OpenCV REQUIRED )
if(OpenCV_FOUND)
include_directories(${OpenCV_INCLUDE_DIRS})
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
else(OpenCV_FOUND)
message(FATAL_ERROR "OpenCV library not found")
endif(OpenCV_FOUND) #set(OpenCV_STATIC ON)
#set( OpenCV_DIR C:/software/opencv-3.4.-android-sdk/OpenCV-android-sdk/sdk/native/jni )
#find_package (OpenCV REQUIRED)
#
#target_link_libraries(native-lib ${OpenCV_LIBS}) #step2 设置so库路径
#参考 https://blog.csdn.net/carryWorld/article/details/75026171
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include)
set(jnilibs "${CMAKE_SOURCE_DIR}/src/main/jniLibs")
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${jnilibs}/${ANDROID_ABI}) # ###################### 项目原生模块 ###########################
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK. add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp) #step3 加入共享库
add_library(test1 SHARED IMPORTED)
add_library(test2 SHARED IMPORTED)
add_library(gnustl_shared SHARED IMPORTED) # Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build. find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log) # Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries. message($CMAKE_SOURCE_DIR)
set_target_properties(test1
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libtest1.so) set_target_properties(test2
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libtest2.so) set_target_properties(gnustl_shared
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libgnustl_shared.so) target_link_libraries( # Specifies the target library.
native-lib
${OpenCV_LIBS}
jnigraphics
log
test1
test2
gnustl_shared
# Links the target library to the log library
# included in the NDK.
${log-lib})

5 开始编译

Android Studio + opencv开发配置的更多相关文章

  1. Google Android Studio Kotlin 开发环境配置

    Google 近日开发者大会宣布Kotlin成为Android开发的第一级语言,即Android官方开发语言,可见Google对Kotlin的重视,本文就介绍一下Android Studio下的Kot ...

  2. Android Studio安装、配置教程全 - 安卓开发环境的配置手册

    Android Studio的安装.配置 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) 一 Downloa ...

  3. Android Studio JNI开发入门教程

    Android Studio JNI开发入门教程 2016-08-29 14:38 3269人阅读 评论(0) 收藏 举报  分类: JNI(3)    目录(?)[+]   概述 在Andorid ...

  4. 【转】Android studio安装与配置

    Android studio安装与配置 1.首先下载Android studio安装包,可以从http://www.android-studio.org/下载最新版本,这里采用3.0版本进行演示,对应 ...

  5. Android Studio经常使用配置及使用技巧(二)

    在<Android Studio经常使用配置及使用技巧(一)>中具体描写叙述了Android Studio的project结构和打开开源project的一些配置方法.本篇将从我个人的使用情 ...

  6. Android Studio NDK环境配置

    本文参考:Android Studio NDK环境配置及JNI使用方法:http://blog.csdn.net/tongseng/article/details/53005123 并添加自己的实践: ...

  7. Android studio 安装与配置【Android学习入门】

    终于下定决心认真学习Android开发了. 之前在很多平台看到很多大牛们学习Android的经验和心得,纸上得来终觉浅. 这里推荐stormzhang老师总结的Android学习之路. 为了防止电脑卡 ...

  8. Mac下Android studio 之NDK配置教程(一)

    Mac下Android studio 之NDK配置教程(一) 1.概述 近期项目全线转移到Mac下使用使用Android studio开发. 遇到关键代码封装到 ***native***层,此时在wi ...

  9. 【Android】Android Studio NDK 开发

    Android Studio NDK 开发 记录在Android Studio中NDK简单开发的步骤 用到的Android Studio版本为3.5. 配置NDK 下载NDK 一般在SDK下已经有自带 ...

随机推荐

  1. windows创建虚拟环境

    mkvirtualenv --no-site-packages --python=C:\Python36\python.exe MyCrawler

  2. rds - mysql修改存储过程/函数的方式

    rds 不支持账户A 给账户B 创建授权存储过程,只能是当前登录账户给自己创建,要登陆对应账户删除原有存储过程重新创建即为修改. 例子如下: 先登陆新账号然后执行如下sql语句即可: DROP PRO ...

  3. 转载_fread函数详解

    fread函数详解 函数原型: size_t   fread(   void   *buffer,   size_t   size,   size_t   count,   FILE   *strea ...

  4. Linux运维技术之scp命令使用

    命令格式: scp -P 8031  -r 路径1 路径2 命令解释, 其中-P中的P一定要大写,小写不行(这个也是问题的关键,这个大小写耽搁了好长时间) -P 2424表示更改SSH端口后的端口,如 ...

  5. zabbix--邮件告警报错“Support for SMTP authentication was not compiled in”

    zabbix 邮件告警报错“Support for SMTP authentication was not compiled in” 邮件报警失败:Support for SMTP authentic ...

  6. Codeforces A. Kyoya and Colored Balls(分步组合)

    题目描述: Kyoya and Colored Balls time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  7. Echo团队 对 待就业六人组 和 SkyReach 的Beta产品测试报告

    班级:软件工程1916|W 作业:Beta阶段团队项目互评 团队名称:Echo 目录 对待就业六人组的Beta产品测试报告 对SkyReach的Beta产品测试报告 对待就业六人组的Beta产品测试报 ...

  8. wordpress角色权限汇总

    我们在用wordpress开发的时候有时候需要设置不同的用户组及权限,具体有哪些角色权限呢?随ytkah一起来看看吧.WordPress使用了角色的概念,旨在让站点所有者能够控制用户在站点中可以做什么 ...

  9. SSH框架学习中遇到的问题

    在web.xml中配置struts2过滤器时,struts2 2.5之前的版本有ng,而2.5之后没有ng,如图 还有要注意web.xml的版本约束,之前一直遇到问题,后来在网上才发现原来时web的版 ...

  10. oc语言源代码

    ? https://opensource.apple.com/source/objc4/objc4-493.9/runtime/