- Home /
GooglePlayDownloader crashes on FetchOBB()
I'm currently working on splitting our application so that we can surpass the 50 MB limit, but I'm running into issues actually testing whether or not the code for downloading the OBB works. The issue occurs like so:
Open up the app, it detects that the OBB is not present and presents a button to fetch the obb
Pushing the button crashes the game with "Unfortunately, __ has stopped"
Going back to the home screen shows a notification that says "Looking for resources to download"
My symptoms are exactly the same as http://answers.unity3d.com/questions/779103/crash-on-android-when-trying-to-download-obb.html however their issue was resolved due to an issue with their public key. I've pretty much triple checked mine and it seems to be completely fine. I have it assigned to a string which is then assigned to the BASE64_PUBLIC_KEY. The string itself has no spaces and is just a huge string of characters which is identical to what google gave me for that specific app.
I do have some other things to note about my error though:
Downloading the game from the store works because it downloads the obb at the same time. I haven't actually tested downloading only the apk and then downloading the obb from code because I don't know a way to only get the apk from the store.
I've been testing this by uploading the apk directly to my phone and then when the game is live on the store, testing the FetchOBB() method. I don't know downloading the apk from the google store is required for the system to know where to get the obb
The actual error I'm running into, according to logcat, is:
E/AndroidRuntime(27999): Caused by: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.android.vending.licensing.ILicensingService } E/AndroidRuntime(27999): at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1674) E/AndroidRuntime(27999): at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1773) E/AndroidRuntime(27999): at android.app.ContextImpl.bindService(ContextImpl.java:1751) E/AndroidRuntime(27999): at android.content.ContextWrapper.bindService(ContextWrapper.java:538) E/AndroidRuntime(27999): at com.unity3d.plugin.downloader.c.j.a(Unknown Source) E/AndroidRuntime(27999): at com.unity3d.plugin.downloader.b.s.run(Unknown Source) E/AndroidRuntime(27999): at android.os.Handler.handleCallback(Handler.java:739) E/AndroidRuntime(27999): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime(27999): at android.os.Looper.loop(Looper.java:135) E/AndroidRuntime(27999): at android.app.ActivityThread.main(ActivityThread.java:5221) E/AndroidRuntime(27999): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(27999): at java.lang.reflect.Method.invoke(Method.java:372) E/AndroidRuntime(27999): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) E/AndroidRuntime(27999): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
And lastly, the code I'm actually running
using UnityEngine;
using System.Collections;
public class ExpansionDownloader : MonoBehaviour
{
void OnGUI()
{
if (!GooglePlayDownloader.RunningOnAndroid())
{
GUI.Label(new Rect(10, 10, Screen.width-10, 20), "Use GooglePlayDownloader only on Android device!");
return;
}
string expPath = GooglePlayDownloader.GetExpansionFilePath();
if (expPath == null)
{
GUI.Label(new Rect(10, 10, Screen.width-10, 20), "External storage is not available!");
}
else
{
string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath);
GUI.Label(new Rect(10, 10, Screen.width-10, 20), "Main = ..." + ( mainPath == null ? " NOT AVAILABLE" : mainPath.Substring(expPath.Length)));
GUI.Label(new Rect(10, 25, Screen.width-10, 20), "Patch = ..." + (patchPath == null ? " NOT AVAILABLE" : patchPath.Substring(expPath.Length)));
if (mainPath == null && patchPath == null)
{
if (GUI.Button(new Rect(10, 100, 400, 400), "Fetch OBBs"))
GooglePlayDownloader.FetchOBB();
}
else
{
Application.LoadLevel("CutScene");
}
}
}
}
Answer by GekidoRising · Jan 23, 2015 at 06:16 PM
EDIT: The following bug is now fixed for Android 5+
Upon testing this on another phone, I've learned that this bug only seems to be occurring on my phone specifically.
http://reign-studios.net/forums/viewtopic.php?f=7&t=246
In the above link for a different plugin, people are reporting the exact same error being specific to Android 5.0.1 on the Nexus 5. This renders the bug rather irrelevant because every time I downloaded the app from the store, the obb was always downloaded with it.
I'm not 100% sure that will be the case for every Nexus 5 out there but as far as I can tell, I've done everything I can on my end, so here's to hoping that it gets fixed on whatever side it's broken.
This issue seems to be actual for all Android 5.0+.
Here is the fixed plugin and code: https://github.com/Unity-Technologies/UnityOBBDownloader
You may just download the updated jar file in bin/ directory and replace it in your Unity project.
Answer by Yury-Habets · Jan 23, 2015 at 10:40 AM
Please take a look at these:
http://forum.unity3d.com/threads/google-play-obb-downloader-plugin-crashes-on-lollipop.290861/
https://code.google.com/p/android-developer-preview/issues/detail?id=1674
In the meanwhile, I will take a look and will try to fix it in the official package.
I took a look at our current API and it turns out that we actually had the target sdk set to API 9 and that API 21 isn't even an option!
Regardless, I decided that I'd set the target SD$$anonymous$$ to API 18 (the highest one we could target) and I added
intent.Call<AndroidJavaObject>("setPackage", "com.android.vending");
to the FetchOBB() method directly above the "addFlags" call. Unfortunately, I still seem to be getting the same crash as before with no change in the error. I'm currently in the midst of letting the play store make the alpha build downloadable in the hopes that the crash was happening because the obb wasn't present in the store yet.
I don't know if me answering my own question sends you an email so I thought I'd just send a quick heads up to say that I figured it out but for reasons mentioned in my answer, it still needs looking into either on Unity's or Android's end.
Your answer
Follow this Question
Related Questions
Does Resources.Load() not work with Android Split Application 2 Answers
PlayFullScreenMovie doesn't work with Android Expansion APK? 0 Answers
Android Google Play OBB Downloader 1 Answer
OBB expansion files problem 1 Answer
Expansion/Database help 2 Answers