public static void GenADTReleaseAPK() { //首先导出项目; GenADTProject(); //执行编译脚本; string cdProjectPath = "cd " + androidADTPath; string bulidLibProject = cdProjectPath + " && " + "android update project --target 3 --path ./berry_lib/" + " && exit"; ProcessCommand(bulidLibProject); string bulidMainProject = cdProjectPath + " && " + "android update project --target 3 --path ./HYLiveSDK/ --subprojects" + " && exit"; ProcessCommand(bulidMainProject); //开始打Release包; string antDebugGenApk = cdProjectPath + "/" + projectName + " && " + "ant release" + " && exit"; ProcessCommand(antDebugGenApk); //文件路径; string srcApkFile = "Export/Android/ADT/HYLiveSDK/bin/UnityPlayerActivity-release.apk"; string dstApkFile = "Export/Android/ADT/ReleaseApk/HYLiveSDK-" + versionCode + "-release.apk"; string srcApkUnalignedFile = "Export/Android/ADT/HYLiveSDK/bin/UnityPlayerActivity-release-unaligned.apk"; string dstApkUnalignedFile = "Export/Android/ADT/ReleaseApk/HYLiveSDK-" + versionCode + "-release-unaligned.apk"; //删除存在的APK文件; //HYIOTools.DeleteFolder(androidADTPath + "/DebugApk"); STIOTools.DeleteFolder(androidADTPath + "/ReleaseApk"); //将APK移动到指定目录; STIOTools.CopyFile(srcApkFile, dstApkFile); STIOTools.CopyFile(srcApkUnalignedFile, dstApkUnalignedFile); }
public static void GenGradleReleaseAPK() { //生成项目; GenGradleProject(); //执行脚本命令构建APK包(gradle assembleRelease); string cdProjectPath = "cd " + androidGradlePath + "/" + projectName; string gradleCMD = cdProjectPath + " && " + "gradle assembleRelease" + " && exit"; ProcessCommand(gradleCMD); //文件路径; string srcApkFile = "Export/Android/Gradle/HYLiveSDK/build/outputs/apk/HYLiveSDK-release.apk"; string dstApkFile = "Export/Android/Gradle/ReleaseApk/HYLiveSDK-" + versionCode + "-release.apk"; string srcApkUnalignedFile = "Export/Android/Gradle/HYLiveSDK/build/outputs/apk/HYLiveSDK-release-unaligned.apk"; string dstApkUnalignedFile = "Export/Android/Gradle/ReleaseApk/HYLiveSDK-" + versionCode + "-release-unaligned.apk"; //删除存在的APK文件; //HYIOTools.DeleteFolder(androidGradlePath + "/DebugApk"); STIOTools.DeleteFolder(androidADTPath + "/ReleaseApk"); //将APK移动到指定目录; STIOTools.CopyFile(srcApkFile, dstApkFile); STIOTools.CopyFile(srcApkUnalignedFile, dstApkUnalignedFile); }
public static void GenGradleProject() { //删除先前生成的工程目录; //HYIOTools.DeleteFolder(androidGradlePath + "/HYLiveSDK"); string cdGradlePath = "cd " + androidGradlePath; string removeProject = cdGradlePath + " && " + "rd/s/q " + projectName + " && exit"; DirectoryInfo mydir = new DirectoryInfo(androidGradlePath + "/" + projectName); if (mydir.Exists) { ProcessCommand(removeProject); } //项目设置; EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle; EditorUserBuildSettings.exportAsGoogleAndroidProject = true; //生成Gradle Android Project; BuildPipeline.BuildPlayer(GetAllScenes(), androidGradlePath, BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer); /*代码文件的拷贝*/ string dstCopyFile = "Export/Android/Gradle/HYLiveSDK/src/main/java/com/huya/hylivesdk/HYLiveSDK.java"; STIOTools.CopyFile(androidJavaSrc, dstCopyFile); /*Bulid 文件*/ string srcCopyBulidFile = "Assets/HYLive/Copy/Android/Gradle/build.gradle"; string dstCopyBulidFile = "Export/Android/Gradle/HYLiveSDK/build.gradle"; STIOTools.CopyFile(srcCopyBulidFile, dstCopyBulidFile); }
public static void GenADTProject() { //首先清理之前的工程; string cdADTPath = "cd " + androidADTPath; string removeProject = cdADTPath + " && " + "rd/s/q " + projectName + " && exit"; DirectoryInfo mydir = new DirectoryInfo(androidGradlePath + "/" + projectName); if (mydir.Exists) { ProcessCommand(removeProject); } //HYIOTools.DeleteFolder(androidADTPath + "/berry_lib"); //HYIOTools.DeleteFolder(androidADTPath + "/HYLiveSDK"); //项目设置; EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.ADT; EditorUserBuildSettings.exportAsGoogleAndroidProject = true; //生成ADT Android Project; BuildPipeline.BuildPlayer(GetAllScenes(), androidADTPath, BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer); /*代码文件的拷贝*/ string dstCopyFile = "Export/Android/ADT/HYLiveSDK/src/com/huya/hylivesdk/HYLiveSDK.java"; STIOTools.CopyFile(androidJavaSrc, dstCopyFile); /*项目文件修改*/ string srcCopyProjectFile = "Assets/HYLive/Copy/Android/ADT/project.properties"; string dstCopyProjectFile = "Export/Android/ADT/HYLiveSDK/project.properties"; STIOTools.CopyFile(srcCopyProjectFile, dstCopyProjectFile); /*Ant文件*/ string srcCopyAntFile = "Assets/HYLive/Copy/Android/ADT/ant.properties"; string dstCopyAntFile = "Export/Android/ADT/HYLiveSDK/ant.properties"; STIOTools.CopyFile(srcCopyAntFile, dstCopyAntFile); }