Using Android Studio with Vuforia

If you are using or planning to use the Android Studio IDE, here are some notes about how to import and build the Vuforia samples:

Getting Started with Android Studio (Java/C++) for Android development

1、Setting up the Android Development Environment

https://developer.vuforia.com/library/articles/Solution/Setting-Up-the-Android-Development-Environment-for-Android-Studio英文的教程比中文好多了

Cygwin uses an installer helper to manage the installation process.
1、Go to http://www.cygwin.com, download and run the installer (setup.exe), and 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.
Android NDK
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 can skip this section.
The Android NDK is an extension of the Android SDK that lets Android developers build performance-critical parts of their applications in native code.
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 ab 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-angeles
ndk-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: 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/Android/android-sdk-macosx/tools:~/Development/Android/android-sdk-macosx/platform-tools:~/Development/Android/android-ndk-rxy:export PATH
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:

2、Installing the Vuforia Android SDK
3、Compiling and Running a Vuforia Android Sample App

  • Read our Getting Started Guide for instructions on setting up the Java SDK, Android SDK and NDK:
  • Make sure you have installed the latest version available of Android Studio from:
  • Use the Android SDK Manager (from within Android Studio) to get the latest Android SDK and Android Platform and Build tools
  • Launch Android Studio
  • 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
    • enter the actual path to the Vuforia.jar library (which is located under yourvuforia_install_dir/build/java/vuforia)
  • In the Project view, right-click on the Project and expand the view hierarchy so to locate the Vuforia.jar underapp > src > main
  • right-click on Vuforia.jar to open the context menu
    • click on the "Add as library..." option in the context menu 
  • 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
    • Click on the "+" button to Add a File Dependency and browse to the Vuforia.jar file
  • Create a folder called "jniLibs" under the "app/src/main" folder under your Android Studio project directory
  • 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
  • If your project includes a "jni" folder, move it to a location outside of your project (otherwise Android Studio may attempt to compile the sources in that folder and may fail)
  • Clean and rebuild the project
  • Run the app on your device
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值