My apk version code is version 3. with it I am using main expansion file which was loaded with apk version code 1 (file name is similar to main.1.ex.etc.eg.obb). The expansi
As you well say, the expansion file version number can be different of the app version. So the question is, how do I know the expansion file version number?
Here's one of the multiple possible answers:
From the APK Expansion Files guide:
There are many ways you could determine the expansion file version number. One simple way is to save the version in a SharedPreferences file when the download begins, by querying the expansion file name with the APKExpansionPolicy class's getExpansionFileName(int index) method. You can then get the version code by reading the SharedPreferences file when you want to access the expansion file.
For more information about reading from the shared storage, see the Data Storage documentation.
You have to create your own provider and declare it in your manifest
<provider android:authorities="com.myCompany.myAppName.provider.ZipFileContentProvider" android:name=".ZipFileContentProvider"></provider>
Taken from:
Where is the SampleZipfileProvider class?
The Zip file provider class contains metadata that you can place in your AndroidManifest.zip file if the version number of the APK Expansion File does not match the version number of your APK.
<provider android:name=".APEZProvider"
android:authorities="my.application.authority"
android:exported="false"
android:multiprocess="true"
>
<meta-data android:name="mainVersion"
android:value="1"></meta-data>
<meta-data android:name="patchVersion"
android:value="2"></meta-data>
</provider>