创建便携式Android开发环境 [英] Create portable android development environment

查看:182
本文介绍了创建便携式Android开发环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个便携式Android开发环境,我可以随身携带,随时随地(如U盘)。该想法是有一个文件夹,包括:

I would like to have a portable android development environment that I could take everywhere (e.g. a usb stick). The idea is to have a folder that would include:

  • 在日蚀
  • Android的SDK
  • JDK
  • .android(文件夹包含AVD的和键)
  • 在工作区

我安装了Eclipse 3.7.0,加入ADT插件以及

I installed Eclipse 3.7.0, added ADT plugin and

  • 添加eclipse.ini文件选项-vm ../jdk/bin/
  • 设置日食Android的SDK变量相对路径(../ Android的SDK)
  • 设置日食工作区的相对路径
  • 设置日食关键文件夹中的相对路径

现在的问题是你如何可以使AVD的便携式?如何.android文件夹是便携式?我看到一些解决方案提创造一个环境变量,但我想一个解决方案,开箱,或者,尽可能的自动化过程的。操作系统应该是Windows 7,但理想的应该在任​​何版本。 任何帮助将大大AP preciated。谢谢。

The question is how can you make the avd's portable? How can .android folder be portable? I saw some solutions mentioning the creation of an environment variable but I was thinking of a solution that works out of the box, or an ,as much as possible, automated procedure. The OS should be windows 7, but ideally should work on any version. Any help would be greatly appreciated. Thanks.

推荐答案

我想我找到了一个办法做到这一点在Mac和Windows上。我已在多台计算机上测试了两个解决方案,但不彻底。

I think I found a way to do this on a Mac and Windows. I have tested both solutions on multiple computers, but not exhaustively.

我有基本相同的方法,因为你,但问题是,在Android SDK在Eclipse中的相​​对路径打破了AVD管理的某些原因。它不会让我跑已有的或创建新的AVDS。予通过包括一个initial_setup脚本要被运行一次根据其中用户解压此包来设置Android SDK中得到了解决这个问题。它还创建初始AVD他们。因此,他们下载并解压包,运行initial_setup脚本,是好去一个默认的Andr​​oid开发环境。

I had basically the same approach as you, but the problem is that the relative path for the Android SDK in Eclipse breaks the AVD Manager for some reason. It wouldn't allow me to run existing or create new AVDs. I got around this by including an "initial_setup" script that is to be run one time to set the Android SDK based on where the user unzips this package. It also creates the initial AVD for them. So they download and unzip the package, run the initial_setup script, and are good to go with a default Android development environment.

关键是更新的Eclipse ADT插件preferences使用Android SDK的绝对路径。这是通过这条线从下面的脚本。请注意,为preferences文件的路径是相对于工作空间(和工作空间路径设置为相对于Eclipse的安装)。

The key is updating Eclipse ADT Plugin preferences to use the absolute path of the Android SDK. This is accomplished with this line from the script below. Note that the path for the preferences file is relative to the workspace (and the workspace path is set as relative to the Eclipse installation).

echo com.android.ide.eclipse.adt.sdk=$sdk_path >> ./workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.android.ide.eclipse.adt.prefs

MAC指令

下面是我解压的目录结构:

Here's my unzipped directory structure:

android_dev_environment (root)
  - android-sdk-macosx
  - eclipse
  - initial_setup
  - workspace

这是initial_setup的内容:

And here are the contents of initial_setup:

#!/bin/bash 
# Set the Android SDK path in Eclipse. Must be the absolute; a relative path
# does not work with the AVD Manager.
cd "$(dirname "$0")"
sdk_path=`pwd`/android-sdk-macosx
echo "Setting Android SDK path in Eclipse..."
echo com.android.ide.eclipse.adt.sdk=$sdk_path >> ./workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.android.ide.eclipse.adt.prefs
echo "Android SDK path set."

# Create a new AVD
echo "Creating new AVD..."
echo no | $sdk_path/tools/android create avd -n Android403 -t 1 --force
echo "AVD created."

视窗说明

下面是我解压的目录结构:

Here's my unzipped directory structure:

android_dev_environment (root)
  - android-sdk-windows
  - eclipse
  - initial_setup.bat
  - java
  - workspace

Windows版本已经在java目录中它自己的本地JDK 6。 Eclipse中需要了解它,所以编辑日食\的eclipse.ini。添加以下行以上-vmargs行

-vm 
..\Java\jdk1.6.0_33\bin\javaw.exe

这是initial_setup.bat的内容:

And here are the contents of initial_setup.bat:

REM Set the Android SDK path in Eclipse. Must be the absolute; a relative path
REM does not work with the AVD Manager.
cd > temp.txt 2>&1
set /p sdk_path= < temp.txt
del temp.txt
set sdk_path=%sdk_path%\android-sdk-windows
set sdk_path=%sdk_path:\=\\%
set sdk_path=%sdk_path::=\:%

echo "Setting Android SDK path in Eclipse..."
echo com.android.ide.eclipse.adt.sdk=%sdk_path%>> .\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.android.ide.eclipse.adt.prefs
echo "Android SDK path set."

REM Create a new AVD
echo "Creating a new AVD..."
echo no | .\android-sdk-windows\tools\android create avd -n Android403 -t 1 --force
echo "AVD created."

pause

对于64位Windows 您还需要调整find_java.bat文件在Android SDK,以便找到同捆安装了Java。添加以下行到Android的SDK-WINDOWS \工具\ lib目录\ find_java.bat(它运行之前,自己的检查与注释以物权检查,我们有一个有效的JAVA.EXE ......

For 64 bit Windows you also need to tweak the find_java.bat file in the Android SDK so that it finds the Java installed with the bundle. Add the following lines to android-sdk-windows\tools\lib\find_java.bat (before it runs its own check that starts with the comment "rem Check we have a valid Java.exe..."

set java_exe=%~dp0\..\..\..\Java\jdk1.6.0_33\bin\java.exe
set javaw_exe=%~dp0\..\..\..\Java\jdk1.6.0_33\bin\javaw.exe
if defined javaw_exe goto :EOF

如何使用环境软件包

  1. 解压缩包
  2. 双击initial_setup在android_dev_environment文件夹设置Android SDK的路径到用户的绝对路径,并创建默认AVD
  3. 运行Eclipse可执行文件的eclipse目录里面​​

注意: Mac或PC上多次运行initial_setup不会伤害任何东西。如果用户initial_setup后将使整个目录,但在新位置运行initial_setup将修复它的开发环境将打破。我计划,包括与这些指令的README文件。

Note: Running initial_setup on a Mac or a PC multiple times does not hurt anything. The dev environment will break if the user moves the whole directory after initial_setup, but running initial_setup from the new location will fix it. I plan on including a README file with these instructions.

希望这有助于!

这篇关于创建便携式Android开发环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆