zoukankan      html  css  js  c++  java
  • Unity2019及Unity2020打包android的环境配置

    2019安卓打包只有gradle模式了,因为谷歌把adt删了

    unity2019可以自定义gradle模板,国内请把repo地址改成阿里云的源

    unity2019打apk配置

    引擎版本:unity2019.3.7f1

    android sdk,我仅保留28,29三个平台,system-images 仅保留23,29压缩后是2.5G,Android SDK Tools Version>26.1.1

    • platforms
    • system-images
    • build-tools

    jdk提示需要JDK1.8 64位

    家里电脑上安装的是:openjdk/16,打包会弹出提示版本不匹配,所以还是请安装JDK而不是OpenJDK

    华为JDK国内镜像:https://mirrors.huaweicloud.com/openjdk/

    提示需要JDK1.8

    此环境配置打包出来的APK可在mumu模拟器安卓6.0上正常跑

    image-20210328234504952

    拷贝.gradle到离线环境

    在断网的情况下,使用unity2018.4.15在打包apk时会报无法连接到远程的google.xxx,无法打包出apk,尝试过从其它电脑拷贝.gradle到打包机上,还是出现一样的提示,所以放弃离线的方法。

    修改Unity的gradle为阿里云

    以unity2019.3.7f1为例,在Unity的安装目录下,找到:PlaybackEngines/AndroidPlayer/Tools/GradleTemplates/baseProjectTemplate.gradle

    替换这个文件的内容为如下,重启Unity进行build,下载一次之后后面build就会很快了。

    // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
    
    allprojects {
        buildscript {
            repositories {**ARTIFACTORYREPOSITORY**
                maven{ url 'https://maven.aliyun.com/repository/google'}
                //google()
                maven{ url 'https://maven.aliyun.com/repository/jcenter'}
                //jcenter()
            }
    
            dependencies {
                // If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
                // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
                // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
                // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
                classpath 'com.android.tools.build:gradle:3.4.0'
                **BUILD_SCRIPT_DEPS**
            }
        }
    
        repositories {**ARTIFACTORYREPOSITORY**
                maven{ url 'https://maven.aliyun.com/repository/google'}
                //google()
                maven{ url 'https://maven.aliyun.com/repository/jcenter'}
                //jcenter()
            flatDir {
                dirs "${project(':unityLibrary').projectDir}/libs"
            }
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
  • 相关阅读:
    将才和帅才之的区别
    百胜集团XX:BPM实现业务流程全过程无缝链接(案例)
    心、肝、脾、肺、肾五脏解说+ 五脏六腑的作用
    人体的五行属性
    易经卦的通例
    《孙子兵法》中的企业领导艺术和方法
    五行盘谱
    大容量高并发性服务器组的技术解析
    中华哲学的领导艺术
    如何在WINDOW环境下搭建ActivateMQ和zookeeper集群环境
  • 原文地址:https://www.cnblogs.com/zhaoqingqing/p/14761582.html
Copyright © 2011-2022 走看看