How to make Android Expansion File using Android Studio?
I've done this on a few projects, but I never figured out a simple way. The instructions at
http://developer.android.com/google/play/expansion-files.html
helped me get my head around the basics, but I found parts of the process (like "android update project") didn't work properly with Gradle.
The instructions below will help you set up your project with the required libraries. After that you can go back to the official docs and figure out what to do with all the stuff you just included.
Add these permissions to AndroidManifest.xml
<uses-permission android:name="com.android.vending.CHECK_LICENSE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
Add Play Services dependency to build.gradle
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
}
Open SDK Manager and install Google Play APK Expansion Library and Google Play Licensing Library.
Copy java source files from these folders into your project's source/main/java folder:
YOUR-ANDROID-SDK-FOLDER\extras\google\play_apk_expansion\zip_file\src
YOUR-ANDROID-SDK-FOLDER\extras\google\play_apk_expansion\downloader_library\src
YOUR-ANDROID-SDK-FOLDER\extras\google\play_licensing\library\src
Open
YOUR-ANDROID-SDK-FOLDER\extras\google\play_apk_expansion\downloader_library\res
Copy drawable-hdpi, drawable-mdpi and layout into your project's source/main/res folder.
For all files in the values folders, merge content from the file into the matching file in your project.
Create a class which extends android.content.BroadcastReceiver
Add something like this to your manifest:
<receiver android:name="mypackage.MyReceiver"/>
Create a class which extends com.google.android.vending.expansion.downloader.impl.DownloaderService
Add something like this to your manifest:
<service android:name="mypackage.MyDownloaderService"/>
Compile the project and look for errors relating to
import com.android.vending.expansion.downloader.R;
Import your own project resources here instead.
How to create .obb file as main apk expansion file using jobb tool?
i have googled and found that we shold have to make .zip with 0% (No compression)
that is mention in http://developer.android.com/google/play/expansion-files.html
Tip: If you're packaging media files into a ZIP, you can use media playback calls on the files with offset and length controls (such as MediaPlayer.setDataSource() and SoundPool.load()) without the need to unpack your ZIP. In order for this to work, you must not perform additional compression on the media files when creating the ZIP packages. For example, when using the zip tool, you should use the -n option to specify the file suffixes that should not be compressed:
zip -n .mp4;.ogg main_expansion media_files
OR How to make 0% compression zip using winrar?
here see the compression method
so we should have to upload this zip in play store.
so you not need to use ZipHelper.java
just simply use
ZipResourceFile expansionFile=null;
try {
expansionFile = APKExpansionSupport.getAPKExpansionZipFile(getApplicationContext(),3,0);
AssetFileDescriptor fd = expansionFile.getAssetFileDescriptor("test.mp4");
MediaPlayer mPlayer = new MediaPlayer();
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mPlayer.setDataSource(fd.getFileDescriptor(),fd.getStartOffset(),fd.getLength());
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
How to add Google Play APK Expansion Library to android studio project?
Apparently there is no way to use APK Expansion Files if you are using Android Studio. (see https://code.google.com/p/android/issues/detail?id=173235) That kind of sucks. So I guess I go back to using Eclipse.
How can I use Android expansion files using App Bundle?
While the App Bundle Known Issues includes:
Android App Bundles do not support APK expansion files. However, Google Play still requires that app downloads be 100MB or less. So, for example, when first installing your app, the total size of your base APK and its configuration APKs must equal 100 MB or less. Similarly, the total size of any dynamic feature APK and its configuration APKs must be 100 MB or less. After uploading your app bundle, the Play Console warns you if your app bundle results in APKs that violate this restriction.
the Playtime 2018 blog post states that this is changing in the future:
Improved support for large apps: you can now upload large app bundles with installed APK sizes of up to 500MB without needing to use expansion files. This feature is in early access and we will roll it out to all developers in the future.
So it appears that if you need an APK over 100MB in size, you'll need to wait for the 500MB app bundle support to roll out to your developer account. If your video and APK is less than 100MB already, you should be able to upload it directly and skip using APK expansion files entirely right now.
Related Topics
Handling Registration Id Changes in Google Cloud Messaging on Android
Android Intent for Twitter Application
How to Get Onclick Event on Webview in Android
How to Change Color of Button in Android When Clicked
How to Disable Gradle 'Offline Mode' in Android Studio
Android: Progressdialog.Show() Crashes with Getapplicationcontext
Change Value of R.String Programmatically
Execution Failed App:Processdebugresources Android Studio
What Does Layoutinflater in Android Do
Android Studio's Project Gradle File Changed
Error "The Connection to Adb Is Down, and a Severe Error Has Occurred."
How to Keep Onitemselected from Firing Off on a Newly Instantiated Spinner
Manifest Merger Failed:Uses-Sdk:Minsdkversion 14
How to Crop Circular Area from Bitmap in Android
Android- Error:Execution Failed for Task ':App:Transformclasseswithdexforrelease'
Push Notifications in Android Platform
How to Hide Soft Keyboard on Android After Clicking Outside Edittext