本文介绍了将 Android Studio 与 Vuforia 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在 Window 8 上的 Android Studio 上运行 Vuforia 示例的方法

Here is how I run a Vuforia Sample on Android Studio on Window 8

  1. 下载、提取示例、删除文件 .project 和 project.properties
  2. 在 Android Studio 上:导入项目,下一步,下一步...
  3. 下载&安装安卓 NDK http://developer.android.com/tools/sdk/ndk/index.html
  4. 下载&安装 cygwin http://cygwin.com/
  5. 编辑文件 jni/Android.mk

  1. Download, extract sample, remove files .project and project.properties
  2. On Android Studio : Import project, next, next ...
  3. Download & install android NDK http://developer.android.com/tools/sdk/ndk/index.html
  4. Download & install cygwin http://cygwin.com/
  5. Edit the file jni/Android.mk

LOCAL_SRC_FILES = C:/Vuforia-sdk/build/lib/$(TARGET_ARCH_ABI)/libQCAR.soLOCAL_EXPORT_C_INCLUDES := C:/Vuforia-sdk/build/include其中 Vuforia-sdk 是您的 vuforia sdk

LOCAL_SRC_FILES = C:/Vuforia-sdk/build/lib/$(TARGET_ARCH_ABI)/libQCAR.soLOCAL_EXPORT_C_INCLUDES := C:/Vuforia-sdk/build/includewhere Vuforia-sdk is your vuforia sdk

在您的项目文件夹中打开 cmd 并执行ndk-build"

Open cmd in your project folder and do "ndk-build"

在android studio中,点击项目结构,模块,YourModuleName",Dependencies,添加jar,为我选择正确的vuforia sdk路径:

In android studio, click on project structure, modules, "YourModuleName", Dependencies, add jars, select the correct path to vuforia sdk for me it was :

C:\Vuforia-sdk\build\java\QCAR\QCAR.jar

C:\Vuforia-sdk\build\java\QCAR\QCAR.jar

构建&在 Android Studio 中运行您的项目

build & run your project in Android Studio

*不要忘记 ndk & 的 PATH 变量cygwin

*Don't forget the PATH variable for the ndk & cygwin

推荐答案

阅读我们的入门指南,了解有关设置 Java SDK、Android SDK 和 NDK 的说明:

Read our Getting Started Guide for instructions on setting up the Java SDK, Android SDK and NDK:

 https://developer.vuforia.com/resources/dev-guide/getting-started-android-native-sdk

确保您已经安装了最新版本的 Android Studio:

Make sure you have installed the latest version available of Android Studio from:

http://developer.android.com/sdk/index.html

使用 Android SDK 管理器(从 Android Studio 中)获取最新的 Android SDK 以及 Android 平台和构建工具

Use the Android SDK Manager (from within Android Studio) to get the latest Android SDK and Android Platform and Build tools

启动 Android Studio

Launch Android Studio

选择 File -> Import Project ... 并浏览到项目的根目录要打开的示例 Vuforia 项目继续进入导入向导"对话框(单击下一步"、下一步"),直到到达包含此消息的页面:

Select File - > Import Project ... and browse to the root directory of the sample Vuforia project you want to open Proceed in the Import Wizard dialog (click Next, Next) until you reach a page with this message:

或者,您可以填写下表中的实际路径图":点击编辑

"Alternatively, you can fill in the actual path map in the table below": click to edit

输入 Vuforia.jar 库的实际路径(位于您的 vuforia_install_dir/build/java/vuforia 下)

enter the actual path to the Vuforia.jar library (which is located under your vuforia_install_dir/build/java/vuforia)

在 Project 视图中,右键单击 Project 并展开视图层次结构,以便在 app > src > main 下找到 Vuforia.jar右键单击 Vuforia.jar 打开上下文菜单

In the Project view, right-click on the Project and expand the view hierarchy so to locate the Vuforia.jar under app > src > main right-click on Vuforia.jar to open the context menu

单击上下文菜单中的添加为库..."选项

click on the "Add as library..." option in the context menu

或者,如果您无法在项目层次结构中找到 Vuforia.jar:右键单击项目并选择打开模块设置"

Alternatively, if you cannot locate the Vuforia.jar in your project hierarchy: right-click on the Project and select "Open Module Settings"

选择应用"然后选择依赖项"标签

select "App" then select the "Dependencies" tab

单击+"按钮添加文件依赖项并浏览到 Vuforia.jar 文件

Click on the "+" button to Add a File Dependency and browse to the Vuforia.jar file

在你的Android Studio项目目录下的app/src/main"文件夹下创建一个名为jniLibs"的文件夹

Create a folder called "jniLibs" under the "app/src/main" folder under your Android Studio project directory

将armeabi-v7a"文件夹(包括其中的libVuforia.so文件)从vuforia_install_dir/build/lib"复制到app/src/main/jniLibs"文件夹

Copy the "armeabi-v7a" folder (including the libVuforia.so file located inside it) from the "vuforia_install_dir/build/lib" to the "app/src/main/jniLibs" folder

the resulting directory structure under your project root should be:
/app
/src
/main
/jniLibs
/armeabi-v7a
libVuforia.so

清理并重建项目

在您的设备上运行应用

这篇关于将 Android Studio 与 Vuforia 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 22:33