Android Studio does not see headers ... Gradle !!!!!!

2,460 views
Skip to first unread message

Денис Котов

unread,
Jul 27, 2015, 2:43:07 PM7/27/15
to adt-dev
I have some trouble! My trouble case is that the gradle build tool can't find header file:


buildscript {
    repositories
{
        maven
{ url 'https://maven.fabric.io/public' }
   
}

    dependencies
{
        classpath
'io.fabric.tools:gradle:1.+'
    }
}
apply
plugin: 'com.android.model.application'
//apply plugin: 'io.fabric'

model {
    android
{
        compileSdkVersion
= 22
        buildToolsVersion = "22.0.1"

        defaultConfig.with {
            applicationId
= "com.collosteam.usbvideorecorder"
            minSdkVersion.apiLevel = 18
            targetSdkVersion.apiLevel = 22
            versionCode = 1
            versionName = "1.0"
        }
   
}

    android
.ndk {
        moduleName
= "webcam_lib"
        cppFlags += "-I${file("src/main/jni/UVCCamera")}".toString()
        cppFlags
+= "-I${file("src/main/jni/libjpeg")}".toString()
        cppFlags
+= "-I${file("src/main/jni/libusb")}".toString()
        cppFlags
+= "-I${file("src/main/jni/libuvc")}".toString()

       
//ldFlags += "-L/src/main/jni/libuvc/include/libuvc"
        //ldLibs += "usb"

        // CFlags is configured in similiar way as cppFlags
        ldLibs    += "-L${file("src/main/jni/libuvc/include/libuvc")}".toString()
       
CFlags    +=  "-I${file("-std=c11 -I${project.buildDir}/../src/main/jni/libuvc/include/libuvc")}".toString()
       
// CFlags    += "-I${file("src/main/jni/libuvc/include/libuvc")}".toString()
        // CFlags    += "-I${file("src/main/jni/native_app_glue")}".toString()
        // CFlags    += "-I${file("src/main/jni/native_app_glue")}".toString()
        // CFlags    += "-I${file("src/main/jni/native_app_glue")}".toString()

        ldLibs += ["android", "EGL", "GLESv2", "log"]
        stl
= "stlport_static"
    }

    android
.sources {
       
main {
            java
{
                source
{
                    srcDirs
'src/main/java'
                }
           
}
            jni
{
                source
{
                    srcDirs
'src/main/jni'
                }
           
}
       
}
   
}

    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("all")
   
}

    android
.buildTypes {
        release
{
            isMinifyEnabled
= false
            //proguardFiles += getDefaultProguardFile('proguard-android.txt')
            proguardFiles += file('proguard-rules.pro')
       
}
   
}
}

dependencies
{
    compile fileTree
(dir: 'libs', include: ['*.jar'])
    compile
'com.android.support:appcompat-v7:22.2.0'
    //compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
    //    transitive = true;
    //}
}

Error:(37, 27) libuvc/libuvc.h: No such file or directory - i had from studio errors, as you see the trouble is the header path is absence. I'm googling and found that standard android tools not supporting sets of header path. How can I resolve it ?

Steven Winston

unread,
Jul 28, 2015, 7:13:36 PM7/28/15
to adt-dev
I've had success using the -I cppFlags and CFlags.  I've noticed that currently setting CFlags doesn't also set cppFlags.  So try doing this:
CFlags += cppFlags
Then you should have your expected behavior.

George Metaxas

unread,
Jul 29, 2015, 11:17:15 AM7/29/15
to adt-dev, redr...@gmail.com
Hello,

I think that the problem is in this line:

CFlags    +=  "-I${file("-std=c11 -I${project.buildDir}/../src/main/jni/libuvc/include/libuvc")}".toString()

It should be something like this:

CFlags
   +=  ["-I${file("src/main/jni/libuvc/include/libuvc")}", "-std=c++11"]


Денис Котов

unread,
Aug 9, 2015, 4:07:11 PM8/9/15
to adt-dev

Yes, it's helpful !!!!! Thanks, but how can I use existing *(Android).mk files. Problem is that I have project on NDK that consist of some modules that have own *.mk file. In your solution, I'll have only one module that named is :
android.ndk {
    moduleName = "some_name"
   
.......
}
// But I need something like this
android
.ndk {   

moduleName0 = "some_name0"
/* some path to libraries 0 */
moduleName1 = "some_name1"
    /* some path to libraries 1 */
    moduleName2 = "some_name2"
    /* some path to libraries 2 */
    moduleName3 = "some_name3"
    /* some path to libraries 3 */
.......
    moduleNameN = "some_nameN"
    /* some path to libraries N */
}

But I need to compile project then existed modules of *.so files add to java by LoadLibrary ... All that in one project. How can I do this ?
My project on the screenshoot.


среда, 29 июля 2015 г., 2:13:36 UTC+3 пользователь Steven Winston написал:

Денис Котов

unread,
Aug 9, 2015, 4:14:07 PM8/9/15
to adt-dev

More wrapped my project:


You'll see that in an jni folder more then one directory, in all that directories it has *.mk file for build. But groovy not supported that information. In this case how can I resolve it ?


среда, 29 июля 2015 г., 2:13:36 UTC+3 пользователь Steven Winston написал:
I've had success using the -I cppFlags and CFlags.  I've noticed that currently setting CFlags doesn't also set cppFlags.  So try doing this:

Ignas Brašiškis

unread,
Aug 17, 2015, 11:52:04 AM8/17/15
to adt-dev
No it has no support for custom makefile.

Known Limitations

  • There’s no support for NDK-only modules. The only supported project types are hybrid app projects and hybrid Library Projects.

  • Consumed Library project don’t impact compilation of jni code in the consuming project (ie the AAR so files are simply packaged in the APK)

  • No support for creating and depending on static libraries

  • No support for using a NDK modules like cpu_features

  • No support for integrating external build systems.

Reply all
Reply to author
Forward
0 new messages