【问题标题】:App crashes in vuforia sample projectvuforia 示例项目中的应用程序崩溃
【发布时间】:2017-07-11 16:05:15
【问题描述】:

我正在尝试运行 vuforia Imagetarget 示例项目,其中显示本机函数错误,“无法解析相应的 JNI 函数 Java_com_vuforia_samples_ImageTargets_ImageTargets_setActivityPortraitMode”。

还会出现运行时错误和应用崩溃。下面是错误日志,

07-10 12:15:50.774 11327-11327/com.vuforia.samples.ImageTargets E/Vuforia:库 libImageTargetsNative.so 无法加载 java.lang.UnsatisfiedLinkError:dlopen 失败:找不到符号“_ZN4QCAR14TrackerManager11getInstanceEv”引用通过“/data/app/com.vuforia.samples.ImageTargets-1/lib/arm/libImageTargetsNative.so”... 07-10 12:15:50.966 11327-11327/com.vuforia.samples.ImageTargets E/art: No implementation found for void com.vuforia.samples.ImageTargets.ImageTargets.setActivityPortraitMode(boolean) (tried Java_com_vuforia_samples_ImageTargets_ImageTargets_setActivityPortraitMode and Java_com_vuforia_samples_ImageTargets_ImageTargets_setActivityPortraitMode__Z) 07-10 12:15:50.968 11327-11327/com.vuforia.samples.ImageTargets E/AndroidRuntime: 致命异常: main 进程:com.vuforia.samples.ImageTargets,PID:11327 java.lang.UnsatisfiedLinkError: No implementation found for void com.vuforia.samples.ImageTargets.ImageTargets.setActivityPortraitMode(boolean) 在 com.vuforia.samples.ImageTargets.ImageTargets.setActivityPortraitMode(本机方法) 在 com.vuforia.samples.ImageTargets.ImageTargets.initApplication(ImageTargets.java:747) 在 com.vuforia.samples.ImageTargets.ImageTargets.updateApplicationStatus(ImageTargets.java:610) 在 com.vuforia.samples.ImageTargets.ImageTargets.onCreate(ImageTargets.java:373) 在 android.app.Activity.performCreate(Activity.java:6672) 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140) 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612) 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724) 在 android.app.ActivityThread.-wrap12(ActivityThread.java) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473) 在 android.os.Handler.dispatchMessage(Handler.java:102) 在 android.os.Looper.loop(Looper.java:154) 在 android.app.ActivityThread.main(ActivityThread.java:6123) 在 java.lang.reflect.Method.invoke(本机方法) 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

APP.GRADLE 文件:

apply plugin: 'com.android.application'

def VUFORIA_SDK_DIR = '../../..'
def JAR_DIR = 'build/java/vuforia'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

sourceSets.main {
    jni.srcDirs = []
    jniLibs.srcDir "src/main/libs"
}

defaultConfig {
    applicationId "com.vuforia.samples.ImageTargets"
    minSdkVersion 8
    targetSdkVersion 22
    versionCode 600
    versionName "6.0"
}

archivesBaseName = rootProject.projectDir.getName()

buildTypes {
    release {
        minifyEnabled false
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
    debug {
        minifyEnabled false
        debuggable true
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
}

task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
    println('compiling jni code with ndk-build...')
    def ndkDir = android.ndkDirectory
    if (System.properties['os.name'].toLowerCase().contains('windows')) {
        commandLine "$ndkDir/ndk-build.cmd",
                '-C', file('src/main/jni').absolutePath
                // Additional ndk-build arguments, such as NDK_DEBUG, can be provided here
    } else {
        commandLine "$ndkDir/ndk-build",
                '-C', file('src/main/jni').absolutePath
                // Additional ndk-build arguments, such as NDK_DEBUG, can be provided here
    }
}

task cleanNative(type: Exec, description: 'Clean JNI object files') {
    def ndkDir = android.ndkDirectory
    if (System.properties['os.name'].toLowerCase().contains('windows')) {
        commandLine "$ndkDir/ndk-build.cmd",
                '-C', file('src/main/jni').absolutePath
                'clean'
    } else {
        commandLine "$ndkDir/ndk-build",
                '-C', file('src/main/jni').absolutePath
                'clean'
    }
}

clean.dependsOn 'cleanNative'

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn buildNative
}
}

dependencies {
compile files('src/main/java/Vuforia.jar')
}

Android.mk 文件:

# An Android.mk file must begin with the definition of the LOCAL_PATH
# variable. It is used to locate source files in the development tree. Here
# the macro function 'my-dir' (provided by the build system) is used to return
# the path of the current directory.

LOCAL_PATH := $(call my-dir)

# The following section is used for copying the libVuforia.so prebuilt library
# into the appropriate folder (libs/armeabi and libs/armeabi-v7a respectively)
# and setting the include path for library-specific header files.

include $(CLEAR_VARS)
LOCAL_MODULE := Vuforia-prebuilt
LOCAL_SRC_FILES = ../../../../../../build/lib/$(TARGET_ARCH_ABI)/libVuforia.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../../../build/include
include $(PREBUILT_SHARED_LIBRARY)

#-----------------------------------------------------------------------------

# The CLEAR_VARS variable is provided by the build system and points to a
# special GNU Makefile that will clear many LOCAL_XXX variables for you
# (e.g. LOCAL_MODULE, LOCAL_SRC_FILES, LOCAL_STATIC_LIBRARIES, etc...),
# with the exception of LOCAL_PATH. This is needed because all build
# control files are parsed in a single GNU Make execution context where
# all variables are global.

include $(CLEAR_VARS)

# The LOCAL_MODULE variable must be defined to identify each module you
# describe in your Android.mk. The name must be *unique* and not contain
# any spaces. Note that the build system will automatically add proper
# prefix and suffix to the corresponding generated file. In other words,
# a shared library module named 'foo' will generate 'libfoo.so'.

LOCAL_MODULE := ImageTargetsNative

# Set OpenGL ES version-specific settings.
OPENGLES_LIB  := -lGLESv2
OPENGLES_DEF  := -DUSE_OPENGL_ES_2_0

# An optional set of compiler flags that will be passed when building
# C and C++ source files.
#
# The flag "-Wno-write-strings" removes warnings about deprecated conversion
#   from string constant to 'char*'.
# The flag "-Wno-psabi" removes warning about "mangling of 'va_list' has
#   changed in GCC 4.4" when compiled with certain Android NDK versions.

LOCAL_CFLAGS := -Wno-write-strings -Wno-psabi $(OPENGLES_DEF) -std=c++11

# The list of additional linker flags to be used when building your
# module. Use the "-l" prefix in front of the name of libraries you want to
# link to your module.

LOCAL_LDLIBS := \
-llog $(OPENGLES_LIB)

# The list of shared libraries this module depends on at runtime.
# This information is used at link time to embed the corresponding information
# in the generated file. Here we reference the prebuilt library defined earlier
# in this makefile.

LOCAL_SHARED_LIBRARIES := Vuforia-prebuilt

# The LOCAL_SRC_FILES variables must contain a list of C/C++ source files
# that will be built and assembled into a module. Note that you should not
# list header file and included files here because the build system will
# compute dependencies automatically for you, just list the source files
# that will be passed directly to a compiler.

LOCAL_SRC_FILES := ImageTargets.cpp SampleAppRenderer.cpp SampleUtils.cpp 
Texture.cpp

# By default, ARM target binaries will be generated in 'thumb' mode, where
# each instruction is 16-bit wide. You can set this variable to 'arm' to
# set the generation of the module's object files to 'arm' (32-bit
# instructions) mode, resulting in potentially faster yet somewhat larger
# binary code.

LOCAL_ARM_MODE := arm

# BUILD_SHARED_LIBRARY is a variable provided by the build system that
# points to a GNU Makefile script being in charge of collecting all the
# information you have defined in LOCAL_XXX variables since the latest
# 'include $(CLEAR_VARS)' statement, determining what and how to build.
# Replace it with the statement BUILD_STATIC_LIBRARY to generate a static
# library instead.

include $(BUILD_SHARED_LIBRARY)

Application.mk 文件:

# Build both ARMv5TE and ARMv7-A machine code.

APP_ABI := armeabi-v7a

# Set target Android API level to the application's minimum SDK version.

APP_PLATFORM := android-14

# This optional variable can be defined to either 'release' or
# 'debug'. This is used to alter the optimization level when
# building your application's modules.
#
# A 'release' mode is the default, and will generate highly
# optimized binaries. The 'debug' mode will generate un-optimized
# binaries which are much easier to debug.
#
# Note that it is possible to debug both 'release' and 'debug'
# binaries, but the 'release' builds tend to provide less information
# during debugging sessions: some variables are optimized out and
# can't be inspected, code re-ordering can make stepping through
# the code difficult, stack traces may not be reliable, etc... 

# APP_OPTIM := release OR debug

libImageTargetsNative.so 和 libVuforia.so 的路径是 app/src/main/jniLibs。

所有mk文件、cpp文件和头文件都在jni文件夹下。

请告诉我是我遗漏了什么还是我的代码中有任何错误。 提前致谢。

【问题讨论】:

    标签: android android-ndk augmented-reality vuforia


    【解决方案1】:

    尝试使用旧版本的 Unity。每次 Unity 发布更新时,我的 vuforia 项目都会停止工作,所以我正在使用 Unity 5.2 并且不再更新

    【讨论】:

      猜你喜欢
      • 2018-12-23
      • 1970-01-01
      • 2011-03-01
      • 2023-03-31
      • 1970-01-01
      • 2014-05-25
      • 2011-08-29
      • 2023-03-15
      • 1970-01-01
      相关资源
      最近更新 更多