Splitting Android APK

So this has probably been asked before but I have been trying to get this to work for days now.

I need to split my APK as it is over androids 50mb allowance.

I’m using this Google Play OBB Downloader | Utilities Tools | Unity Asset Store but there is very little in the way of instructions so almost completely clueless as to what i need to do.

I have entered my public key into the google play downloader script. Not sure what the base64_public key bit is, i assume this doesnt need to be changed.

I tried following this tutorial: Tutorial Unity 4 apk splitting into OBB for google play but my app just crashes on launch every time.

All I want is to load a simple scene that downloads the obb and then launches my first scene. Please help

Couple of things I found while doing this, not sure if it’ll help:

  1. In GooglePlayDownloader.cs you need to put your public key in there (a static string called PUBLIC_KEY)

  2. Have a separate scene that loads first - that should load the OBB

  3. To test it is a bit of a pain, you can either put the obb file on the sd card or you can test through google play. Once you’ve created your app you have an apk and an obb. The obb needs to be named with the same convention as the app but also have the build number at the start.

For instance, if your app is com.mycompany.myapp your obb would be main.1.com.mycompany.myapp.obb

Upload both of these as a beta to google play and publish them. Wait a good while until it goes live and then test your apk on your local device and it should load the obb remotely from google play.

Thanks :slight_smile:

I didnt rename the obb so the app just gets stuck on the downloader scene, will try this now and report back in an hour or two when google play is ready thanks

So the game loads to a blue scene with a button saying get obb or something similar. I click this button and a new screen shows with a loading bar for like a split second then it returns to the blue scene and the button no longer does anything :S

I assume this means its failed to find obb or something

mmm… that’s odd, did you definitely add your public key to that GooglePlayDownloader.cs?

Might be worth running the app through logcat (use adb logcat from the android command line tools) and see what errors you’re getting - if you put them here I’ll have a look.

I’d also make sure your app is set to ‘published’ for beta (not production) as that can cause issues too. Make sure your device is also on the beta testers list.

Device is on tester list,

its published for beta

and def has the public key in the googleplaydownloader.

Ill take a look at log cat.

Thanks again

Here is the Log:

02-19 17:48:35.555: I/ActivityManager(542): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.YeahButNo.Rotator cmp=com.YeahButNo.Rotator/com.unity3d.player.UnityPlayerNativeActivity} from uid 10016 on display 0
02-19 17:48:35.638: I/ActivityManager(542): Start proc com.YeahButNo.Rotator for activity com.YeahButNo.Rotator/com.unity3d.player.UnityPlayerNativeActivity: pid=22636 uid=10141 gids={50141, 9997, 3003, 1028, 1015} abi=armeabi-v7a
02-19 17:48:35.776: V/ActivityManager(542): Display changed displayId=0
02-19 17:48:35.786: I/ActivityManager(542): Config changes=480 {1.0 234mcc?mnc en_GB ldltr sw600dp w600dp h887dp 320dpi lrg port finger -keyb/v/h -nav/h s.27}
02-19 17:48:35.790: I/InputReader(542): Reconfiguring input devices. changes=0x00000004
02-19 17:48:35.790: I/InputReader(542): Device reconfigured: id=6, name=‘elan-touchscreen’, size 1200x1920, orientation 0, mode 1, display id 0
02-19 17:48:35.854: D/OpenGLRenderer(17250): endAllStagingAnimators on 0x9edeb700 (LayerDrawable) with handle 0x9aa3e3e0
02-19 17:48:36.178: I/ActivityManager(542): Displayed com.YeahButNo.Rotator/com.unity3d.player.UnityPlayerNativeActivity: +566ms (total +25s812ms)
02-19 17:48:36.191: W/IInputConnectionWrapper(17250): showStatusIcon on inactive InputConnection
02-19 17:48:36.197: I/WindowManager(542): Screen frozen for +455ms due to Window{22bfa80a u0 Starting com.YeahButNo.Rotator}
02-19 17:48:36.294: I/Adreno-EGL(22636): <qeglDrvAPI_eglInitialize:410>: QUALCOMM Build: 10/28/14, c33033c, Ia6306ec328
02-19 17:48:36.297: W/Adreno-EGL(22636): <qeglDrvAPI_eglGetConfigAttrib:638>: EGL_BAD_ATTRIBUTE
02-19 17:48:36.297: W/Adreno-EGL(22636): <qeglDrvAPI_eglGetConfigAttrib:638>: EGL_BAD_ATTRIBUTE
02-19 17:48:36.321: D/Unity(22636): GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_AMD_program_binary_Z400 GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_robustness GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_NV_fence GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_depth24 GL_OES_EGL_image GL_OES_EGL_sync GL_OES_EGL_image_external GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_depth_texture_cube_map GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_OES_vertex_array_object GL_QCOM_alpha_test GL_QCOM_binning_control GL_QCOM_driver_control GL_QCOM_perfmon_global_mode GL_QCOM_extended_get GL_QCOM_extended_get2 GL_QCOM_tiled_rendering GL_QCOM_writeonly_rendering GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_
02-19 17:48:36.321: D/Unity(22636): texture_sRGB_decode GL_EXT_texture_filter_anisotropic GL_EXT_multisampled_render_to_texture GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_disjoint_timer_query
02-19 17:48:36.418: W/libc(22636): pthread_create sched_setscheduler call failed: Operation not permitted
02-19 17:48:36.443: D/audio_hw_primary(184): select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
02-19 17:48:36.443: D/ACDB-LOADER(184): ACDB → send_afe_cal
02-19 17:48:36.443: D/audio_hw_primary(184): enable_snd_device: snd_device(2: speaker)
02-19 17:48:36.450: D/audio_hw_primary(184): enable_audio_route: apply and update mixer path: low-latency-playback
02-19 17:48:37.246: W/SensorService(542): sensor 00000000 already enabled in connection 0xb3b5d0a0 (ignoring)
02-19 17:48:38.324: I/art(542): Explicit concurrent mark sweep GC freed 27820(1459KB) AllocSpace objects, 11(8MB) LOS objects, 33% free, 31MB/47MB, paused 1.892ms total 119.934ms
02-19 17:48:40.902: I/ActivityManager(542): START u0 {flg=0x10000 cmp=com.YeahButNo.Rotator/com.unity3d.plugin.downloader.UnityDownloaderActivity (has extras)} from uid 10141 on display 0
02-19 17:48:40.972: V/ActivityManager(542): Display changed displayId=0
02-19 17:48:40.984: I/ActivityManager(542): Config changes=480 {1.0 234mcc?mnc en_GB ldltr sw600dp w960dp h527dp 320dpi lrg land finger -keyb/v/h -nav/h s.28}
02-19 17:48:40.989: I/InputReader(542): Reconfiguring input devices. changes=0x00000004
02-19 17:48:40.989: I/InputReader(542): Device reconfigured: id=6, name=‘elan-touchscreen’, size 1200x1920, orientation 1, mode 1, display id 0
02-19 17:48:41.272: D/LVLDL(22636): Service Bound
02-19 17:48:41.373: I/ActivityManager(542): Displayed com.YeahButNo.Rotator/com.unity3d.plugin.downloader.UnityDownloaderActivity: +425ms
02-19 17:48:41.376: I/WindowManager(542): Screen frozen for +428ms due to Window{20b4f099 u0 com.YeahButNo.Rotator/com.unity3d.plugin.downloader.UnityDownloaderActivity}
02-19 17:48:41.517: I/LicenseChecker(22636): Binding to licensing service.
02-19 17:48:41.577: I/LicenseChecker(22636): Calling checkLicense on service for com.YeahButNo.Rotator
02-19 17:48:41.578: I/LicenseChecker(22636): Start monitoring timeout.
02-19 17:48:41.898: I/qtaguid(17250): Failed write_ctrl(u 45) res=-1 errno=22
02-19 17:48:41.898: I/qtaguid(17250): Untagging socket 45 failed errno=-22
02-19 17:48:41.898: W/NetworkManagementSocketTagger(17250): untagSocket(45) failed with errno -22
02-19 17:48:41.901: I/LicenseChecker(22636): Received response.
02-19 17:48:41.902: I/LicenseChecker(22636): Clearing timeout.
02-19 17:48:41.921: D/LVLDL(22636): file main.4.com.YeahButNo.Rotator.obb found. Not downloading.
02-19 17:48:42.023: V/ActivityManager(542): Display changed displayId=0
02-19 17:48:42.040: I/ActivityManager(542): Config changes=480 {1.0 234mcc?mnc en_GB ldltr sw600dp w600dp h887dp 320dpi lrg port finger -keyb/v/h -nav/h s.29}
02-19 17:48:42.041: I/InputReader(542): Reconfiguring input devices. changes=0x00000004
02-19 17:48:42.041: I/InputReader(542): Device reconfigured: id=6, name=‘elan-touchscreen’, size 1200x1920, orientation 0, mode 1, display id 0
02-19 17:48:42.229: E/BufferQueueProducer(178): [SurfaceView] cancelBuffer: BufferQueue has been abandoned
02-19 17:48:42.241: I/WindowManager(542): Screen frozen for +251ms due to Window{21d52e62 u0 com.YeahButNo.Rotator/com.unity3d.player.UnityPlayerNativeActivity}
02-19 17:48:43.624: E/WifiStateMachine(542): WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=5.56 rxSuccessRate=6.07 targetRoamBSSID=any RSSI=-40
02-19 17:48:43.625: I/wpa_supplicant(650): wlan0: CTRL-EVENT-SCAN-STARTED
02-19 17:48:44.367: I/art(542): Explicit concurrent mark sweep GC freed 16236(847KB) AllocSpace objects, 4(84KB) LOS objects, 33% free, 31MB/47MB, paused 1.586ms total 113.922ms

This line doesnt look good:

02-19 17:48:41.921: D/LVLDL(22636): file main.4.com.YeahButNo.Rotator.obb found. Not downloading.

unless it means its found the obb so doesnt need to download

Yeah, does sound like that. I’m probably grasping at straws now but here’s a few other things to try!

  1. This forum post (last entry) suggests using a particular browser to upload OBB (Google Play OBB Downloader - Unity Engine - Unity Discussions)

  2. I vaguely remember having problems with mixed case bundle ids on Android (YeahButNo) - might be best to stick with all lowercase.

  3. Make sure the build number (4 in your example) is the same in the APK that you’re testing on the phone and that the APK is signed with the key you use when uploading to google play.

  4. You can try manually copying the obb to the sdcard of your device and it should ‘just work’. If it does then at least you can narrow it down to a downloading issue.

Its working now. I think it just wasn’t loading the next scene so I added a bit of code to do so and it works. Still not quite right but getting there