【发布时间】:2014-05-28 09:29:33
【问题描述】:
我有一个使用外部 jar 的库。 (Unity的东西)我怎样才能链接到它,以便ant jar命令成功?我对蚂蚁很陌生,所以我有点迷茫......
我尝试添加一个新属性:
<property name="unity.androidplayer.jarfile" value="/Applications/Unity/Unity.app/Contents/PlaybackEngines/AndroidDevelopmentPlayer/bin/"/>
<path id="classpath">
<fileset dir="${unity.androidplayer.jarfile}" includes="**/*.jar"/>
</path>
然后添加一个“编译”目标
<target name="compile"
description="Compiles project's .java files into .class files">
<javac encoding="ascii" debug="true">
<src path="${source.dir}" />
<classpath>
<pathelement location="${sdk.dir}\platforms\${target}\android.jar"/>
<pathelement location="${unity.androidplayer.jarfile}"/>
</classpath>
</javac>
</target>
但更糟糕的是,我得到更多错误:(
我还在 jar 目标中尝试了<zipgroupfileset dir="${unity.androidplayer.jarfile}" includes="*.jar" excludes="*.config"/>,但没有任何改变。
我认为我没有将${unity.androidplayer.jarfile} 添加到正确的位置。
最初我的 build.xml 看起来像这样,现在我将符号库添加到 libs/ 中,我认为这不是最佳解决方案。
<?xml version="1.0" encoding="UTF-8"?>
<project name="MyFirstApp" default="help">
<property file="local.properties" />
<property file="ant.properties" />
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<loadproperties srcFile="project.properties" />
<fail
message="sdk.dir is missing. Make sure blah blah..."
unless="sdk.dir"
/>
<!-- Jar target to make it a library -->
<target name="jar" depends="debug">
<jar
destfile="bin/MySuperLibrary.jar"
basedir="bin/classes"
includes="net/mycompany/myapp/*"
/>
</target>
<import file="custom_rules.xml" optional="true" />
<import file="${sdk.dir}/tools/ant/build.xml" />
非常感谢任何帮助
更新
这是我得到的结果:
$ ant jar
Buildfile: /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.6.2
[checkenv] Installed at /Users/guillermo.enriquez/Downloads/adt-bundle-mac-x86_64-20140321/sdk
-setup:
[echo] Project Name: MyFirstApp
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.3
[echo] Resolving Build Target for MyFirstApp...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/bin
[mkdir] Created dir: /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/bin/res
[mkdir] Created dir: /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/bin/rsObj
[mkdir] Created dir: /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/bin/rsLibs
[mkdir] Created dir: /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/gen
[mkdir] Created dir: /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/bin/classes
[mkdir] Created dir: /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/bin/dexedLibs
[echo] ----------
[echo] Resolving Dependencies for MyFirstApp...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'debug'...
[subant] No sub-builds to iterate on
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 4 source files to /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/bin/classes
[javac] /Users/guillermo.enriquez/Documents/github/mycompany/myapp/Android/src/com/mycompany/myapp/MySource.java:22: package com.unity3d.player does not exist
[javac] import com.unity3d.player.UnityPlayer;
[javac] ^
【问题讨论】:
-
你能分享你的
ant jar命令输出吗? -
@PCoder 我刚刚添加了我的结果。我要的库好像没找到