eclipse 创建可移植的android开发环境

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10824359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:16:57  来源:igfitidea点击:

Create portable android development environment

androideclipseportabilityavd

提问by Thomas Kaliakos

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 开发环境(例如 U 盘)。这个想法是有一个文件夹,其中包括:

  • eclipse
  • android-sdk
  • jdk
  • .android (folder that contains the avd's and keys)
  • workspace
  • android-sdk
  • jdk
  • .android(包含 avd 和密钥的文件夹)
  • 工作空间

I installed Eclipse 3.7.0, added ADT plugin and

我安装了 Eclipse 3.7.0,添加了 ADT 插件和

  • added option "-vm ../jdk/bin/" in eclipse.ini file
  • set the eclipse android-sdk variable to a relative path (../android-sdk)
  • set the eclipse workspace to a relative path
  • set the eclipse key folder to a relative path
  • 在 eclipse.ini 文件中添加了选项“-vm ../jdk/bin/”
  • 将 eclipse android-sdk 变量设置为相对路径 (../android-sdk)
  • 将eclipse工作区设置为相对路径
  • 将 eclipse 密钥文件夹设置为相对路径

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.

问题是如何使 avd 具有便携性?.android 文件夹如何便携?我看到一些解决方案提到了创建环境变量,但我正在考虑一个开箱即用的解决方案,或者一个尽可能多的自动化程序。操作系统应该是 windows 7,但理想情况下应该适用于任何版本。任何帮助将不胜感激。谢谢。

回答by Ben Jakuben

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.

我想我找到了一种在 Mac 和 Windows 上执行此操作的方法。我已在多台计算机上测试了这两种解决方案,但并未详尽无遗。

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 中 Android SDK 的相对路径由于某种原因破坏了 AVD 管理器。它不允许我运行现有的或创建新的 AVD。我通过包含一个“initial_setup”脚本来解决这个问题,该脚本将运行一次,以根据用户解压缩此包的位置来设置 Android SDK。它还为他们创建初始 AVD。所以他们下载并解压包,运行initial_setup 脚本,并使用默认的Android 开发环境。

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).

关键是更新 Eclipse ADT 插件首选项以使用 Android SDK 的绝对路径。这是通过下面脚本中的这一行完成的。请注意,首选项文件的路径是相对于工作区的(并且工作区路径设置为相对于 Eclipse 安装)。

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

Mac Instructions

Mac 使用说明

Here's my unzipped directory structure:

这是我解压后的目录结构:

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

And here are the contents of initial_setup:

以下是 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 "
android_dev_environment (root)
  - android-sdk-windows
  - eclipse
  - initial_setup.bat
  - java
  - workspace
")" 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."

Windows Instructions

视窗说明

Here's my unzipped directory structure:

这是我解压后的目录结构:

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

The Windows version has its own local JDK 6 in the java directory. Eclipse needs to know about it, so edit eclipse\eclipse.ini. Add the following lines above the -vmargs line:

Windows 版本在 java 目录中有自己的本地 JDK 6。Eclipse 需要知道它,所以编辑 eclipse\eclipse.ini。在 -vmargs 行上方添加以下几行

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

And here are the contents of initial_setup.bat:

以下是 initial_setup.bat 的内容:

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

For 64 bit Windowsyou 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..."

对于 64 位 Windows,您还需要调整 Android SDK 中的 find_java.bat 文件,以便它找到随包安装的 Java。将以下行添加到 android-sdk-windows\tools\lib\find_java.bat(在它运行以注释“rem Check we have a valid Java.exe...”开头的自己的检查之前)

##代码##

How to Use the Environment Bundle

如何使用环境包

  1. Unzip the bundle
  2. Double-click on initial_setup in the android_dev_environment folder to set the Android SDK path to the user's absolute path and create the default AVD
  3. Run the Eclipse executable inside the eclipse directory
  1. 解压捆绑包
  2. 双击android_dev_environment文件夹中的initial_setup,设置Android SDK路径为用户的绝对路径,并创建默认的AVD
  3. 在 eclipse 目录中运行 Eclipse 可执行文件

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.

注意:在 Mac 或 PC 上多次运行 initial_setup 不会造成任何伤害。如果用户在 initial_setup 之后移动整个目录,开发环境将中断,但从新位置运行 initial_setup 将修复它。我计划在这些说明中包含一个 README 文件。

Hope this helps!

希望这可以帮助!

回答by ghostbust555

If your willing to use linux you could use a portable operating system on your flash drive with all your settings and programs exactly how you like them on any computer with a usb drive. Or use a live cd and save to another location. I dont know how you could do it with windows

如果您愿意使用 linux,您可以在您的闪存驱动器上使用便携式操作系统,并在任何带有 USB 驱动器的计算机上完全按照您喜欢的方式使用所有设置和程序。或者使用 live cd 并保存到另一个位置。我不知道你怎么能用窗户做到这一点

回答by Richard T

While the above "approved" answer has a lot of great information, information that has helped me!, I'd like to point out another answer that has a different - more literal - take on the word "portable."

虽然上面的“批准”答案有很多重要的信息,这些信息对我有帮助!,但我想指出另一个答案,它具有不同的 - 更直接的 - 使用“便携”这个词。

Check out Terminal-IDEfor Android phones!

查看适用于 Android 手机的终端 IDE

Terminal-IDE provides an integrated development environment (IDE) that LITERALLY runs on a NON-ROOTED Android phone!

Terminal-IDE 提供了一个集成开发环境 (IDE),它可以在非 ROOTED 的 Android 手机上运行!

It ALSO provides your phone with SSH capabilities both outbound and INBOUND! So, you can literally log in to your phone from other computers! WAY COOL.

它还为您的手机提供出站和入站 SSH 功能!因此,您实际上可以从其他计算机登录到您的手机!很酷。

Frankly, I think Terminal-IDE is a FANTASTIC contribution to the Android environment.

坦率地说,我认为 Terminal-IDE 是对 Android 环境的巨大贡献。

回答by Aatul Palandurkar

Above answer works fine.

以上答案工作正常。

If you are looking forward to use your Android Tablet as Android Development Tool, take a look at "AIDE - Android IDE - Java, C++". Here's a link! which is really a good option, I am currently using it and writing code on the go. Also allows to export signed APK.

如果您期待将您的 Android 平板电脑用作 Android 开发工具,请查看“AIDE - Android IDE - Java、C++”。这是一个链接!这确实是一个不错的选择,我目前正在使用它并随时随地编写代码。还允许导出签名的 APK。

回答by veganaize

I've created a portable package of the android sdk (complete with ant/jdk/jre), available here:

我已经创建了一个可移植的 android sdk 包(完整的 ant/jdk/jre),可在此处获得:

http://staticchaos.freeoda.com/android/sdk/

http://staticchaos.freeoda.com/android/sdk/

You are on your own for the IDE however.

但是,您需要自己使用 IDE。