I asked this question on the android-developers group but didn't get any response, so I thought I'd try here.
The ADT eclipse plugin seems to have a pretty rigid idea of how an Android project should be structured - per http://developer.android.com/guide/developing/eclipse-adt.html, it needs to have the AndroidManifest.xml
file at the root level of the project, plus res
, assets
, gen
and src
folders at the top level, and so on.
I'm wondering if it's possible to get the plugin to be a little more flexible with the layout it recognizes. In particular, I've been using a build plugin for the (scala-based) simple-build-tool, which expects projects to be laid out in a more Maven-like fashion, like so:
src/
main/
AndroidManifest.xml
assets/
res/
scala/
java/
test/
resources
<files to include in test jar here>
scala/
<test Scala sources>
java/
<test Java sources>
(see the simple-build-tool docs).
This is a layout I'm used to from maven-based java development. When I load a project like it up in ADT, though, I get a lot of complaints about a missing AndroidManifest.xml
, a missing res
directory, and so on. These things are all present, they just aren't where ADT expects them to be.
I don't necessarily need to use ADT to build my project, but I'd like to use it (and Eclipse) for editing. Can anybody tell me whether it's possible 开发者_运维知识库to make it more flexible in the directories it uses to find various Android-related resources?
Also, can anyone tell me whether the ADT plugin is open-source? I can't seem to find a link to its source code anywhere.
(As a note, I've also been trying to wrangle sbt
to just do things in a way that ADT likes, and it's probably possible to do but it seems very tedious.)
Here's is where you can find the ADT source for r3 0.94, couldn't find the latest though
I do not believe you can change the Android project structure and have ADT understand it. It would be "very tedious" to do that even with the Ant-based command-line builds -- you'd have to make your own copy of the various Android Ant tasks, modify them to suit (and hope the underlying build tools allow what you want), then maintain them forever in the face of Android SDK updates.
Your structure is actually fairly close to the Android expectation, if you consider main/
to be the Android project. If you can convince sbt
to allow src/
instead of java/
there, and if sbt
won't complain about the resulting bin/
and gen/
you will wind up with in main/
after a compile, you might get it to work.
As far as I can tell, ADT requires those folder names, but there is a workaround: you can create "linked folders" in Eclipse. These are similar to symbolic links in Unix, but are stored in the Eclipse .project file instead of the filesystem, so they are only visible to Eclipse.
You can create one by right clicking in Eclipse the root of the project, and then selecting "Create New Folder". Click on "Advanced" and select the option to create a linked folder. Then type in where you want it to link to. You can use PROJECT_LOC at the begining to specify the project directory, so for your example you would type PROJECT_LOC/src/main/res as the folder to link to, and use the automatically generated name of "res" for the created folder.
精彩评论