exportedHeaders DSL does not seem to include the headers

不问归期 提交于 2019-12-11 13:11:54

问题


I am trying to make use of the "Multiple NDK Projects" feature of the experimental gradle plugin. I am using Android Studio 2.1 and gradle plugin 0.7.0 stable. The blog seems to say that the header files specified in the exportedHeaders section of the native library will be included during compilation

exportedHeaders {
                        srcDir "src"
                    }

This does not seem to work for me. Say for example I have the following folder structure, I would expect Addition.h to be available in native.cpp, ie I should be able to say

#include <Addition.h>

but only

#include "../../../../../../../Framework/Addition/src/Addition.h" 

works. Adding cppFlags to include the headers makes no difference.

Here's how some relevant files look for an example project. The example project module "app" depends on a native library module "addition" to add 2 numbers. The native library uses the new native plugin.

settings.gradle

include ':app'
include ':Addition'
project (":Addition").projectDir = new File("../../../Framework/Addition")

gradle-wrapper.properties

#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

build.gradle (:app)

apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"

        ndk {
            moduleName = 'native'
            platformVersion = 17
            toolchain "clang"
            cppFlags.addAll(['-I' + file('src/main/jni'),
                             '-I'  + file('../../../Framework/Addition')])
        }

        sources {
            main {
                jni {
                    dependencies {
                        project ':Addition' linkage 'static'
                    }
                }
            }
        }

        defaultConfig {
            applicationId "com.harkish.nativepluginexample"
            minSdkVersion.apiLevel 21
            targetSdkVersion.apiLevel 23
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
}

build.gradle (:Addition)

apply plugin: 'com.android.model.native'

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = '23.0.2'

        defaultConfig {
            minSdkVersion.apiLevel = 21
            targetSdkVersion.apiLevel = 23
            versionCode = 1
            versionName = '1.0'
        }
        ndk {
            moduleName = 'addition'
        }
        sources {
            main {
                jni {
                    source {
                        srcDir "src"
                    }
                    exportedHeaders {
                        srcDir "src"
                    }
                }
            }
        }
    }
}

Anyone solved this problem? ideas?

来源:https://stackoverflow.com/questions/37147657/exportedheaders-dsl-does-not-seem-to-include-the-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!