在 Android Studio 中使用OpenCV所遇到问题

Android Studio 中使用OpenCV所遇到问题

 

一、关于如何生成.h文件

网上查了很多资料,大部分都是说需要切换到build/intermediates/classes/debug/文件目下,然后怎么搞怎么搞,其实不必要,也不用配置-classpath的环境变量。

直接从 Terminal 里切换进入 / src / main / java 目录,执行javah命令,然后 包名 + 类名,生成的.h文件便会在该路径下,如图:

/

 

 

 

二、遇到错误:

 

?
1
2
3
Error:Execution failed for task ':app:compileDebugNdk' .
> com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: Process 'command '
C:\Tools\adt-bundle-windows-x86_64- 20140702 \android-ndk-r10c\ndk-build.cmd '' finished with non-zero exit value 2


 

1. May be this is known NDK bug. Try to add empty .c file to your jni dir (like empty.c).

2. Try adding this to the build.gradle file:
 

?
1
2
3
4
5
6
7
8
android {
     ...
     sourceSets.main {
        jni.srcDirs = [ ]
     }
 
 
}

注:可能是NDK的Bug,在编译时,还必须在jni目录生成一个空的.c文件。

 

 

 

三、遇到错误

 

?
1
Error:Error: NDK integration is deprecated in the current plugin.  Consider trying the new experimental plugin.  For details, see http: //tools.android.com/tech-docs/new-build-system/gradle-experimental.  Set android.useDeprecatedNdk=true in gradle.properties to continue using the current NDK integration.

 

http://stackoverflow.com/questions/31979965/after-updating-android-studio-to-version-1-3-0-i-am-getting-ndk-integration-is

 

 

Here is how to solve this issue :

  1. add gradle.properties file to root folder of your project
  2. add 'android.useDeprecatedNdk=true' to gradle.properties file

    Here is my gradle.properties :

     

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    # Project-wide Gradle settings.
     
    # IDE (e.g. Android Studio) users:
    # Gradle settings configured through the IDE *will override*
    # any settings specified in this file.
     
    # For more details on how to configure your build environment visit
    # http: //www.gradle.org/docs/current/userguide/build_environment.html
     
    # Specifies the JVM arguments used for the daemon process.
    # The setting is particularly useful for tweaking memory settings.
    # Default value: -Xmx10248m -XX:MaxPermSize=256m
    # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF- 8
     
    # When configured, Gradle will run in incubating parallel mode.
    # This option should only be used with decoupled projects. More details, visit
    # http: //www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
    # org.gradle.parallel= true
     
    android.useDeprecatedNdk= true


     

    And add it to root of your project :

    /

    And rebuild your project.

     

    四、遇到错误

     

    ?
    1
    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command ' C:Program FilesJavajdk1. 8 .0_60injava.exe '' finished with non-zero exit value 2

     

    导致原因:项目中出现了重复的依赖。删除依赖项便可很容易地解决该问题。

     

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值