包括谷歌的AdMob SDK使用Ant使用 [英] Including Google AdMob SDK to use with Ant
问题描述
我使用(新?),使用上的这个谷歌网站。我们应该整合 GoogleAdMobAdsSdk-4.0.4.jar
文件导入到我们的项目。问题是:我们如何利用这种蚂蚁怎么样?我在Eclipse中工作正常(它会自动进入的.classpath
文件),但与蚂蚁它抛出了大量的找不到的问题时,蚂蚁发布
ING。
I'm using the (new?) AdMob SDK using instructions on this Google site. We are supposed to integrate the GoogleAdMobAdsSdk-4.0.4.jar
file into our project. Problem is: how do we do this using Ant? I works fine in Eclipse (it goes automatically into the .classpath
file), but with Ant it throws a lot of "cannot find" problems when ant release
ing.
在哪里,我怎么包括引用,罐子?我怀疑我应该做它的build.xml
,但我不知道怎么样。
Where and how do I include the reference to that jar? I suspect I should do it in build.xml
, but I'm not sure how.
我复制源文件夹,在其他地方所以不会惹我的Eclipse项目文件夹。
I copy the source folder elsewhere so it won't mess with my eclipse project folder.
//编辑:
让我更加具体:它会自动工作,如果我只是把罐子到库
文件夹,但我想知道如果我能使用的jar如果罐子位于其它地方。 不管怎么说,我的问题就解决了......我可以编译付诸库。我将以此作为一个好奇的问题。不着急。
Let me be more specific: it works automatically if I just put the jar into libs
folder, but I wanted to know if I could use the jar if the jar is located somewhere else. Anyway, my problem is solved... I can compile putting it into libs. I will take this as a curiosity question. No rush.
下面是.classpath文件,下文。让我说,这不仅使Eclipse的一个区别,但蚂蚁似乎并不使用它:
Here is .classpath file, below. Let me say it only makes a difference in Eclipse, but Ant does not seem to use it:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="src" path="/android_licensing"/>
<classpathentry kind="lib" path="C:/Users/David/Documents/program/eclipse/GoogleAdMobAdsSdk-4.0.4.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
蚂蚁错误:
compile:
[javac] C:\android-sdk-windows\tools\ant\main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 35 source files to C:\Users\David\Documents\program\eclipse\MyApp\9-branch\aaa\bin\classes
[javac] C:\Users\David\Documents\program\eclipse\MyApp\9-branch\v9\src\net\myapp\ui\MainActivity.java:116: package com.google.ads does not exist
[javac] import com.google.ads.*;
[javac] ^
[javac] C:\Users\David\Documents\program\eclipse\MyApp\9-branch\v9\src\net\myapp\ui\MainActivity.java:143: cannot find symbol
[javac] symbol : class AdView
[javac] location: class net.myapp.ui.MainActivity
[javac] AdView adView;
[javac] ^
我试着寻找到main_rules,我可以看到它声明的库文件夹作为罐子的地方,不过,我想知道如果有一个简单的方法,每个项目行的code定制这一点。
I've tried looking into main_rules, and I can see where it declares the libs folder as a place for jars, but still, I wondering if there is a simple way, per-project line of code to customize this.
感谢。
推荐答案
不幸的是,这是不容易的事,因为罐子在main_rules.xml处理方式:
Unfortunately, this isn't easy to do, due to the way jars are processed in main_rules.xml:
<!-- Directory for the third party java libraries -->
<property name="jar.libs.dir" value="libs" />
<property name="jar.libs.absolute.dir" location="${jar.libs.dir}" />
<!-- create a path with all the jar files, from the main project and the
libraries -->
<path id="jar.libs.ref">
<fileset dir="${jar.libs.absolute.dir}" includes="*.jar" />
<path refid="project.libraries.jars" />
</path>
看起来在一个目录中,并建立从那里所有的文件的路径。鉴于AdMob的罐子有一个嵌入式的版本号,我建议你坚持保留一个副本在项目库目录。
It looks in one directory, and builds a path from all the files in there. Given that the admob jar has an embedded version number, I'd suggest you stick with keeping a copy in the project libs directory.
如果您使用SVN,您可以使用一个外部定义拔罐子到一个子目录,并使用副本任务 - pre-编译移动最新一进库;这一切都取决于有多少人(或机器)你共享code与
If you use SVN, you could use an externals definition to pull the jar into a subdirectory, and using a copy task at -pre-compile to move the latest one into libs; it all depends how many people (or machines) you're sharing the code with
我想不出创建维护不只是复制罐子少一种优雅的方式。
I can't think of an elegant way that creates less maintenance than just copying the jar.
这篇关于包括谷歌的AdMob SDK使用Ant使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!