如何在 Eclipse/Phonegap/Android 项目中链接 assets/www 文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6843181/
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 16:43:14  来源:igfitidea点击:

How to link assets/www folder in Eclipse / Phonegap / Android project?

androideclipsecordova

提问by sne11ius

I am working on a PhoneGap app that is supposed to run on iOS and Android. My folder structure looks like this:

我正在开发一个应该在 iOS 和 Android 上运行的 PhoneGap 应用程序。我的文件夹结构如下所示:

+-+-[app folder]
  |
  +-[android] (contains Eclipse workspace and project files)
  |
  +-[iOS] (contains XCode project files)
  |
  +-[www] (contains all html, js, css etc. files for the actual app)

It's easy to reference the www folder in the XCode project, everything there works fine.

在 XCode 项目中引用 www 文件夹很容易,那里的一切工作正常。

However, creating a link to the www folder in Eclipse doesn't work as expected: I used 'Import -> Filesystem' to create the link under the existing assets folder and everything seemed to work fine. But the files are not getting copied to the apk during the build step.
Any idea what I am doing wrong?

但是,在 Eclipse 中创建 www 文件夹的链接没有按预期工作:我使用“导入 - > 文件系统”在现有资产文件夹下创建链接,一切似乎都正常。但是在构建步骤中文件不会被复制到 apk。
知道我做错了什么吗?

采纳答案by dhaval

For windows use this command mklink /D link-name target-folderand for linux/mac use lnto create a source link. Both works for me.

对于 windows 使用此命令mklink /D link-name target-folder,对于 linux/mac 使用ln创建源链接。两者都对我有用。

回答by phatblat

This can be accomplished creating a "Linked Folder" resource in Eclipse. It's essentially the same thing as what Xcode creates when you drag any file or folder into your project and tell it to create references - just nowhere near as easy.

这可以通过在 Eclipse 中创建“链接文件夹”资源来完成。当您将任何文件或文件夹拖到项目中并告诉它创建引用时,它本质上与 Xcode 创建的内容相同 - 远没有那么容易。

The ADT Eclipse plugin expects an "assets" folder at the top level of your project, so we're going to create an /assets linked folder that references ../www, sitting right next to your project folder.

ADT Eclipse 插件需要在项目的顶层有一个“assets”文件夹,因此我们将创建一个 /assets 链接文件夹,该文件夹引用 ../www,就在您的项目文件夹旁边。

  1. File menu > New > Folder
  2. Folder name: assets
  3. Click Advanced >>
  4. Select: Link to alternate location (Linked Folder)
    • You can use Browse to select the www folder and you're done, but this option creates the link using a full path which will usually break on other team members' systems
  5. Click Variables...
  6. New
    1. Name: SIBLING_WWW_FOLDER
    2. Location: ${PROJECT_LOC}/../www
  7. OK
  8. Select SIBLING_WWW_FOLDERand click OK
  9. Finish
  1. 文件菜单 > 新建 > 文件夹
  2. 文件夹名称:资产
  3. 点击高级>>
  4. 选择:链接到备用位置(链接文件夹)
    • 您可以使用浏览来选择 www 文件夹并完成,但此选项使用完整路径创建链接,这通常会在其他团队成员的系统上中断
  5. 单击变量...
  6. 新的
    1. 名称:SIBLING_WWW_FOLDER
    2. 位置:${PROJECT_LOC}/../www
  7. 好的
  8. 选择SIBLING_WWW_FOLDER并单击确定
  9. 结束

回答by ciberado

Don't know how does it work in MacOS but I guess you can create a symbolic link with ln, putting your www folder inside Eclipse's assets. I do it both in Windows and Linux and work ok.

不知道它在 MacOS 中是如何工作的,但我想您可以使用 ln 创建一个符号链接,将您的 www 文件夹放在 Eclipse 的资产中。我在 Windows 和 Linux 中都这样做,并且工作正常。