0

Gradle doesn't seem to be building a project I am including:

FATAL EXCEPTION: main
     Process: com.projecttango.examples.cpp.planefitting, PID: 14678 
     java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/libtango_device2.jar", zip file "/data/app/com.projecttango.examples.cpp.planefitting-1/base.apk"],nativeLibraryDirectories=[/data/app/com.projecttango.examples.cpp.planefitting-1/lib/arm, /data/app/com.projecttango.examples.cpp.planefitting-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libcpp_plane_fitting_example.so"

In my main build.gradle:

dependencies {
    compile project(':cpp_example_util')
}

My top-level build.gradle:

buildscript {

    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

The build.gradle of my external project:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 19
    buildToolsVersion "24"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

def external_lib_prefix = null
if (project.hasProperty("Tango.catkin_devel_prefix")) {
    external_lib_prefix = project.property("Tango.catkin_devel_prefix")
}

The settings.gradle:

include ':app'
include ':cpp_example_util'
project(':cpp_example_util').projectDir = new File('../cpp_example_util/app')

As shown in the error, there is no libcpp_plane_fitting_example library being built.

Mihai Bujanca
  • 4,089
  • 10
  • 43
  • 84

1 Answers1

0

Since the error reads couldn't find "libcpp_plane_fitting_example.so", it looks like there is some error with your NDK configuration, which might be why it is not being able to access the native code.

To take care of UnsatisfiedLinkError, use

static {
    System.loadLibrary("yourlibraryname");
}

and make sure that the package signature is correct.

Swayam
  • 16,294
  • 14
  • 64
  • 102
  • More info on UnsatisfiedLinkError : http://stackoverflow.com/questions/3262440/how-to-resolve-the-java-lang-unsatisfiedlinkerror-in-ndk-in-android – Swayam Oct 27 '16 at 19:15
  • `System.loadLibrary("yourlibraryname");` is causing the issue, as it's trying to load a library it can't find. I figured out that it can't find that library because it's not being built, but I can't figure out why it's not being built (project cpp_example_util) – Mihai Bujanca Oct 28 '16 at 09:18