我有一个使用外部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] ^
答案 0 :(得分:1)
日志表明问题与javac
无法在指定的类路径中找到库有关。我会在我的构建文件中尝试使用类似的东西。
<path id="android">
<fileset dir="${sdk.dir}\platforms\${target}">
<include name="*.jar"/>
</fileset>
</path>
<path id="unity">
<fileset dir="${unity.androidplayer.jarfile}">
<include name="*.jar"/>
</fileset>
</path>
...
<javac encoding="ascii" debug="true">
<src path="${source.dir}" />
<classpath>
<path refid="android"/>
<path refid="unity"/>
</classpath>
</javac>