Getting Started with Vuforia for Android Development 开始使用Vuforia进行Android开发

来源:互联网 发布:mac上好用的office软件 编辑:程序博客网 时间:2024/06/02 02:25

Getting Started with Vuforia for Android Development

  • Setting Up the Android Development Environment
  • Installing the Vuforia Android SDK
  • How to Compile and Run an Android Sample
  • How To Install an APK using ADB
  • 设置Android开发环境
  • 安装Vuforia Android SDK
  • 如何编译和运行Android示例
  • 如何使用ADB安装APK

Setting Up the Android Development Environment

Supported development platforms

  • The Vuforia SDK officially supports Android OS 4.1 and above, and OpenGL ES 2 and 3.
  • The recommended development environment is Microsoft Windows 7 or 8 32/64-bit.
  • The components to build the actual code (JDK, Android Studio, Android SDK / NDK) are available across multiple platforms. While building on Linux Ubuntu and Mac OS X environments is possible, we are unable to support those platforms with detailed documentation. However, we have included hints and notes to platform-specific issues that will help you set up your development environment on Linux Ubuntu 10.10 or Mac OS X 10.7 (Lion). This setup guide has been written for the Win7 32/64-bit platform with special notes for other operating systems.

NOTE: If you have already set up the Android SDK and NDK, go directly to Installing the Vuforia Android SDK

设置Android开发环境支持的开发平台

·  Vuforia SDK正式支持Android OS 4.1及更高版本,以及OpenGL ES 2和3。
· 推荐的开发环境是Microsoft Windows 7或8 32/64位。
· 构建实际代码的组件(JDK,Android Studio,Android SDK / NDK)可在多个平台上使用。 虽然在Linux上构建Ubuntu和Mac OS X环境是可能的,但我们无法通过详细的文档来支持这些平台。 但是,我们在平台特定的问题中提供了提示和注释,可帮助您在Linux Ubuntu 10.10或Mac OS X 10.7(Lion)上设置开发环境。 此设置指南是为Win7 32/64位平台编写的,其他操作系统具有特殊说明。


注意:如果您已经设置了Android SDK和NDK,请直接转到安装Vuforia Android SDK

The Vuforia SDK requires the Android SDK and the NDK. The Android NDK is an extension of the Android SDK that lets Android developers build performance-critical parts of their applications in native code. The SDK and NDK communicate over the Java Native Interface (JNI).
To set up the development environment, install these components in the following order, using the latest versions of the tools with the Vuforia SDK:

  • JDK (Java SE)
  • Android Studio IDE
  • Android SDK packages
  • Cygwin environment
  • Android NDK
Vuforia SDK需要Android SDK和NDK。 Android NDK是Android SDK的扩展,可让Android开发人员使用本机代码构建其应用程序的关键性能部件。 SDK和NDK通过Java Native Interface(JNI)进行通信。
要设置开发环境,请按照以下顺序安装这些组件,使用Vuforia SDK的最新版本的工具:


· JDK(Java SE)
· Android Studio IDE
· Android SDK包
· Cygwin环境
·Android NDK

JDK

Mac OSX: The JDK is already integrated into the Mac OS X operation system.

  1. Download the Java SE Development Kit (JDK) from this site: http://www.oracle.com/technetwork/java/javase/downloads/
  2. Click Download from the JDK section of the 'Java Platform, Standard Edition' table.
  3. Install the JDK environment with default settings.

Detailed installation instructions and system requirements can be found at: http://www.oracle.com/technetwork/java/javase/index-137561.html


Mac OSX:JDK已经集成到Mac OS X操作系统中。


从此站点下载Java SE开发工具包(JDK):http://www.oracle.com/technetwork/java/javase/downloads/
单击“Java平台,标准版”表的JDK部分下载。
使用默认设置安装JDK环境。
详细的安装说明和系统要求可以在以下网站找到:http://www.oracle.com/technetwork/java/javase/index-137561.html

Android Studio

Android Studio provides everything you need to start developing apps for Android, including the Android Studio IDE and the Android SDK tools.

  1. Download the Android Studio installer from: http://developer.android.com/sdk/index.html
  2. Once the download has completed, run the installer executable and follow the installation instructions to install the IDE in the destination directory of your choice (e.g. C:\Program Files\Android\Android Studio ); in particular, pay attention to the following steps:
    • In the Select components to install page, make sure that Android SDK option is selected;
    • In the Configuration Settings Install Locations page of the install wizard, specify the location where you want to install the Android SDK; we suggest to set it to a location like C:\Development\Android\android-sdk , where C:\Development\Android represents the base directory of your Android development environment; this is also the directory where you will want to install the Android NDK, as discussed later in this guide (note: we will refer to such base directory as <DEVELOPMENT_ROOT> in the remainder of this guide)

Android Studio


Android Studio提供开始开发Android应用程序所需的一切,包括Android Studio IDE和Android SDK工具。


1、从http://developer.android.com/sdk/index.html下载Android Studio安装程序
2、下载完成后,运行安装程序可执行文件,并按照安装说明将IDE安装到您所选择的目标目录(例如C:\ Program Files \ Android \ Android Studio)中;特别要注意以下几个步骤:
· 在“选择要安装的组件”页面中,确保选择了Android SDK选项;
· 在安装向导的“配置设置安装位置”页面中,指定要安装Android SDK的位置;我们建议将其设置为像C:\ Development \ Android \ android-sdk这样的位置,其中C:\ Development \ Android表示Android开发环境的基本目录;这也是您将要安装Android NDK的目录,如本指南稍后所述(请注意:本指南的其余部分将引用<DEVELOPMENT_ROOT>这样的基本目录)


Android SDK Packages       Android SDK软件包

By installing Android Studio, you also installed the most recent version of the Android SDK and the relevant SDK tools. However, the SDK Manager allows you to install additional / optional SDK components and to update your Android SDK and SDK tools to the latest revisions available; therefore you may want to periodically run the SDK Manager to check for the latest SDK revisions, and update to them if necessary.
We also recommend to run the SDK Manager at least once after the installation of Android Studio, to download the necessary components for developing with Vuforia:

安装Android Studio时,您还安装了最新版本的Android SDK和相关的SDK工具。 但是,SDK Manager允许您安装其他/可选的SDK组件,并将Android SDK和SDK工具更新为可用的最新版本; 因此,您可能需要定期运行SDK Manager以检查最新的SDK修订版本,并在必要时更新它们。
我们还建议在安装Android Studio后至少运行一次SDK Manager,以便下载使用Vuforia进行开发的必要组件:

1、Launch Android Studio

       启动Android Studio

2、In Android Studio, click on the SDK Manager icon in the Toolbar. 

      在Android Studio中,点击工具栏中的SDK Manager图标。


      3.In the dialog window that opens up, click on the Launch Standalone SDK Manager 

3、打开的对话框窗口,单击启动独立SDK管理器

4.In the SDK Manager standalone window, select the following packages to install:

  • Tools:
    • Android SDK Tools (latest rev.)
    • Android SDK Build Tools (latest rev.)
    • Android SDK Platform-Tools (latest rev.)
  • Android 6.0 (API 23):
    • SDK Platform
    • Documentation for Android SDK
      • NOTE: These items should have been already installed during the Android Studio installation (if not, simply select them for installation)
  • Android 5.1.1 (API 22):
    • SDK Platform
      • NOTE: Vuforia 5.0.x does not fully support Android 6.0 (akas Android Marshmallow or Android M ); therefore we recommend installing the Android 5.1.1 (API 22)
  • Extras:
    • Google USB Driver (Windows only)
4.在SDK Manager独立窗口中,选择要安装的以下软件包:


工具:
Android SDK工具(最新版本)
Android SDK Build Tools(最新版本)
Android SDK Platform-Tools(最新版本)
Android 6.0(API 23):
SDK平台
Android SDK文档
注意:这些项目应该已经在Android Studio安装过程中安装(如果没有,只需选择它们进行安装)
Android 5.1.1(API 22):
SDK平台
注意:Vuforia 5.0.x不完全支持Android 6.0(akas Android Marshmallow或Android M); 因此我们建议安装Android 5.1.1(API 22)
附加功能:
Google USB驱动程序(仅限Windows)


Once you've selected all the desired packages, continue to install:

  1. Click 'Install X packages'
  2. In the next window, double-click each package name on the left to accept the license agreement for each.
  3. Click Install.

The download progress is shown at the bottom of the SDK Manager window. Do not exit the SDK Manager or it will cancel the download.

选择所有所需软件包后,请继续安装:


点击“安装X包”
在下一个窗口中,双击左侧的每个软件包名称以接受每个软件包的许可协议。
单击安装。
下载进度显示在SDK Manager窗口的底部。 不要退出SDK管理器,否则将取消下载。

Setting the System Environment Variables

Add the Android SDK tools and platform-tools directories to your Windows Path:

  1. Right-click My Computer on the desktop and select Properties .
  2. Click the Advanced System settings button ab to open the System properties window
  3. Under the Advanced tab, select Environment Variables and look for the Variable Path in the System variables window.
  4. After pressing Edit, scroll to the end of Variable value: and add the full path to the directory to the end of the path, separated by a semicolon from the previous path. In the above example, you would add:
;C:\Development\Android\android-sdk\tools\;C:\Development\Android\android-sdk\platform-tools\
设置系统环境变量


将Android SDK工具和平台工具目录添加到Windows路径中:


1.右键单击桌面上的我的电脑,然后选择属性。
2.单击高级系统设置按钮ab打开系统属性窗口
3.在“高级”选项卡下,选择“环境变量”,并在“系统变量”窗口中查找“变量路径”。
4.按“编辑”后,滚动到“变量”值的末尾:将目录的完整路径添加到路径的末尾,以前面路径的分号分隔。 在上面的例子中,你可以添加:
; C:\开发\ Android的\ Android的SDK\工具\; C:\开发\ Android的\ Android的SDK\平台工具\


NOTE: The last "\" at the end of the Path variable has to be included.

Mac OSX: Update the PATH variable to point to the Android SDK Platform-tools directory in the /etc/rc.common file or ~/.bash_profile:

 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices:/Developer/usr/bin:~/Development/And

注意:必须包括路径变量末尾的最后一个“\”。


Mac OSX:更新PATH变量以指向/etc/rc.common文件中的Android SDK Platform-tools目录或〜/ .bash_profile:


 PATH =/ bin中:/ sbin目录:在/ usr/ bin中:/ usr / sbin目录:在/ usr/ libexec目录:/系统/资源库/ CoreServices:/开发人员在/ usr/ bin中:〜/开发/ AND


Linux: Update your PATH to point to the Android SDK Platform-tools directory. If you use bash shell, add the following to ~/.bashrc :

export PATH=/opt/android-sdk/tools/:/opt/android-sdk/platform-tools/:

Linux:更新您的PATH以指向Android SDK Platform-tools目录。 如果您使用bash shell,请将以下内容添加到〜/ .bashrc中:


export PATH = / opt / android-sdk / tools /:/ opt / android-sdk / platform-tools /:


Cygwin environment

Linux: This section is not relevant for Linux users who have GNU make installed and in their path.
Mac OSX: This section is not relevant for Mac users who have Apple Developer Tools (XCode) installed. Install XCode if necessary from http://developer.apple.com/xcode/.

The Vuforia SDK for the Android platform includes both a Java API and a C++ API. The Java API enables the full suite of Vuforia features and functionalities and allows developers to build Android applications without having to write native C++ code.

The C++ API is meant to be used by developers with very advanced / specific requirements, such as the ability to integrate C++-based third party libraries or custom C++ software components. When this is not required, it is generally recommended to use the Java API.
If you expect to need the C++ native API, you will need a C++ GNU compiler, as explained in the following paragraph; otherwise, for pure Java based development, you can skip this section.

A GNU compiler is required to compile dynamic applications as shared libraries for the Android NDK. Android makefiles are designed to run with gcc4. On Windows, a convenient way to have the complete environment prepared for this is to install Cygwin.

Cygwin uses an installer helper to manage the installation process.

  1. Go to http://www.cygwin.com, download and run the installer (setup.exe)
  2. Select "Install from the Internet!" when prompted at "Choose a Download Source" in the installer. We recommend not changing the Root Directory in the next window, and leaving it at "C:\cygwin." The "Local Package Directory" holds the downloaded packages. You may want to keep them with the downloaded Setup.exe file in the same directory to have a Cygwin installer directory. Choose a download site with a known fast connection near you.

When the package information is downloaded you will see a hierarchical browser to select packages.

  1. Select the following package from the hierarchy for download: All -> Devel -> "make: The GNU version of the 'make' utility"
  2. Select the word skip to change it to the actual version number that will be installed
  3. Finish the installation by clicking Next.

Your Cygwin environment is fully set up to work with the Vuforia SDK. If you have other similar environments installed, make sure to set your Windows path variable to point to "C:\cygwin\bin" so that bash uses this version of GNU's make.exe.


Cygwin环境


Linux:此部分与已安装GNU make的Linux用户及其路径无关。
Mac OSX:此部分与安装了Apple Developer Tools(XCode)的Mac用户无关。如有必要,请从http://developer.apple.com/xcode/安装XCode。


用于Android平台的Vuforia SDK包括Java API和C ++ API。 Java API支持全套Vuforia功能和功能,并允许开发人员构建Android应用程序,而无需编写本机C ++代码。


C ++ API旨在由具有非常高级/特定要求的开发人员使用,例如集成基于C ++的第三方库或自定义C ++软件组件的能力。当这不需要时,通常建议使用Java API。
如果您需要C ++本机API,则需要一个C ++ GNU编译器,如下面段落所述;否则,对于纯Java开发,您可以跳过本节。


将动态应用程序编译为Android NDK的共享库需要GNU编译器。 Android makefiles设计为使用gcc4运行。在Windows上,为此准备好一个完整的环境的方便方法是安装Cygwin。


Cygwin使用安装程序助手管理安装过程。


转到http://www.cygwin.com,下载并运行安装程序(setup.exe)
选择“从Internet安装!”当在安装程序中的“选择下载源”时提示。我们建议在下一个窗口中不要更改根目录,并将其保留在“C:\ cygwin”。 “本地包目录”保存下载的包。您可能希望将下载的Setup.exe文件保存在同一目录中以具有Cygwin安装程序目录。选择一个具有已知快速连接的下载站点。
当软件包信息下载时,您将看到一个分层浏览器来选择软件包。


从层次结构中选择以下软件包以进行下载:全部 - > Devel - >“make:”make“实用程序的GNU版本
选择单词skip将其更改为将要安装的实际版本号
单击下一步完成安装。
您的Cygwin环境已完全设置为使用Vuforia SDK。如果安装了其他类似的环境,请确保将Windows路径变量设置为“C:\ cygwin \ bin”,以便bash使用此版本的GNU的make.exe。



Android NDK

The Android NDK is an extension of the Android SDK that lets Android developers build performance-critical parts of their applications in native code.
If you need to use the C++ API of the Vuforia SDK, you will also need to install the Android NDK which enables native C++ programming on Android. If you plan to only use the Java API, you may skip this section.

  1. Download the NDK package from http://developer.android.com/sdk/ndk/index.html
  2. Unzip the archive, and copy the contents into a directory. To be consistent with our previous setup, we recommend putting the contents in "C:\Development\Android\android-ndk-rxy\". Thus, Android SDK and Android NDK share the same parent directory. Later, we will add the Vuforia SDK and your project files. NDK requires the above directory to be added to the Windows path.
  3. Right-click My Computer on the desktop and select Properties .
  4. Click the Advanced System settings button to open the System properties window
  5. Under the Advanced tab, select Environment Variables and look for the Variable Path in the System variables window.
  6. After pressing Edit, scroll to the end of Variable value: and add the full path to the directory to the end of the path, separated by a semicolon from the previous path. In the above example, you would add:
;C:\Development\Android\android-ndk-rxy\

NOTE: Path has a semicolon at the beginning. Do not use pathnames with spaces. Alternatively, you can set a User variable with the name Path, but this is valid only for the current user. The last "\" at the end of the Path variable has to be included.

To test your installation, compile any of the NDK sample applications. Using a Cygwin bash shell, navigate to the root directory of any demo application (e.g., for the 'san-angeles' sample app without the installation path above):

cd /cygdrive/c/Development/Android/android-ndk-rxy/samples/san-angelesndk-build 


The compiler should produce a dynamically linked library libsanangeles.so and write it to /libs/armeabi within the application directory. NDK includes support for different architectures so you might find different subdirectories in /libs.
Now your development environment is ready to host Vuforia SDK-related content.

Mac OSX: Update the PATH variable to point to the Android NDK directory in the /etc/rc.common file or the ~/.bash_profile:

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices:/Developer/usr/bin:~/Development/And


Linux: Update your PATH to point to the Android NDK Platform directory. If you use bash shell, add the following to the ~/.bashrc file:

export PATH=~/bin:/opt/android-sdk-linux_x86/tools/:/opt/android-ndk-rxy:
Android NDK


Android NDK是Android SDK的扩展,可让Android开发人员使用本机代码构建其应用程序的关键性能部件。
如果您需要使用Vuforia SDK的C ++ API,您还需要安装Android NDK,它可以在Android上启用本机C ++编程。如果您打算仅使用Java API,则可以跳过本节。


从http://developer.android.com/sdk/ndk/index.html下载NDK软件包
解压缩档案,并将内容复制到目录中。为了与我们以前的设置保持一致,我们建议将内容放在“C:\ Development \ Android \ android-ndk-rxy \”中。因此,Android SDK和Android NDK共享相同的父目录。之后,我们将添加Vuforia SDK和您的项目文件。 NDK要求将上述目录添加到Windows路径。
右键单击桌面上的我的电脑,然后选择属性。
单击高级系统设置按钮打开系统属性窗口
在“高级”选项卡下,选择“环境变量”,并在“系统变量”窗口中查找“变量路径”。
按“编辑”后,滚动到“变量”值的末尾:将目录的完整路径添加到路径的末尾,以前面路径的分号分隔。在上面的例子中,你可以添加:
; C:\开发\ Android的\ Android的NDK-RXY​​ \


注意:路径在开头有一个分号。不要使用带空格的路径名。或者,您可以使用名称Path设置User变量,但这仅对当前用户有效。必须包括路径变量末尾的最后一个“\”。


要测试您的安装,请编译任何NDK示例应用程序。使用Cygwin bash shell,导航到任何演示应用程序的根目录(例如,对于没有上述安装路径的“san-angeles”示例应用程序):


cd / cygdrive / c / Development / Android / android-ndk-rxy / samples / san-angeles
NDK建造


编译器应该产生一个动态链接库libsanangeles.so,并将其写入应用程序目录中的/ libs / armeabi。 NDK包括对不同架构的支持,因此您可能会在/ lib中找到不同的子目录。
现在您的开发环境已准备好承载与Vuforia SDK相关的内容。


Mac OSX:更新PATH变量以指向/etc/rc.common文件中的Android NDK目录或〜/ .bash_profile:


PATH = / bin中:/ sbin目录:在/ usr / bin中:/ usr / sbin目录:在/ usr / libexec目录:/系统/资源库/ CoreServices:/开发人员在/ usr / bin中:〜/开发/ AND


Linux:更新PATH以指向Android NDK Platform目录。如果您使用bash shell,请将以下内容添加到〜/ .bashrc文件中:


export PATH =〜/ bin:/ opt / android-sdk-linux_x86 / tools /:/ opt / android-ndk-rxy:


Installing the Vuforia Android SDK

Installing the Vuforia Android SDK

Clean installation

The Vuforia SDK is distributed as a ZIP package for the following platforms:

  • Windows 7 or 8 32/64-bit
  • Mac OS X

To start developing with the Vuforia SDK:

  • Download the Vuforia Android SDK
  • Extract the contents of the SDK ZIP archive, placing it in your Android development root folder (e.g. C:\Development\Android on Windows, or /Users/[account]/Development/Android on OSX )

Extracting the SDK will create a directory structure for your Android development environment. This structure ensures that Vuforia sample apps can easily be built and deployed using the Android SDK, Android NDK, and the Android Studio development environment.

Upgrading from a previous version

  • See How to Migrate an Android Project for API changes and migration instructions.

Resulting directory structure

To streamline development we have defined a directory structure that maintains the Vuforia SDK and your applications in separate directory trees. This enables the SDK to be updated without the need to modify your source tree.

As a convention, we will refer to the root directory of your Vuforia Android development environment as

<DEVELOPMENT_ROOT>

The extracted SDK archive will create the following directory structure in the vuforia-sdk-android-[ xx-yy-zz ] folder. The pattern xx-yy-zz stands for the version number of the Vuforia SDK.

<DEVELOPMENT_ROOT>\ android-ndk-rxy\ android-sdk\ vuforia-sdk-android-xx-yy-zz\   build\                  Vuforia Augmented Reality SDK            licenses\               License Agreements   samples\                Sample applications with full source code   assets\                 Additional assets required to use Vuforia SDK   readme.txt              Starting read-me document

安装Vuforia Android SDK
安装Vuforia Android SDK


清洁安装


Vuforia SDK作为以下平台的ZIP包发布:


Windows 7或8 32/64位
Mac OS X
要开始使用Vuforia SDK进行开发:


下载Vuforia Android SDK
提取SDK ZIP存档的内容,将其放入Android开发根文件夹(例如Windows上的C:\ Development \ Android或OSX上的/ Users / [account] / Development / Android)
提取SDK将为您的Android开发环境创建一个目录结构。此结构确保使用Android SDK,Android NDK和Android Studio开发环境轻松构建和部署Vuforia示例应用程序。


从以前的版本升级


请参阅如何迁移Android项目以进行API更改和迁移说明。
结果目录结构


为了简化开发,我们定义了一个目录结构,它将Vuforia SDK和应用程序维护在单独的目录树中。这样可以更新SDK,而无需修改源代码树。


作为惯例,我们将参考您的Vuforia Android开发环境的根目录


<DEVELOPMENT_ROOT>
提取的SDK存档将在vuforia-sdk-android- [xx-yy-zz]文件夹中创建以下目录结构。模式xx-yy-zz表示Vuforia SDK的版本号。
<DEVELOPMENT_ROOT> \
 
Android的NDK-RXY​​ \
 
Android的SDK \
 
vuforia-SDK-的Android-XX-YY-ZZ \
 
  构建\ Vuforia增强现实SDK
 
  许可证\许可协议
 
  样本\样本应用程序与完整的源代码
 
  资产\使用Vuforia SDK所需的其他资产
 
  readme.txt启动read-me文档

Install the Vuforia SDK

Download
The Vuforia SDK is distributed through the Developer Portal.

Note: Although we distribute the Vuforia SDK for the platforms listed below, support for development is limited to the Win 7 32/64-bit platform.

  1. Download the archive file from the Downloads page.
  2. Extract the content of the archive and store it under <DEVELOPMENT_ROOT>.

Prepare test device for development

Developer settings on the device
Android devices require special settings for development.

You will need to:

  • Enable installing apps from unknown sources

On the device, go to Settings > Security and choose Unknown sources. This setting allows direct installation of unsigned APKs from within Eclipse.

安装Vuforia SDK


下载
Vuforia SDK通过开发者门户网站发布。


注意:尽管我们为以下列出的平台分发了Vuforia SDK,但支持开发仅限于Win 7 32/64位平台。


从“下载”页面下载存档文件。
提取存档的内容并将其存储在<DEVELOPMENT_ROOT>下。
准备测试设备进行开发


设备上的开发者设置
Android设备需要特殊的开发设置。


您将需要:


启用从未知来源安装应用程序
在设备上,转到设置>安全性,然后选择未知来源。 此设置允许从Eclipse内直接安装未签名的APK。


  •               Enable USB debugging          启用USB调试

Go to Settings > Developer Options and enable the USB debugging and Stay awake options.

转到设置>开发人员选项,并启用USB调试和保持唤醒选项。


Note that USB debugging is mandatory, the Stay awake setting is a convenience that helps with development.

Install the USB driver (Windows only)

  • Connect your device to the development PC using the USB cable.

On initial connection, Windows recognizes the new device and attempts to locate a compatible driver. The Android SDK already includes some USB drivers, others can be obtained directly from the device manufacturer.

SDK pre-packaged drivers can be located in the following directory:

请注意,USB调试是强制性的,“保持唤醒”设置是方便开发的。


安装USB驱动程序(仅限Windows)


使用USB电缆将设备连接到开发PC。
在初始连接时,Windows会识别新设备,并尝试查找兼容的驱动程序。 Android SDK已经包括一些USB驱动程序,其他的可以直接从设备制造商获得。


SDK预打包驱动程序可以位于以下目录中:

<DEVELOPMENT_ROOT>\android-sdk\extras\google\usb_driver


Your device will be ready to use when the device driver installation has completed.

设备驱动程序安装完成后,您的设备将可以使用。


How to Compile and Run an Android Sample

The Vuforia SDK for the Android platform includes both a Java API and a C++ API. The Java samples demonstrate all the main features of the Vuforia SDK; in addition, there is a C++ sample implementation of the Image Targets feature, called ImageTargetsNative-x-y-z , which shows how to use the C++ native API:

如何编译和运行Android示例
用于Android平台的Vuforia SDK包括Java API和C ++ API。 Java示例演示了Vuforia SDK的所有主要功能;此外,还有一个C ++示例实现Image Targets功能,称为ImageTargetsNative-x-y-z,它显示了如何使用C ++本机API:
示例名称                                                               描述                                                                                  API
VuforiaSamples-x-y-z                       演示所有主要Vuforia SDK功能的示例                                         JAVA
BackgroundTextureAccess-x-y-z     演示如何访问和操作视频背景纹理JAVA的示例
书籍x-y-z                                            演示云识别功能JAVA的高级用例的示例
Dominoes-x-y-z                                 演示使用“图像目标”功能进行高级触摸式交互的示例            JAVA
OcclusionManagement-x-y-z          使用多目标功能JAVA显示高级呈现效果的示例
VideoPlayback-x-y-z                          演示如何使用图像目标JAVA播放AR体验视频的示例
ImageTargets-Native-x-y-z               演示图像目标特征C ++的本地C ++实现的示例

Sample NameDescriptionAPIVuforiaSamples-x-y-zSample demonstrating all the main Vuforia SDK featuresJAVABackgroundTextureAccess-x-y-zSample demonstrating how to access and manipulate the video background textureJAVABooks-x-y-zSample demonstrating an advanced use case for the Cloud Recognition featureJAVADominoes-x-y-zSample demonstrating advanced touch-based interaction with the Image Targets featureJAVAOcclusionManagement-x-y-zSample demonstrating advanced rendering effects with the Multi Targets featureJAVAVideoPlayback-x-y-zSample demonstrating how to play videos in an AR experience with Image TargetsJAVAImageTargets-Native-x-y-zSample demonstrating a native C++ implementation of the Image Targets featureC++


The Vuforia samples can be downloaded from https://developer.vuforia.com/downloads/samples
Once downloaded, extract the sample ZIP packages and copy them into the samples folder under your Vuforia SDK installation directory (e.g., C: \Development\Android\vuforia-sdk-android-xx-yy-zz\samples\ ).
The VuforiaSamples-x-y-z application is a good place to start learning about the SDK, because it shows the main features of the SDK in a single app. This section explains how to use Android Studio to build the Java sources and create the APK package that can be deployed to the device.

Building the Samples

To build a Vuforia sample for the Android platform, follow these steps:

1. Launch Android Studio
2. Select Open > File or Project from the File menu, or select Open an existing Android Studio project from the Quick Start launch page 

Vuforia示例可以从https://developer.vuforia.com/downloads/samples下载
一旦下载,解压缩样本ZIP包,并将它们复制到您的Vuforia SDK安装目录(例如C:\ Development \ Android \ vuforia-sdk-android-xx-yy-zz \ samples \)下的示例文件夹中。
VuforiaSamples-x-y-z应用程序是开始了解SDK的好地方,因为它在单个应用程序中显示了SDK的主要功能。 本节介绍如何使用Android Studio构建Java源代码并创建可以部署到设备的APK包。


建立样品
要为Android平台构建Vuforia示例,请按照下列步骤操作:


1.启动Android Studio
2.从文件菜单中选择打开>文件或项目,或从快速启动启动页面选择打开现有的Android Studio项目




3. Browse to the <DEVELOPMENT_ROOT>\vuforia-sdk-android-xx-yy-zz\samples\VuforiaSamples-x-y-z directory and click OK to open it
4. When opening a sample project for the first time, Android Studio may prompt a dialog asking whether you want to create a Gradle Wrapper for the project; you can answer yes by clicking the OK button:

3.浏览到<DEVELOPMENT_ROOT> \ vuforia-sdk-android-xx-yy-zz \ samples \ VuforiaSamples-x-y-z目录,然后单击确定将其打开
4.首次打开示例项目时,Android Studio可能会提示一个对话框,询问您是否要为该项目创建一个Gradle Wrapper; 您可以通过单击确定按钮来回答是:



5. Once the project is loaded, open the Build menu and select Make Project to compile the app. This will also create the APK package for deployment; the generated APK files are stored by Android Studio in the app/build/outputs/ sub-directory of the sample project.
Alternatively you can click on Rebuild Project to trigger a clean and full rebuild of the application.

5.加载项目后,打开Build菜单,选择Make Project编译应用程序。 这也将创建用于部署的APK包; 生成的APK文件由Android Studio存储在示例项目的应用程序/构建/输出/子目录中。
或者,您可以单击重建项目以触发清洁和完全重建应用程序。



Running the Vuforia Samples application
If you click on the Run menu item in the toolbar, or on the little arrow icon next to the app menu button, the app will be compiled, installed and launched on the target device.

运行Vuforia示例应用程序
如果您单击工具栏中的“运行”菜单项或应用程序菜单按钮旁边的小箭头图标,该应用程序将在目标设备上进行编译,安装和启动。

Upon startup of the Vuforia Samples app, a main menu is shown, from which you can select a specific sample feature:

在启动Vuforia Samples应用程序时,将显示一个主菜单,您可以从中选择特定的示例功能:


Troubleshooting
If you encounter problems on the installation, check the device connection settings in Prepare Test Device for Development. In Android Studio, you can see if the device is connected correctly via the Android Device Monitor, which you can open by clicking on the Android icon in the toolbar. The device must be listed under Devices.

故障排除
如果在安装时遇到问题,请在“准备测试设备开发”中检查设备连接设置。 在Android Studio中,您可以通过Android设备监视器看到设备是否正确连接,您可以通过点击工具栏中的Android图标打开设备。 设备必须列在设备下。



The device must be listed under Devices, and should appear with Online status.

设备必须列在“设备”下,并应显示为“联机”状态。



Alternatively, open a Cygwin bash shell and execute:

或者,打开Cygwin bash shell并执行:

adb devices


The output should show the following attached device:

输出应显示以下连接的设备:

$ adb devices List of devices attached HT012P123456 device

*the attached device ID will reflect the Model ID of the devices attached to you ADB host.

If the device list is empty, or a given device is not listed, kill the ADB server by executing:
*附加的设备ID将反映附加到您的ADB主机的设备的型号。


如果设备列表为空,或者给定的设备未列出,请通过执行以下命令杀死ADB服务器:


adb kill-server

Execute 'adb devices' again to restart the server and re-detect devices.

再次执行“adb设备”重新启动服务器并重新检测设备。



How To Install an APK using ADB

You can install an APK onto an Android device by connecting the device to a PC with a USB cord and then connecting to the device using the Android Debug Bridge (ADB). 

1. Connect the device to the developer desktop environment with a USB cable.
2. Open a Cygwin bash shell or Windows Command Line and execute:

如何使用ADB安装APK
您可以通过将设备连接到具有USB电缆的PC,然后使用Android调试桥(ADB)连接到设备,将APK安装到Android设备上。


1.使用USB电缆将设备连接到开发人员桌面环境。
2.打开Cygwin bash shell或Windows命令行并执行:

1
adb devices

The output should show the attached device:

输出应显示所连接的设备:

1
2
3
4
$ adb devices
 
List of devices attached
HT012P123456 device

3. To install the application, navigate to the folder containing the downloaded APK. In our example C:\Temp and install APK using adb.

3.要安装应用程序,请导航到包含已下载的APK的文件夹。 在我们的示例C:\ Temp并使用adb安装APK。

1
2
3
$ cd /cygdrive/c/temp
 
$ adb install thisIsTheAPKName.apk

4. If the device list is empty, or a given device is not listed, kill the ADB server by executing:

4.如果设备列表为空,或者给定的设备未列出,请通过执行以下命令杀死ADB服务器:

1
adb kill-server

5. Execute adb devices again to restart the server, re-detect devices, and try again.

5.再次执行adb设备重新启动服务器,重新检测设备,然后重试。




原网址:https://library.vuforia.com/articles/Solution/Getting-Started-with-Vuforia-for-Android-Development.html