Windows和Mac上的Android图书馆项目 [英] Android Library Projects on Windows and Mac

查看:159
本文介绍了Windows和Mac上的Android图书馆项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在代表我的两个Android开发人员团队提出这个问题。我使用Windows,我的合作伙伴使用Macbook。当通过Git共享一个项目时, classpaths 意外地搞砸了。以下是一些意见:




  • 引用的库项目(最初工作)无法解析。

  • 通过Java Build Path中的项目选项卡添加时,可以找到库。

  • 但是应用程序崩溃(由于 NoClassDefFoundError ),再次指向一个混乱的构建路径结构。

  • Mac上最初引用的库项目用于直接在构建路径中显示为JAR。现在他们在Android依赖关系下,这是奇怪的(前者更多)。

  • 在Windows上,上述JAR一直在依赖关系和参考库下。



我想以一种我们可以在Git上分享项目并在将来无缝工作的方式来解决这个问题。 :

解决方案

一个选项是:




  • 不是版本 .classpath

  • 版本一个classpath 模板

  • 根据代码签出的当前平台生成正确的类路径。



这被称为, Pro Git book



请注意,您可以轻松地从repo:

$ b删除(不在本地删除) .classpath
$ b

  git rm --cached  -  .classpath 
git add -u。
git commit -m删除.classpath
git push


I'm asking this question on behalf of my team of two Android devs. I use Windows and my partner uses a Macbook. When sharing a project through Git, the classpaths accidentally got messed up. Here are a few observations:

  • The library projects referenced (working initially) can't be resolved anymore.
  • When adding through the Projects tab in 'Java Build Path', the libraries can be found.
  • But the app crashes (due to NoClassDefFoundError), again pointing towards a messy build path structure.
  • Initially referenced library projects on the Mac used to appear directly in the build path as JARs. Now they do under Android Dependencies, which is weird (the former more).
  • On the Windows, the above JARs have always been under Dependencies and Referenced Libraries.

I'd like to resolve this issue in a way that we can share the project on Git and work seamlessly in the future. :)

解决方案

One option is to:

  • not version .classpath,
  • version a classpath template
  • generate the right classpath depending on the current platform where the code is checked out.

That is called a content filter driver, here a smudge script, which will be called automatically (hence the "seamless" aspect) on git checkout, and will generate the actual .classpath (otherwise not versioned and add in the .gitignore)

(image shown in "Customizing Git - Git Attributes", from "Pro Git book")

Note that you can easily remove (without deleting it locally) the .classpath from the repo:

git rm --cached -- .classpath
git add -u .
git commit -m "Delete .classpath"
git push

这篇关于Windows和Mac上的Android图书馆项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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