Reputation: 2617
When I was trying to add the APK Expansion functionality to my current app, I got into that annoying compiling error. "XAPKFile cannot be resolved to a type".
This is the guide I was using to add the APK Expansion Files to my projects.
Upvotes: 2
Views: 1357
Reputation: 66
You can find this class in the SampleDownloaderActivity in the extras projects, which also include a really useful example of implementation of APK Expansion Files. If you downloaded the Google Play Expansion Library (through the SDK Manager), you can find it under:
YourPathToAndroidSdk/extras/google/play_apk_expansion/downloader_library
For convenience, I've copy pasted this class here together with the xAPKS array of XAPKFile (as found in v3 of the expansion library):
/**
* This is a little helper class that demonstrates simple testing of an
* Expansion APK file delivered by Market. You may not wish to hard-code
* things such as file lengths into your executable... and you may wish to
* turn this code off during application development.
*/
private static class XAPKFile {
public final boolean mIsMain;
public final int mFileVersion;
public final long mFileSize;
XAPKFile(boolean isMain, int fileVersion, long fileSize) {
mIsMain = isMain;
mFileVersion = fileVersion;
mFileSize = fileSize;
}
}
/**
* Here is where you place the data that the validator will use to determine
* if the file was delivered correctly. This is encoded in the source code
* so the application can easily determine whether the file has been
* properly delivered without having to talk to the server. If the
* application is using LVL for licensing, it may make sense to eliminate
* these checks and to just rely on the server.
*/
private static final XAPKFile[] xAPKS = {
new XAPKFile(
true, // true signifies a main file
3, // the version of the APK that the file was uploaded
// against
687801613L // the length of the file in bytes
),
new XAPKFile(
false, // false signifies a patch file
4, // the version of the APK that the patch file was uploaded
// against
512860L // the length of the patch file in bytes
)
};
Upvotes: 0
Reputation: 2617
I've used a couple of hours until I've found a place, through Google, that somebody defined this:
private static class XAPKFile {
public final boolean mIsMain;
public final int mFileVersion;
public final long mFileSize;
XAPKFile(boolean isMain, int fileVersion, long fileSize) {
mIsMain = isMain;
mFileVersion = fileVersion;
mFileSize = fileSize;
}
}
So, the only thing that you have to check, if you get the same error, is if you have defined this class. Android DOESN'T provide it. It could be because maybe you don't want to put your FileSize at the code...or just because there is a mistake.
Upvotes: 1