简体   繁体   English

在Mac / OSX上创建便携式Android / Eclipse

[英]Create a portable Android/Eclipse on Mac/OSX

I'm trying to create a portable environment (USB Flash/Disk) that can be copied from one device to another - and work "out of the box" on a Mac/OSX (10.10.x environment) specifically. 我正在尝试创建一个可从一个设备复制到另一个设备的便携式环境(USB闪存/磁盘),并专门在Mac / OSX(10.10.x环境)上“开箱即用”工作。 My purpose for this, is I'm teaching a "Portable Programming" class next semester, and I want to be able to just copy (or give the student a .zip file), have them expand it on a specifically named volume, and the environment works. 我的目的是,我下学期要教一门“便携式编程”课,我希望能够复制(或给学生一个.zip文件),让他们将其扩展到专门命名的卷上,然后环境有效。 This includes the SDK version(s), AVDs, etc. I've got everything apparently working (so far), but have a problem with the AVDs. 这包括SDK版本,AVD等。到目前为止,我似乎一切正常,但是AVD出现了问题。

This is a new install, using latest Eclipse, etc. 这是新安装,使用最新的Eclipse等。

I'd hoped to find these directories, etc. within an XML/INI file, and use an editor or sed to change the strings, but can't seem to find the directory names of anything I've needed to change so far within an XML/INI file within the unzipped Android directory - but don't see them. 我希望可以在XML / INI文件中找到这些目录等,并使用编辑器或sed来更改字符串,但似乎找不到到目前为止我需要更改的任何内容的目录名。未解压缩的Android目录中的XML / INI文件-但看不到它们。

I do see a reference within Preferences->Android->Build "Default debug keystore" that references ~./android - but it is not editable. 我确实在Preferences-> Android-> Build“ Default debug keystore”中看到一个引用〜。/ android的引用,但是它不可编辑。 There IS a "custom" debug keystore setting on the same dialog page, but changing it does not seem to have an effect on the AVDs and their location. 在同一对话框页面上有一个“自定义”调试密钥库设置,但是更改它似乎对AVD及其位置没有影响。 So far, that's the ONLY reference I've found for my home directory. 到目前为止,这是我为主目录找到的唯一参考。 I've looked at the Eclipse CLI at eclipse.org , but don't seem to see anything relating to this issue (at least not anything that's ringing a bell with me). 我已经在eclipse.org上查看了Eclipse CLI,但是似乎看不到与此问题有关的任何东西(至少没有发现任何与我有关的东西)。

So - how can I change my default "home" directory (without boogering up the environment, etc.) for Eclipse/Android, so my AVDs (and whatever else I HAVEN'T run into yet), can be installed and used/run from the USB drive/stick? 所以-如何为Eclipse / Android更改默认的“主”目录(不增加环境等),因此可以安装和使用我的AVD(以及我可能尚未遇到的任何其他文件)从USB驱动器/棒?

Please - I DO NOT WANT links to other "portable" packages, as I'm not sure what's actually been altered in them (and probably not current, and an update is likely to hose everything anyway), and don't want to pass along anything to students. 请-我不希望链接到其他“便携式”软件包,因为我不确定它们中实际更改的内容(可能不是最新的,而且无论如何更新都可能使所有内容失效),并且不想通过对学生来说。 I'm downloading official packages from official locations, and want to keep it that way. 我正在从官方位置下载官方软件包,并希望保持这种状态。 So I'm only looking for things that can be fixed/edited within an officially installed environment to get the effect I'm looking for. 因此,我只是在寻找可以在正式安装的环境中进行固定/编辑的东西,以获得我想要的效果。 Thanks! 谢谢!

Found this at Launch mac eclipse with environment variables set 启动mac eclipse并设置了环境变量的情况下发现了这一点

There is an alternate solution which involves replacing the executable that is run by MacOS X when the user launches the Eclipse application with a shell wrapper that sets up the environment. 还有一个替代解决方案,其中涉及当用户使用设置环境的外壳包装程序启动Eclipse应用程序时,替换由MacOS X运行的可执行文件。

Create an empty text file called "eclipse.sh" in the Eclipse application bundle directory /Applications/eclipse/Eclipse.app/Contents/MacOS. 在Eclipse应用程序捆绑目录/Applications/eclipse/Eclipse.app/Contents/MacOS中创建一个名为“ eclipse.sh”的空文本文件。

Open the eclipse.sh in a text editor an enter the following contents: 在文本编辑器中打开eclipse.sh,然后输入以下内容:

#!/bin/sh

export ENV_VAR1=value
export ENV_VAR2=value

logger "`dirname \"$0\"`/eclipse"

exec "`dirname \"$0\"`/eclipse" $@

In the example ENV_VAR1 and ENV_VAR2 are the environment variables being set up. 在示例中,ENV_VAR1和ENV_VAR2是正在设置的环境变量。 These variables will be visible to processes launched from within Eclipse. 从Eclipse内部启动的进程将看到这些变量。 The logger command will just log the path of the eclipse executable to the system.log as a debugging aid. logger命令仅将eclipse可执行文件的路径记录到system.log中,以作为调试辅助工具。

In the Terminal set the executable flag of the shell script eclipse.sh, ie: 在终端中,设置外壳脚本eclipse.sh的可执行标志,即:

chmod +x /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.sh

Open the Eclipse.app Info.plist and change the value for the key CFBundleExecutable from eclipse to eclipse.sh. 打开Eclipse.app Info.plist,并将CFBundleExecutable键的值从eclipse更改为eclipse.sh。

MacOS X does not automatically detect that the Eclipse.app's Info.plist has changed. MacOS X不会自动检测到Eclipse.app的Info.plist已更改。 Therefore you need to force update the LaunchService database in the Terminal by using the lsregister command: 因此,您需要使用lsregister命令在终端中强制更新LaunchService数据库:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app

The next time you launch Eclipse.app from the Dock or from the Finder the environment variables should be set. 下次从Dock或Finder启动Eclipse.app时,应设置环境变量。

It took me a while to research, as that info was from Sep. '09, which was back in Snow Leopard (OSX 10.6) days. 我花了一些时间进行研究,因为该信息是从09年9月开始的,那是在雪豹(OSX 10.6)时代。 I'm now running 10.10, and while some things don't change - a LOT has changed, so it took a while to research the above approach and make sure it wasn't going to do some potential damage to the installation. 我现在正在运行10.10,尽管某些内容没有更改-很多已更改,所以花了一些时间研究上述方法并确保它不会对安装造成潜在的损害。 A LOT of under-the-cover stuff has changed in those 4 versions, and I wasn't willing to just take off with it. 在这4个版本中,很多秘密的东西已经改变,我不愿意随便拿走它。 I've also not found a good explanation of exactly what ANDROID_SDK_HOME actually controls - although this above approach seems to work - so far. 到目前为止,我仍然没有找到关于ANDROID_SDK_HOME实际控制的确切信息的很好的解释-尽管上述方法似乎可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM