android与ant许可证库依赖关系

问题描述:

我需要使用ANT与Android构建过程,因为最后我需要创建两个版本的应用程序(完整& LITE)。 当我使用命令行工具创建新项目时,它会为我生成所有必需的构建文件(build.xml,local.properties,build.properties和default.properties,以及oh和proguard.cfg)。我的完整版本的应用程序需要一个市场许可证书库(位于我的$ {sdk.dir}/extras/google/market_licensing/library中。因此,在Eclipse中我定义了这个库的位置,如果我从Eclipse运行我的应用程序。 现在,如果我在我的应用程序运行Ant脚本android与ant许可证库依赖关系

${my.project-home}$ ant 
Buildfile: ${my.project-home}/build.xml 
    [setup] Android SDK Tools Revision 10 
    [setup] Project Target: Android 2.1-update1 
    [setup] API level: 7 
    [setup] 
    [setup] ------------------ 
    [setup] Resolving library dependencies: 

BUILD FAILED 
${my.project-home}/build.xml:77: ../../../android-sdk-mac_86/extras/google/market_licensing/library resolve to a path with no default.properties file for project ${my.project-home} 

我default.properties样子

target=android-7 
android.library=false 
android.library.reference.1=../../../android-sdk-mac_86/extras/google/market_licensing/library 

而且我的build.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project name="MyMeasures"> 

<!-- The local.properties file is created and updated by the 'android' 
    tool. 
    It contains the path to the SDK. It should *NOT* be checked into 
    Version Control Systems. --> 
    <property file="local.properties" /> 

    <!-- The build.properties file can be created by you and is never touched 
     by the 'android' tool. This is the place to change some of the 
     default property values used by the Ant rules. 
     Here are some properties you may want to change/update: 

     source.dir 
      The name of the source directory. Default is 'src'. 
     out.dir 
      The name of the output directory. Default is 'bin'. 

     Properties related to the SDK location or the project target should 
     be updated using the 'android' tool with the 'update' action. 

     This file is an integral part of the build system for your 
     application and should be checked into Version Control Systems. 

     --> 
    <property file="build.properties" /> 

    <!-- The default.properties file is created and updated by the 'android' 
     tool, as well as ADT. 
     This file is an integral part of the build system for your 
     application and should be checked into Version Control Systems. --> 
    <property file="default.properties" /> 


    <!-- Required pre-setup import --> 
    <import file="${sdk.dir}/tools/ant/pre_setup.xml" /> 


<!-- extension targets. Uncomment the ones where you want to do custom work 
    in between standard targets --> 

    <target name="-pre-build"> 
    </target> 
    <target name="-pre-compile"> 
    </target> 

<!-- [This is typically used for code obfuscation. 
    Compiled code location: ${out.classes.absolute.dir} 
    If this is not done in place, override ${out.dex.input.absolute.dir}] 
    <target name="-post-compile"> 
    </target> 
--> 

    <!-- Execute the Android Setup task that will setup some properties 
     specific to the target, and import the build rules files. 

     The rules file is imported from 
      <SDK>/tools/ant/ 
     Depending on the project type it can be either: 
     - main_rules.xml 
     - lib_rules.xml 
     - test_rules.xml 

     To customize existing targets, there are two options: 
     - Customize only one target: 
      - copy/paste the target into this file, *before* the 
       <setup> task. 
      - customize it to your needs. 
     - Customize the whole script. 
      - copy/paste the content of the rules files (minus the top node) 
       into this file, *after* the <setup> task 
      - disable the import of the rules by changing the setup task 
       below to <setup import="false" />. 
      - customize to your needs. 
    --> 
    <setup /> 

</project> 

I D的唯一的事o现在在build.xml中是我取消注释-pre-build-pre-compile,但他们什么都不做......我也尝试将它们评论回来,它是相同的结果。

有没有人用过ant的市场许可证书库?

我没有使用这个库,但是我发现对于需要第三方jar的Ant构建,需要在'my_project_home'(即与'src'相同的级别)下创建一个目录'libs'。把罐子放在那里。 main_rules.xml中的目标应该能够找到它。

+0

是的,这是所有真实的。这里的问题在于,市场许可证库实际上不是库(jar文件),而是需要编译并添加到类中的源代码。dex – zmeda 2011-04-19 18:45:53

+0

是的,我看到你的问题,很好的问题。其他用户建议,只要你使用相对路径,它应该工作。我看到你有一个相对路径,所以只要你的sdk基础在用户/鲍里斯下,我不能看到麻烦在哪里,对不起。 – NickT 2011-04-19 19:45:36

+0

关于这个最有趣的是,如果我从Eclipse“编译安装”(右键单击项目 - >运行方式 - > Android应用程序)它的工作原理。当我想使用buildin ant时,上面显示的错误是... WTF? – zmeda 2011-04-20 07:03:39

zmeda检查额外LVM文件夹,我认为它缺少default.properties file..at至少,这是你的错误信息告诉你..

+0

在我的项目文件夹中有default.properties。其实这个文件的内容在问题本身提到。 – zmeda 2011-05-30 14:27:38

嗨,你需要把到库项目的引用中主应用程序的build.properties文件。它应该看起来像:

android.library.reference.1=../path-to/library-project 

那么只要该项目也有一个工作蚂蚁的build.xml将建立和包含在你的应用程序。

更多细节here

+0

build.xml在许可库中不存在。 – Chloe 2012-04-05 02:16:00

+0

如果build.xml不存在,那么你将无法使用Ant来构建它。您需要使用'android update project'命令 – 2012-05-01 13:20:16

点点旧的话题,但也许它可以帮助别人。我有同样的问题和麻烦

系统终于发现来源: WIN7,最后Eclipse和旧的Android工具

创建的build.xml与

android update project --path . 

添加库(IES)为默认值。属性如

android.library.reference.1=..\dir\MyLibrary 

但这不起作用...最后我找到了解决方案。 这个作品

android.library.reference.1=..\\dir\\MyLibrary 

希望这可以帮助别人......

+0

'android.bat update project -path licensing-library /'创建一个。已经有了正确路径的default.properties行。缺少build.xml,但手动从另一个应用程序复制并更改了名称。仍然没有工作。该更新表示它更新了local.properties(sdk.dir)。我不知道以前是什么,但自从我安装它之后应该是正确的。我也将project.properties中的目标更改为与我的项目相同的'android-10'。不确定这有什么影响。 – Chloe 2012-04-05 02:23:25