Android Studio + OpenCV + Tess2

引用来源

OpenCV & Tesseract: Android Computer Vision for Dummies
在Android Studio中安装OpenCV mac环境/Linux环境

趟过的坑

列表如下:
  1. IOException: error=2, No such file or directory ,cannot run program {/Users/leon/Library/Android/sdk/ndk-bundle/}ndk-build… 把括号删掉!!
  1. 参考Caused by: java.io.IOException: error=2, No such file or directory
  1. 现在(2019)添加JNI 支持应该用Android.mk 和Application.mk 的方式(ndk-build 方式)。
  1. 参考 Link Gradle to your native library
    Once you link Gradle to a native project, Android Studio updates the Project pane to show your source files and native libraries in the cpp group, and your external build scripts in the External Build Files group.
  1. The tool javah.exe was removed in Java 10. See below

javah missing after JDK install

javah missing after JDK install
javah has been superseded by the -h option added to javac in JDK 8.

Motivation

The tool has been superseded by superior functionality in javac, added in JDK 8 (JDK-7150368). This functionality provides the ability to write native header files at the time that Java source code is compiled, thereby eliminating the need for a separate tool.

Focusing on the support provided by javac eliminates the need to upgrade javah to support recent new paradigms, such as API access via the Compiler API in javax.tools.*, or the new java.util.spi.ToolProvider SPI added in JDK 9.

Process ‘command ‘PATHTONDK/ndk-build’’ finished with non-zero exit value 2"

Run this command: <ndk_build_path> -C <jni_path> NDK_OUT= all NDK_DEBUG=1
to see what’s exactly going wrong

==Error: Android NDK: android-9 is unsupported. Using minimum supported version android-16. ==

  • Turned out it’s in the Application.mk file which blindly copied from someone’s blog…like the following:
    APP_PLATFORM := android-9

==/Users/leon/Library/Android/sdk/ndk-bundle/build/core/setup-toolchain.mk:52: *** Android NDK: Invalid NDK_TOOLCHAIN_VERSION value: 4.9. GCC is no longer supported. ==

  • The same reason as above
[Solution] How to switch to clang

Clang Migration Notes

  • For ndk-build, remove lines setting NDK_TOOLCHAIN or NDK_TOOLCHAIN_VERSION.
  • For cmake, remove lines setting ANDROID_TOOLCHAIN.
  • For standalone toolchains, use the clang/clang++ binaries instead of gcc/g++.
  • For other build systems, ask the owners of that build system.

Configure your build

Configure your build

Gradle and the Android plugin run independent of Android Studio. This means that you can build your Android apps from within Android Studio, the command line on your machine, or on machines where Android Studio is not installed (such as continuous integration servers).

Getting Started with the NDK

Getting Started with the NDK

Link Gradle to your native library by providing a path to your CMake or ndk-build script file. Gradle uses the build script to import source code into your Android Studio project and package your native library (the SO file) into the APK.

Note: If your existing project uses the deprecated ndkCompile tool, you should open your build.properties file and remove the following line of code before configuring Gradle to use CMake or ndk-build:

// Remove this line
android.useDeprecatedNdk = true

Add C and C++ code to Your project

Add C and C++ code to Your project
Migrate from ndkCompile

终极问题

ALL problems come from by simply copying the critical files directly from someone’s blog…OpenCV & Tesseract: Android Computer Vision for Dummies

Error: Your project contains C++ files but it is not using a supported native build system [closed]
android.useDeprecatedNdk=true is no longer supported

Deprecated NDK is no longer supported. To avoid that error remove android.useDeprecatedNdk=true and do not make any white space in the Project Directory. If errors come again then edit the build.gradle(Module:app) below buildTypes block and add those line like below:

 buildTypes {
    release {
       ......................
    }
}
sourceSets { main { jni.srcDirs = ['src/main/jni/','src/main/jniLibs/'] } }
externalNativeBuild {
    ndkBuild {
        path 'build/intermediates/ndk/debug/Android.mk'
    }
}

Finally Worked!!

Process ‘command ‘D:\SDK\ndk-bundle/ndk-build.cmd’’ finished with non-zero exit value 2 #358

NDK 17 does not support target architectures armeabi and mips anymore…as pointed out in #277
So if you want to use NDK17, remove entries in libuvccamera\src\main\jni\Application.mk
Change:
APP_ABI := armeabi armeabi-v7a x86 mips
to
APP_ABI := armeabi-v7a x86

Android Studio failed build NDK project non-zero exit value

This is known problem of Android Studio, caused by very limited support of NDK-enabled projects. Answering to your question: yes, Android Studio now run ndk-build on its own, but it ignore existing Android.mk and generate one on the fly (and do it wrong for any non-trivial NDK-enabled project). Practically, the best way to fix this is to disable Android Studio’s limited NDK support and call ndk-build from gradle script. Here I’ve described it more detailed and how to get it fixed.

Android NDK Support Version Limited

Android 2.3 (android-9) is no longer supported. The minimum API level target in the NDK is now Android 4.0 (android-9). If your APP_PLATFORM is set lower than android-14, android-14 is used instead.

WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion in /home/user/MyApp/AndroidManifest.xml

Check your jni/Application.mk
You should have following line:-
APP_PLATFORM := android-14
If you do not have that line then version of your SDK is taken from project.properties files.

生成一个适合你的列表

  • 项目
    • 项目
      • 项目
  1. 项目1
  2. 项目2
  3. 项目3
  • 计划任务
  • 完成任务

SmartyPants

SmartyPants将ASCII标点字符转换为“智能”印刷标点HTML实体。例如:

TYPEASCIIHTML
Single backticks'Isn't this fun?'‘Isn’t this fun?’
Quotes"Isn't this fun?"“Isn’t this fun?”
Dashes-- is en-dash, --- is em-dash– is en-dash, — is em-dash

新的甘特图功能,丰富你的文章

Mon 06 Mon 13 Mon 20 已完成 进行中 计划一 计划二 现有任务 Adding GANTT diagram functionality to mermaid
  • 关于 甘特图 语法,参考 [这儿][2],

UML 图表

可以使用UML图表进行渲染。 Mermaid. 例如下面产生的一个序列图::

张三 李四 王五 你好!李四, 最近怎么样? 你最近怎么样,王五? 我很好,谢谢! 我很好,谢谢! 李四想了很长时间, 文字太长了 不适合放在一行. 打量着王五... 很好... 王五, 你怎么样? 张三 李四 王五

这将产生一个流程图。:

链接
长方形
圆角长方形
菱形
  • 关于 Mermaid 语法,参考 [这儿][3],

FLowchart流程图

我们依旧会支持flowchart的流程图:

Created with Raphaël 2.2.0 开始 我的操作 确认? 结束 yes no
  • 关于 Flowchart流程图 语法,参考 [这儿][4].
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值