我刚刚编译它,虽然我现在不能导入“R”类。
执行以下步骤:
首先,在 Eclipse 更新管理器中安装 Xtend SDK,通过输入“http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/”,展开节点“TMF Xtext-2.1. 0”,然后选择“Xtend2 SDK”。等待,然后重新启动 Eclipse。
在您的 Eclipse Android 项目文件夹中,编辑文件“.project”(例如,通过在 OSX 上的终端中键入“nano .project”),并将其更改为类似于此(名称除外;您实际上可以复制全部内容,并将名称改回您的项目名称):
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TestAndroidXtend</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
然后将以下内容插入到文件“.classpath”的类路径元素中:
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
我把它放在com.android.ide.eclipse.adt.ANDROID_FRAMEWORK的入口之前,也许你也应该这样做。
回到 Eclipse,用 F5 刷新项目,然后在项目的顶层创建一个文件夹“META-INF”,并创建一个空文件“MANIFEST.MF”。将这些内容粘贴到其中:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Xtend Tutorial
Bundle-SymbolicName: xtend.tutorial
Bundle-Version: 2.1.0.qualifier
Bundle-Vendor: Eclipse Modeling
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.xtext.xtend2.lib;bundle-version="2.0.0",
org.junit4,
org.aopalliance;bundle-version="1.0.0"
对您的项目执行“项目”->“清理”,您现在可以创建和使用 Xtend 类。
如前所述,我无法导入 R 类,也许 Xtend 只是在普通的“src”文件夹中查找类文件。