Can Corona Enterprise support expansion file (over 50M APK limit in Google play) for android?

Hello all.

Did Corona Enterprise support expansion file (over 50M APK limit in Google play) for android?

If It supports, How can I setting it or command in build (build.sh)?

Corona Pro is doing well with below setting, but no happen in Corona Enterprise.

http://www.coronalabs.com/blog/2013/04/17/expansion-file-support-for-android/

Thank you.

Since you are doing native Android development, you’ll have to create the expansion file yourself according to Google’s documentation here…

   http://developer.android.com/google/play/expansion-files.html

Quick summary, the Android SDK will not create the expansion file for you.  You’re expected to create a zip file containing all of your app’s content yourself.  Also, I recommend that you use zero compression for fast file access, which is typically 3-4x faster than compressed file access.  The simplest solution is to move all of the asset files that you have in your Corona project directory to some other directory which you plan on zipping up into an expansion file.  This is because the Corona pre-build step in your “build.xml” file will copy your Corona project’s files into your Android “assets” directory, which causes them to be included in the APK, which is not what you want.

Unfortunately, Google did not make it easy for native developers to create expansion files.  Definitely not as easy as we make it via the Corona Simulator.  So, that’s one of the disadvantages of going the native route with Android development, but the advantage is that you get full control over how to create these files and what assets go into them.

In Corona, when you attempt to access a file in your “system.ResourceDirectory”, Corona will look for that file in the following places in-order:

  1. Patch expansion file.  (That obb file is expected to be a zip file.)

  2. Main expansion file.  (That obb file is expected to be a zip file.)

  3. The assets directory.

That should be enough for you to get started.

Thank you, joshua

If it helps you any, you should be able to create an expansion file via ant by adding the following to your “build.xml” file.  You’ll need to modify it a bit to specify the *.obb file name.  Should be a good start for you.
 

\<?xml version="1.0" encoding="UTF-8"?\> \<project name="YourApkFileName" default="help"\> \<!-- File set for all Corona files to be copied to the expansion file. Excludes files that are not assets. --\> \<fileset dir="${basedir}/../Corona" id="asset.fileset"\> \<exclude name="\*\*/\*.config" /\> \<exclude name="\*\*/\*.lua" /\> \<exclude name="\*\*/\*.lu" /\> \<exclude name="\*\*/\*.settings" /\> \<exclude name="\*\*/\*.bak" /\> \<exclude name="\*\*/\*.orig" /\> \<exclude name="\*\*/\*.swp" /\> \<exclude name="\*\*/\*.DS\_Store" /\> \<exclude name="\*\*/\*.apk" /\> \<exclude name="\*\*/\*.obb" /\> \<exclude name="\*\*/\*.obj" /\> \<exclude name="\*\*/\*.o" /\> \<exclude name="\*\*/\*.lnk" /\> \<exclude name="\*\*/\*.class" /\> \<exclude name="\*\*/\*.log" /\> \<exclude name="\*\*/.\*" /\> \<exclude name="\*\*/.\*/\*\*" /\> \<exclude name="\*\*/.\_\*" /\> \<exclude name="\*\*/build.properties" /\> \</fileset\> \<!-- Creates a Google Play expansion file. --\> \<target name="build-expansion-file"\> \<zip destfile="${basedir}/bin/YourExpansionFileName.obb" encoding="UTF8" compress="false"\> \<fileset refid="asset.fileset"/\> \</zip\> \</target\> \</project\>

Since you are doing native Android development, you’ll have to create the expansion file yourself according to Google’s documentation here…

   http://developer.android.com/google/play/expansion-files.html

Quick summary, the Android SDK will not create the expansion file for you.  You’re expected to create a zip file containing all of your app’s content yourself.  Also, I recommend that you use zero compression for fast file access, which is typically 3-4x faster than compressed file access.  The simplest solution is to move all of the asset files that you have in your Corona project directory to some other directory which you plan on zipping up into an expansion file.  This is because the Corona pre-build step in your “build.xml” file will copy your Corona project’s files into your Android “assets” directory, which causes them to be included in the APK, which is not what you want.

Unfortunately, Google did not make it easy for native developers to create expansion files.  Definitely not as easy as we make it via the Corona Simulator.  So, that’s one of the disadvantages of going the native route with Android development, but the advantage is that you get full control over how to create these files and what assets go into them.

In Corona, when you attempt to access a file in your “system.ResourceDirectory”, Corona will look for that file in the following places in-order:

  1. Patch expansion file.  (That obb file is expected to be a zip file.)

  2. Main expansion file.  (That obb file is expected to be a zip file.)

  3. The assets directory.

That should be enough for you to get started.

Thank you, joshua

If it helps you any, you should be able to create an expansion file via ant by adding the following to your “build.xml” file.  You’ll need to modify it a bit to specify the *.obb file name.  Should be a good start for you.
 

\<?xml version="1.0" encoding="UTF-8"?\> \<project name="YourApkFileName" default="help"\> \<!-- File set for all Corona files to be copied to the expansion file. Excludes files that are not assets. --\> \<fileset dir="${basedir}/../Corona" id="asset.fileset"\> \<exclude name="\*\*/\*.config" /\> \<exclude name="\*\*/\*.lua" /\> \<exclude name="\*\*/\*.lu" /\> \<exclude name="\*\*/\*.settings" /\> \<exclude name="\*\*/\*.bak" /\> \<exclude name="\*\*/\*.orig" /\> \<exclude name="\*\*/\*.swp" /\> \<exclude name="\*\*/\*.DS\_Store" /\> \<exclude name="\*\*/\*.apk" /\> \<exclude name="\*\*/\*.obb" /\> \<exclude name="\*\*/\*.obj" /\> \<exclude name="\*\*/\*.o" /\> \<exclude name="\*\*/\*.lnk" /\> \<exclude name="\*\*/\*.class" /\> \<exclude name="\*\*/\*.log" /\> \<exclude name="\*\*/.\*" /\> \<exclude name="\*\*/.\*/\*\*" /\> \<exclude name="\*\*/.\_\*" /\> \<exclude name="\*\*/build.properties" /\> \</fileset\> \<!-- Creates a Google Play expansion file. --\> \<target name="build-expansion-file"\> \<zip destfile="${basedir}/bin/YourExpansionFileName.obb" encoding="UTF8" compress="false"\> \<fileset refid="asset.fileset"/\> \</zip\> \</target\> \</project\>

Has anyone successfully implemented this? I have had no luck yet.

I tried creating the zip (naming is main.#.com.mydomain.myapp) and pushing it to the device using adp. However I still get a file not found with the display.newImageRect call. 

Is there something i need to do to my AndroidManifest.xml or code I need to include as well?

Does the Corona expansion pack code (the part that actually does the downloading) exist in the Enterprise build?

Also, that target build for the build.xml to generate Zips doesn’t work. It doesn’t crash the coronabuilder but it doesn’t generate a zip file either.

Yes you do need to add

<meta-data android:name=“usesExpansionFile” android:value=“true” />

to your manifest.  Add it as a child of the “application” field.

Has anyone successfully implemented this? I have had no luck yet.

I tried creating the zip (naming is main.#.com.mydomain.myapp) and pushing it to the device using adp. However I still get a file not found with the display.newImageRect call. 

Is there something i need to do to my AndroidManifest.xml or code I need to include as well?

Does the Corona expansion pack code (the part that actually does the downloading) exist in the Enterprise build?

Also, that target build for the build.xml to generate Zips doesn’t work. It doesn’t crash the coronabuilder but it doesn’t generate a zip file either.

Yes you do need to add

<meta-data android:name=“usesExpansionFile” android:value=“true” />

to your manifest.  Add it as a child of the “application” field.

Has anyone been able to create an .obb file and implement the Android downloader?

I have been able to add the libraries needed for the downloader (market_licensing and market_apk_expansion) and succesfully build the apk without errors. However it does not create an expansion file.

The other problem I’m having is enabling the downloader. When building a Corona apk the main script is called within the application tag, like this:

\<application android:name="CoronaApplication" android:label="App label" android:hardwareAccelerated="true" android:debuggable="true" android:icon="@drawable/ic\_launcher"\>

and after that an Activity, like this:

\<activity android:name="com.ansca.corona.CoronaActivity" android:screenOrientation="landscape" android:configChanges="keyboardHidden|orientation|screenSize" android:label="App label" android:launchMode="singleTask" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"\> \<intent-filter\> \<action android:name="android.intent.action.MAIN" /\> \<category android:name="android.intent.category.LAUNCHER" /\> \</intent-filter\> \</activity\>

The downloader however needs to use the main activity thread, but corona also uses this. And as far as i know I can’t modify the com.ansca.corona.CoronaActivity. Or is there a way to start the downloader and after that to call CoronaActivity?

Any help would be appreciated!

If you’re using enterprise you’ll have to create the .obb file yourself.  The other option is to build your project using the Corona Simulator and then have that build your .obb that you then use with your enterprise built apk.

There are 2 ways you can implement your downloader screen.

  1. Have your own activity be the first activity thats started.  Once its done downloading/verifying the expansion file then you start the CoronaActivity.

  2. Extend CoronaActivity.

Has anyone been able to create an .obb file and implement the Android downloader?

I have been able to add the libraries needed for the downloader (market_licensing and market_apk_expansion) and succesfully build the apk without errors. However it does not create an expansion file.

The other problem I’m having is enabling the downloader. When building a Corona apk the main script is called within the application tag, like this:

\<application android:name="CoronaApplication" android:label="App label" android:hardwareAccelerated="true" android:debuggable="true" android:icon="@drawable/ic\_launcher"\>

and after that an Activity, like this:

\<activity android:name="com.ansca.corona.CoronaActivity" android:screenOrientation="landscape" android:configChanges="keyboardHidden|orientation|screenSize" android:label="App label" android:launchMode="singleTask" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"\> \<intent-filter\> \<action android:name="android.intent.action.MAIN" /\> \<category android:name="android.intent.category.LAUNCHER" /\> \</intent-filter\> \</activity\>

The downloader however needs to use the main activity thread, but corona also uses this. And as far as i know I can’t modify the com.ansca.corona.CoronaActivity. Or is there a way to start the downloader and after that to call CoronaActivity?

Any help would be appreciated!

If you’re using enterprise you’ll have to create the .obb file yourself.  The other option is to build your project using the Corona Simulator and then have that build your .obb that you then use with your enterprise built apk.

There are 2 ways you can implement your downloader screen.

  1. Have your own activity be the first activity thats started.  Once its done downloading/verifying the expansion file then you start the CoronaActivity.

  2. Extend CoronaActivity.

Since Corona has already implemented this entire functionality in the regular Corona SDK, can you please make it available to enterprise customers? It would be great if you could provide the work that you’ve already done and just expose it to your enterprise customers so we can use it. It doesn’t really make sense for every enterprise customer to try to write their own version of what Corona has already accomplished right?

Corona Enterprise already supports “reading” from *.obb expansion files.  The only thing you have to do is create the expansion file yourself, which is really just a zip file, and add the following AndroidManifest.xml entry telling Corona that an expansion file exists.

\<manifest ...\> \<application ...\> \<activity android:name="com.ansca.corona.CoronaActivity" ...\> \<!-- Add this meta-data entry within the CoronaActivity tag. --\> \<!-- This tells Corona that an expansion file exists. --\> \<meta-data android:name="usesExpansionFile" android:value="true"/\> \</activity\> \</application\> \</manifest\>

Remember, Corona Enterprise is just a library which you integrate into your own Android application project.  You’re really compiling with Google’s Android SDK.  So, you have to create the Google Play expansion file yourself according to Google’s documentation.  What I recommend is for you to move all of your assets from your Corona project folder to another folder for you to zip up and rename it with a *.obb extension.  When you do an Android build, ideally, only the Lua scripts should be included within your APK’s assets.  The app template we provide with Corona Enterprise will automatically compile the Lua scripts, bundle them within a “resource.car” file, and move that to your Android app project’s “assets” folder as a pre-build step within your “build.xml”.

Thank you for your reply Joshua. All of what you said is true; however, there is the part on app startup that checks to see whether the obb file is downloaded and will download it if it does not exist. This is the code that I am interested in getting from Corona since you guys have already written it for Corona SDK and it works.

Okay.  You’ll have to do add the “meta-data” tag to your AndroidManifest.xml as I’ve shown up above.

You’ll also need to add Google Licensing (aka: LVL) support to your app as well, which is a Google Play requirement.  You’ll need to add the Android permission equivalents documented in the link below to your AndroidManifest.xml file as well.

   http://docs.coronalabs.com/daily/guide/distribution/buildSettings/index.html#expansion-files

And you’ll need to copy Corona’s Google Licensing plugin *.jar files to your Android app project’s “libs” directory.  You can download our plugins from our daily build page (link below, under “Enterprise” tab).  Make sure to download the Corona build number that matches your Corona Enterprise build number.

   http://developer.coronalabs.com/downloads/daily-builds/

I recommend that you verify that you’ve got Google licensing working first before adding expansion file support.

Once you’ve got licensing working, then move your assets to another folder and create your expansion file.  You can test your expansion file support before uploading your *apk and *.obb file to Google Play by putting your *.obb file in the right SD card location on your device via the Android tool “Monitor” or the older “ddms” tool.  Unfortunately, the exact folder location is different between many devices.  More details can be found here…

   http://developer.android.com/google/play/expansion-files.html

Since Corona has already implemented this entire functionality in the regular Corona SDK, can you please make it available to enterprise customers? It would be great if you could provide the work that you’ve already done and just expose it to your enterprise customers so we can use it. It doesn’t really make sense for every enterprise customer to try to write their own version of what Corona has already accomplished right?