2012-09-09 11 views
6

के बीच अंतर मैं अब एंड्रॉइड की निर्माण प्रक्रिया को पूरी तरह से समझने की कोशिश कर रहा हूं।build.xml और project_name.xml

मैं एंड्रॉइड के लिए इंटेलिजे आइडिया का उपयोग कर रहा हूं (जो अद्भुत उपकरण है)। मैंने IntelliJ नाम "हैलो एंड्रॉइड" में एक टेस्ट प्रोजेक्ट खोला। परियोजना नीचे

<?xml version="1.0" encoding="UTF-8"?> 
<project name="HelloAndroid" default="help"> 

    <!-- 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 ant.properties file can be created by you. It is only edited by the 
     'android' tool to add properties to it. 
     This is the place to change some Ant specific build properties. 
     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'. 

     For other overridable properties, look at the beginning of the rules 
     files in the SDK, at tools/ant/build.xml 

     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="ant.properties" /> 

    <!-- if sdk.dir was not set from one of the property file, then 
     get it from the ANDROID_HOME env var. 
     This must be done before we load project.properties since 
     the proguard config can use sdk.dir --> 
    <property environment="env" /> 
    <condition property="sdk.dir" value="${env.ANDROID_HOME}"> 
     <isset property="env.ANDROID_HOME" /> 
    </condition> 

    <!-- The project.properties file is created and updated by the 'android' 
     tool, as well as ADT. 

     This contains project specific properties such as project target, and library 
     dependencies. Lower level build properties are stored in ant.properties 
     (or in .classpath for Eclipse projects). 

     This file is an integral part of the build system for your 
     application and should be checked into Version Control Systems. --> 
    <loadproperties srcFile="project.properties" /> 

    <!-- quick check on sdk.dir --> 
    <fail 
      message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." 
      unless="sdk.dir" 
    /> 

    <!-- 
     Import per project custom build rules if present at the root of the project. 
     This is the place to put custom intermediary targets such as: 
      -pre-build 
      -pre-compile 
      -post-compile (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}) 
      -post-package 
      -post-build 
      -pre-clean 
    --> 
    <import file="custom_rules.xml" optional="true" /> 

    <!-- Import the actual build file. 

     To customize existing targets, there are two options: 
     - Customize only one target: 
      - copy/paste the target into this file, *before* the 
       <import> task. 
      - customize it to your needs. 
     - Customize the whole content of build.xml 
      - copy/paste the content of the rules files (minus the top node) 
       into this file, replacing the <import> task. 
      - customize to your needs. 

     *********************** 
     ****** IMPORTANT ****** 
     *********************** 
     In all cases you must update the value of version-tag below to read 'custom' instead of an integer, 
     in order to avoid having your file be overridden by tools such as "android update project" 
    --> 
    <!-- version-tag: 1 --> 
    <import file="${sdk.dir}/tools/ant/build.xml" /> 

</project> 

फिर इस फ़ाइल नाम build.xml, कोड है मैंने किया था IntelliJ विचार में निम्नलिखित बिल्ड -> जनरेट चींटी निर्माण और निम्नलिखित विकल्पों का चयन किया

  1. एकाधिक फ़ाइल चींटी निर्माण उत्पन्न
  2. आउटपुट फ़ाइल नाम: helloandroid
  3. UI सक्षम संकलन रूपों
  4. उपयोग JSDK defin परियोजना फाइलों से itions

इस तीन अतिरिक्त फ़ाइलें

  1. helloandroid.properties
  2. helloandroid.xml
  3. module_helloandroid.xml

helloandroid.properties की रचना हुई

path.variable.maven_repository=C\:\\Users\\abc\\.m2\\repository 
jdk.home.android_4.1_platform=C\:/Program Files (x86)/Android/android-sdk 

helloandroid.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project name="HelloAndroid" default="help"> 

    <!-- 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 ant.properties file can be created by you. It is only edited by the 
     'android' tool to add properties to it. 
     This is the place to change some Ant specific build properties. 
     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'. 

     For other overridable properties, look at the beginning of the rules 
     files in the SDK, at tools/ant/build.xml 

     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="ant.properties" /> 

    <!-- if sdk.dir was not set from one of the property file, then 
     get it from the ANDROID_HOME env var. 
     This must be done before we load project.properties since 
     the proguard config can use sdk.dir --> 
    <property environment="env" /> 
    <condition property="sdk.dir" value="${env.ANDROID_HOME}"> 
     <isset property="env.ANDROID_HOME" /> 
    </condition> 

    <!-- The project.properties file is created and updated by the 'android' 
     tool, as well as ADT. 

     This contains project specific properties such as project target, and library 
     dependencies. Lower level build properties are stored in ant.properties 
     (or in .classpath for Eclipse projects). 

     This file is an integral part of the build system for your 
     application and should be checked into Version Control Systems. --> 
    <loadproperties srcFile="project.properties" /> 

    <!-- quick check on sdk.dir --> 
    <fail 
      message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." 
      unless="sdk.dir" 
    /> 

    <!-- 
     Import per project custom build rules if present at the root of the project. 
     This is the place to put custom intermediary targets such as: 
      -pre-build 
      -pre-compile 
      -post-compile (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}) 
      -post-package 
      -post-build 
      -pre-clean 
    --> 
    <import file="custom_rules.xml" optional="true" /> 

    <!-- Import the actual build file. 

     To customize existing targets, there are two options: 
     - Customize only one target: 
      - copy/paste the target into this file, *before* the 
       <import> task. 
      - customize it to your needs. 
     - Customize the whole content of build.xml 
      - copy/paste the content of the rules files (minus the top node) 
       into this file, replacing the <import> task. 
      - customize to your needs. 

     *********************** 
     ****** IMPORTANT ****** 
     *********************** 
     In all cases you must update the value of version-tag below to read 'custom' instead of an integer, 
     in order to avoid having your file be overridden by tools such as "android update project" 
    --> 
    <!-- version-tag: 1 --> 
    <import file="${sdk.dir}/tools/ant/build.xml" /> 

</project> 

module_helloandroid।एक्सएमएल

<copy todir="${helloandroid.output.dir}"> 
    <fileset dir="${module.helloandroid.basedir}/src"> 
    <patternset refid="compiler.resources"/> 
    <type type="file"/> 
    <patternset refid="excluded.from.compilation.helloandroid"/> 
    </fileset> 
    <fileset dir="${module.helloandroid.basedir}/gen"> 
    <patternset refid="compiler.resources"/> 
    <type type="file"/> 
    <patternset refid="excluded.from.compilation.helloandroid"/> 
    </fileset> 
</copy> 

मेरे प्रश्न

  1. क्यों हमारे पास अलग build.xml और helloandroid.xml और अन्य दो फ़ाइलों?
  2. क्या इन फ़ाइलों का निर्माण प्रक्रिया में उपयोग किया जा सकता है?
  3. क्या हम इन फ़ाइलों को और अधिक चींटी निर्माण स्क्रिप्ट जोड़ने के लिए संपादित कर सकते हैं?
  4. क्यों build.xml env.ANDROID_HOME पर एक त्रुटि दिखा रहा है?
  5. क्या हैलोलोन्ड्रॉइड.एक्सएमएल jdk.home.1.6 पर एक त्रुटि दिखा रहा है?

उत्तर

2
  1. फ़ाइलों का निर्माण अन्य निर्माण फ़ाइलों को शामिल कर सकते हैं, यह एक सामान्य बात है। आपकी परियोजना का helloandroid.xmlbuild.xml फ़ाइल के समान है, आप जो भी चाहें उसे संशोधित कर सकते हैं और दूसरे को त्याग सकते हैं।build.xml फ़ाइल चींटी के लिए पसंदीदा सम्मेलन है। आपकी गुण फ़ाइल केवल गुणों को सेट करने के लिए है, और मॉड्यूल फ़ाइल को कॉल नहीं किया जाता है, लेकिन शायद मौजूद है ताकि आप इसे शामिल कर सकें और फ़ाइल प्रतिलिपि को निर्दिष्ट कर सकें।

  2. हां, बस उन्हें शामिल करें। helloandroid.properties फ़ाइल जेनेरिक project.properties फ़ाइल पर कॉल के बजाय उपयोग की जा सकती है, या आप इसे छोड़ सकते हैं।

  3. हां, कृपया उन्हें संपादित करें, हालांकि उन्हें एक आसान शुरुआत के लिए पर्याप्त होना चाहिए।

  4. ऐसा लगता है कि आपके ANDROID_HOME पर्यावरण चर सेट नहीं किए गए हैं। आप इसे इंटेलिजे के माध्यम से सेट कर सकते हैं, लेकिन मैं इसे अपने ओएस स्तर पर करने की सलाह दूंगा।

  5. ऐसा लगता है कि आपके JAVA_HOME पर्यावरण चर सेट नहीं किया गया है। आप इसे इंटेलिजे के माध्यम से सेट कर सकते हैं, लेकिन मैं इसे अपने ओएस स्तर पर करने की सलाह दूंगा।

संबंधित मुद्दे