I got an android 2.2 device that often will throw me an error on the pushing process, after compiling the whole project. The compiling process does take about 3 minutes and whanever I get the error, I have to try again which sums linearly up on the time it takes to test on the device. I have no such issues with another android 3.1 device and all that is actually beyond the point:
Is there any way to skip the compiling step and just push / send the APK so I can hugely minimize this bottleneck?
Of course, since you have the Android SDK installed, you also have the Android Debug Bridge (adb.exe), which is somewhere in the platform-tools folder.
Just open the command line and type adb install YourGamesAPKFile.apk (or if it doesn’t work, adb install -r YourGamesAPKFile.apk) and adb will push it on the device.
Here you go, just put this in a C# script in Assets/Editor.
The first time it asks you for the locations of the android debug bridge exe and the apk file. These are stored in the PlayerPrefs for subsequent runs.
P.S.
I tried to post this as a comment, but the formatting was crap.
using System;
using System.Diagnostics;
using System.IO;
using UnityEditor;
using UnityEngine;
using Debug = UnityEngine.Debug;
public class BuildPlayer : MonoBehaviour {
[MenuItem("Build/Push To Android")]
public static void PushToAndroid() {
string apkLocation = PlayerPrefs.GetString("APK location");
if (string.IsNullOrEmpty(apkLocation) || !File.Exists(apkLocation))
apkLocation = EditorUtility.OpenFilePanel("Find APK", Environment.CurrentDirectory, "apk");
if (string.IsNullOrEmpty(apkLocation) || !File.Exists(apkLocation)) {
Debug.LogError("Cannot find .apk file.");
return;
}
PlayerPrefs.SetString("APK location", apkLocation);
string adbLocation = PlayerPrefs.GetString("Android debug bridge location");
if (string.IsNullOrEmpty(apkLocation) || !File.Exists(adbLocation))
adbLocation = EditorUtility.OpenFilePanel("Android debug bridge", Environment.CurrentDirectory, "exe");
if (string.IsNullOrEmpty(apkLocation) || !File.Exists(adbLocation)) {
Debug.LogError("Cannot find adb.exe.");
return;
}
PlayerPrefs.SetString("Android debug bridge location", adbLocation);
ProcessStartInfo info = new ProcessStartInfo {
FileName = adbLocation,
Arguments = string.Format("install -r \"{0}\"", apkLocation),
WorkingDirectory = Path.GetDirectoryName(adbLocation),
};
Process.Start(info);
}
}
Neat script. Makes it really fast to test an apk-only build on the phone.
Has anyone made a script that installs an obb-expansion file as well?
I tried adding code for .obb to be handled the same as the apk-file, but that did not work out. ,Neat script. Makes it so fast to install an apk-only build.
How would I go about to install a build with an .obb-expansion file?
I tried adding an obb-file the same way as the .apk-file was handled, but that did not work. The obb file is disregarded.
Has anyone made a script to install both apk and obb files?