zoukankan      html  css  js  c++  java
  • Unity Android && Ant Automate Build 之一

    这几天抽空研究下Android SDK 自动化打包。顺便温习下Unity 与 Android 交互机制。

    一、Unity 与 Android 的 消息传递机制

      Example:

      

       

      导出 Android Project

      这里为了测试,就填了包名能导出就行了

      

      Eclipse 导入之后 在 最开始启动的Activity 上加上一个被 u3d 代码调用的函数 即可

      

    1     public void BeCalledFromUnity(String arg)
    2     {
    3         UnityPlayer.UnitySendMessage("SDK", "BeCalledFromAndroid", arg);
    4     }

      

      OK

      消息通信搞定了

      

      

    二、配置 Ant 环境

    Step:

      Download Ant. Uncompress the downloaded file into a directory.
      Set environmental variables JAVA_HOME to your Java environment,
      ANT_HOME to the directory you uncompressed Ant to, and add${ANT_HOME}/bin (Unix) or %ANT_HOME%/bin (Windows) to your PATH.

    Check Installation:

        You can check the basic installation with opening a new shell and typing ant. You should get a message like this

         Buildfile: build.xml does not exist!
         Build failed


      So Ant works. This message is there because you need to write an individual buildfile for your project. With a ant -versionyou should get an output like

        Apache Ant(TM) version 1.9.2 compiled on July 8 2013

    三、With Android Project

       参考:http://www.androidengineer.com/2010/06/using-ant-to-automate-building-android.html (目前我用的是1.9.4 有一点出入)

      

          If you already have a project that you'd like to add the Ant build script to, then there is an easy command line tool you can use.

      Open up a command prompt and navigate to the base directory of your project. 

      From there, use the command:

        android update project --path .

      (PS:

       Add Path If Fail

        %ANDROID_SDK%platform-tools
        %ANDROID_SDK% ools

      )

      Here is an example of successful output:

      

       其中ant.properties 是 手工添加的,为了自动化打包签名

       

      Open up a command prompt and navigate to the base directory of your project.
      From there, use the command:
          -> ant release 

          => 打包成功   

     



    目前我们已经构建了发布版本的签名APK,下一篇我会讲讲自定义build.xml 流程
    
    
  • 相关阅读:
    VTK初学一,动画加AVI录制终于做出来了
    QCamera获取摄像头图像(转载)
    VTK初学一,比较常见的错误2
    myeclipse2014鼠标单击后光标位置背景底色为白色太难看,行号显示
    记一次跟二房东公司(非中介个人房源无中介费)租房的经历
    求16进制数据或运算后的值(即多个16进制相加的和)
    error LNK2001: 无法解析的外部符号 "public: char * __thiscall
    如何利用指向数组的指针得到数组元素个数?
    C++判断字符串是否为空的一个小问题
    C++开发中BYTE类型数组转为对应的字符串
  • 原文地址:https://www.cnblogs.com/chongxin/p/4522672.html
Copyright © 2011-2022 走看看