• 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 流程
    
    
  • 相关阅读:
    Java单例模式(Singleton)以及实现
    golang 垃圾回收机制
    MySQL索引背后的数据结构及算法原理
    简述拥塞控制的四种基本算法
    分库分表
    lvalue & rvalue
    理解linux cpu load
    android使用百度地图SDK获取定位信息
    iOSUIWebView---快停下啦,你的愚蠢的行为
    【翻译自mos文章】当/var/tmp文件夹被remove掉之后,GI crash,并启动失败,原因是ohasd can not create named pipe
  • 原文地址:https://www.cnblogs.com/chongxin/p/4522672.html
Copyright © 2020-2023  润新知