C / C ++的JNI文件夹文件充满了错误 [英] C/C++ file on JNI folder filled with errors

查看:219
本文介绍了C / C ++的JNI文件夹文件充满了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去,我已经打了一个漂亮的Andr​​oid库(链接 这里 ),允许开发人员包含C / C ++的世界中的一个位图,用它玩,后来将其转换回Java的世界。

In the past, I've made a nice Android library (link here) that allows the developers to contain a bitmap within C/C++ world, play with it, and later convert it back to Java's world.

现在,我尝试导入它,我无法在Eclipse和Android的工作室这样做。

Now that I try to import it, I fail to do so on both Eclipse and Android-Studio.

有关Android的工作室,我可以理解,因为它并没有真正支持它好还,但Eclipse的,我已经做了很多次,它工作得很好。我甚至根据我收集时间的问题做了一个教程。

For Android-Studio, I can understand, since it doesn't really support it well yet, but for Eclipse, I've done it many times and it worked fine. I've even made a tutorial based on the problems I've collected over time.

不管我做什么,这是我得到:

No matter what I do, this is what I get:

很多的形式,错误的类型X不能被解决。

A lot of errors in the form of "Type 'X' could not be resolved" .

这也导致了失败,才能运行创建示例所需要的文件。

This also leads to failure in creating the files the sample needs in order to run.

在Android的工作室,我得到这个错误:

On Android Studio, I get this error:

Windows 8.1中的64位时,Eclipse 4.4.1,ADT 23.0.4.1468518,NDK r10d 64

Windows 8.1 64bit, Eclipse 4.4.1, ADT 23.0.4.1468518, NDK r10d 64bit

如何解决呢?

什么是错我的图书馆吗?

What is wrong with my library?

另外,我应该为了让Android的Studio用户导入它吗?

Also, what should I do in order to allow Android Studio users import it?

推荐答案

正如你所知道谷歌的Andr​​oid发布1.3工作室RC3的新的更新,最终我们得到C ++的支持。配置我的应用程序这种方式,一切都工作得很好。

As you know Google announced the new update of Android studio 1.3 RC3, and finally we get C++ support. I configure my app this way and everything working just fine.

这休耕步骤......

Fallow this steps...


  1. 运行的Andr​​oid 1.3工作室RC3和点击导入项目(Eclipse的ADT,摇篮等)

  2. 请参见并的这个来配置应用

  3. 项目结构(CMD +;在Mac OS中)设置摇篮版本 1 和Android插件版本 留空

  1. Run Android Studio 1.3 RC3 and click Import Project (Eclipse ADT, Gradle, etc.)
  2. See this and this to configure your app.
  3. In project structure (cmd + ; in Mac OS) set Gradle version to 1 and Android Plugin Version leave blank

然后配置你的 app.gradle 文件

 android.ndk 
 {

    moduleName = "MY_MODULE_NAME" 

    // this is your additional include files, 
    // do this if you have subfolder inside of JNI folder
    cppFlags += "-I${file("src/main/jni/myFolder/Sources")}".toString()
    cppFlags += "-I${file("src/main/jni/myFolder/Sources/Helper")}".toString()
    cppFlags += "-I${file("src/main/jni/myFolder/Sources/Image")}".toString()
    cppFlags += "-I${file("src/main/jni/myFolder/Sources/Utils")}".toString()

    // add c++ 11 support
    cppFlags += "-std=c++11"

    // your libs
    ldLibs += ["log", "jnigraphics"]

    stl     = "gnustl_static"
}


如果你想使用例如 cpufeatures ,则必须将其添加到您的JNI文件夹中。然后在 app.gradle 文件中指定用这种方法路径。

if you want to use for example cpufeatures , you must add it to your JNI folder. Then in app.gradle file specify path to it in this way .

cppFlags += "-I${file("src/main/jni/cpufeatures")}".toString()

我的 app.gradle 文件

apply plugin: 'com.android.model.application'
model {
    android {
        compileSdkVersion = 21
        buildToolsVersion = "22.0.1"

        defaultConfig.with {
            applicationId = "com.example.testapp"
            minSdkVersion.apiLevel = 17
            targetSdkVersion.apiLevel = 22
        }

    }
    android.ndk {
        moduleName = "MY_MODULE_NAME" 

        // this is your additional include files, 
        // do this if you have subfolder inside of JNI folder
        cppFlags += "-I${file("src/main/jni/myFolder/Sources")}".toString()
        cppFlags += "-I${file("src/main/jni/myFolder/Sources/Helper")}".toString()
        cppFlags += "-I${file("src/main/jni/myFolder/Sources/Image")}".toString()
        cppFlags += "-I${file("src/main/jni/myFolder/Sources/Utils")}".toString()

        // add c++ 11 support
        cppFlags += "-std=c++11"

        // your libs
        ldLibs += ["log", "jnigraphics"]

        stl     = "gnustl_static"
    }
    // jni is the default dir; config this if yours is in different directory
    android.sources {
        main {
            jni {
                source {
                    srcDirs 'src/main/jni'
                }
            }
        }
    }
    android.buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles += file('proguard-rules.txt')
        }
    }
    android.productFlavors {
        create ("arm7") {
            ndk.abiFilters += "armeabi-v7a"
        }
        create ("arm8") {
            ndk.abiFilters += "arm64-v8a"
        }
        create ("x86-32") {
            ndk.abiFilters += "x86"
        }
        // for detailed abiFilter descriptions, refer to "Supported ABIs" @
        // https://developer.android.com/ndk/guides/abis.html#sa
        // build one including all productFlavors
        create("fat")
    }
}

我的的gradle项目文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

我的 gradle-wrapper.properties 文件

#Mon Jul 20 16:12:41 AMT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-rc-1-all.zip

P.S我的名声是不是让我发表图片,对不起

P.S my reputation is not allowing me to post images, sorry

这篇关于C / C ++的JNI文件夹文件充满了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆