Open bobanminic96 opened 4 years ago
Ok, so i had this two issues.
Both fixed in Build.cs . In comments after // ... it is version which was before changes!
public static void DoBuildAndroid() { string buildPath = Path.Combine(apkPath); // -not working version Path.Combine(apkPath, Application.productName); string exportPath = Path.GetFullPath(Path.Combine(ProjectPath, "../../android/UnityExport"));
if (Directory.Exists(apkPath)) Directory.Delete(apkPath, true); if (Directory.Exists(exportPath)) Directory.Delete(exportPath, true); EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle; var options = BuildOptions.AcceptExternalModificationsToPlayer; var report = BuildPipeline.BuildPlayer( GetEnabledScenes(), apkPath, BuildTarget.Android, options ); if (report.summary.result != BuildResult.Succeeded) throw new Exception("Build failed"); Copy(buildPath, exportPath); // Modify build.gradle var build_file = Path.Combine(exportPath, "build.gradle"); var build_text = File.ReadAllText(build_file); build_text = build_text.Replace("com.android.application", "com.android.library"); build_text = build_text.Replace("implementation fileTree(dir: 'libs', include: ['*.jar'])", "api fileTree(include: ['*.jar'], dir: 'libs')"); // build_text = build_text.Replace("implementation(name: 'VuforiaWrapper', ext:'aar')", "api(name: 'VuforiaWrapper', ext: 'aar')"); build_text = Regex.Replace(build_text, @"\n.*applicationId '.+'.*\n", "\n"); File.WriteAllText(build_file, build_text); // Modify AndroidManifest.xml var manifest_file = Path.Combine(exportPath, "unityLibrary/src/main/AndroidManifest.xml"); // -not working version, missed 'unityLibrary/' + src/main/AndroidManifest.xml"); var manifest_text = File.ReadAllText(manifest_file); manifest_text = Regex.Replace(manifest_text, @"<application .*>", "<application>"); Regex regex = new Regex(@"<activity.*>(\s|\S)+?</activity>", RegexOptions.Multiline); manifest_text = regex.Replace(manifest_text, ""); File.WriteAllText(manifest_file, manifest_text); }
Cheers!
Ok, so i had this two issues.
Both fixed in Build.cs . In comments after // ... it is version which was before changes!
public static void DoBuildAndroid() { string buildPath = Path.Combine(apkPath); // -not working version Path.Combine(apkPath, Application.productName); string exportPath = Path.GetFullPath(Path.Combine(ProjectPath, "../../android/UnityExport"));
Cheers!