2013-06-11 7 views
2

우리는 android ant build를 수정했습니다. build.xml 파일은 이제 다음과 같습니다 : 수정 된 android 빌드 gradle

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

<!-- This is a modified version of the "dex-helper" macro. It added the "input-dir" and 
    "output-dex-file" required attributes. 
    Configurable macro, which allows to pass as parameters input directory, 
    output directory, output dex filename and external libraries to dex (optional) --> 
<macrodef name="dex-helper-mod"> 
    <attribute name="input-dir" /> 
    <attribute name="output-dex-file" /> 
    <element name="external-libs" optional="yes" /> 
    <element name="extra-parameters" optional="yes" /> 
    <attribute name="nolocals" default="false" /> 
    <sequential> 

     <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" /> 
     <!-- set the secondary dx input: the project (and library) jar files 
      This has been disabled in order to avoid redundant class definitions in the plugin and the core app 
     <if> 
      <condition> 
       <isreference refid="out.dex.jar.input.ref" /> 
      </condition> 
      <else> 
       <path id="out.dex.jar.input.ref"> 
        <path refid="project.all.jars.path" /> 
       </path> 
      </else> 
     </if> --> 

     <echo>Converting compiled files and external libraries into @{output-dex-file}...</echo> 
     <dex executable="${dx}" output="@{output-dex-file}" nolocals="@{nolocals}" verbose="${verbose}"> 
      <path path="@{input-dir}" /> 
      <!-- <path refid="out.dex.jar.input.ref" /> --> 
      <external-libs /> 
     </dex> 
    </sequential> 
</macrodef> 

<!-- This is a modified version of "-dex" target taken from $SDK/tools/ant/main_rules.xml --> 
<!-- Converts this project's .class files into .dex files --> 
<target name="-dex" depends="-compile, -post-compile, -obfuscate" unless="do.not.compile"> 
    <if condition="${manifest.hasCode}"> 
     <then> 

      <mkdir dir="${out.classes.absolute.dir}" /> 

      <copy todir="${out.classes.absolute.dir}"> 
       <fileset dir="${out.classes.absolute.dir}"> 

       </fileset> 
      </copy> 


      <dex-helper-mod input-dir="${out.classes.absolute.dir}" output-dex-file="${out.absolute.dir}/${dex.file.name}" /> 
     </then> 
     <else> 
      <echo>hasCode = false. Skipping...</echo> 
     </else> 
    </if> 
</target> 

<!-- version-tag: custom --> 
<import file="${sdk.dir}/tools/ant/build.xml" /> 

이제 우리는 우리의 빌드 논리가 Gradle을 위해 이동한다. 위와 같이 gradle 빌드를 수정할 수 있습니까?

+0

나는 변화가 무엇 확실하지 않다. 당신이 성취하려는 것을 우리에게 말하면 도움이 될 것입니다. –

+0

@Xav 나는 엔디 언이 이것에 대해 이야기하고 있다고 믿습니다. http://android-developers.blogspot.pt/2011/07/custom-class-loading-in-dalvik.html 나는 또한 Gradle로 달성하려고 노력하고 있습니다. –

+0

누군가 "다른"종류의 대답이 필요한 경우 어쩌면 이것이 당신이 찾고있는 것일 것입니다 : http://stackoverflow.com/q/18174022/40480 –

답변

1

다음 Gradle을 코드는 개미 스크립트에서 마이그레이션하는 데 도움이 :

android { 
    buildTypes { 
     // prevents dexing of lib classes 
     // replaces the modified ant script 
     applicationVariants.each { variant -> 
      variant.dex.libraries = new ArrayList<?>() 
     } 
    } 
} 
+0

이것이 정말로 당신의 문제를 해결합니까? 난 당신이 별도의 .dex 파일을 빌드하고 기사처럼 사용자 정의 클래스 로딩을 수행하는 사용자 정의 Ant 빌드 파일을 사용하고 있다고 생각. 그렇지 않니? 내가 Gradle의 전체 대본을 모방하는 적절한 방법을 찾았 기 때문에 나는 이것을 묻습니다. 나는 대답을 게시 할 준비가되어 있지 않다. 관심이 있으십니까, 아니면 정말로이 문제를 해결합니까? –

+0

이 스크립트는 실제로 우리의 문제를 해결합니다. – endian