Android native dependencies

2019-07-11 06:18发布

Supposedly we can now define dependencies on native-only libraries, but I'm having an issue adding multiple dependencies.

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

model {
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"

        defaultConfig {
            minSdkVersion.apiLevel 11
            targetSdkVersion.apiLevel 22
            versionCode = 1
            versionName = "1.0"
        }

        sources {
            //noinspection GroovyAssignabilityCheck
            main {
                jni {
                    dependencies {
                        project ":libraw"
                        project ":libjpeg"
                    }
                }
            }
        }

        ndk {
            moduleName "rawprocessor"
            cppFlags.add("-fexceptions")
            ldLibs.add("log")
            stl "gnustl_shared"
        }
    }
}

The two libraries are com.android.model.native and they generate an .so properly.

Headers are loaded from foo, but not bar. If I swap the lines they'll load from bar but not foo. Is there a way to load multiple dependencies?

Update (Actual error messages, complete build.gradle added)

undefined reference to 'jpeg_std_error'
undefined reference to 'jpeg_CreateDecompress' 
undefined reference to 'jpeg_mem_src' 

These continue for any reference to libjpeg in the aggregate library. If I swap libjpeg to be first I get the same undefined reference to any call in the other library.

undefined reference to `open_file(char const*, long long)'
undefined reference to `recycle()'

Update 2

I just noticed that when I add the aggregate library module (the above build.gradle), the build process does not build the second library. If I comment out that library it builds both native-only libraries. I'm now starting to wonder if there's some issue due to the fact that libraw also depends on libjpeg.

0条回答
登录 后发表回答