Android 无法将XAPKFile解析为类型
当我试图将APK扩展功能添加到我当前的应用程序时,我遇到了那个恼人的编译错误。“XAPKFile无法解析为类型”Android 无法将XAPKFile解析为类型,android,Android,当我试图将APK扩展功能添加到我当前的应用程序时,我遇到了那个恼人的编译错误。“XAPKFile无法解析为类型” 是我用来将APK扩展文件添加到我的项目中的指南。我用了几个小时,直到我通过谷歌找到一个地方,有人定义了以下内容: private static class XAPKFile { public final boolean mIsMain; public final int mFileVersion; public final long m
是我用来将APK扩展文件添加到我的项目中的指南。我用了几个小时,直到我通过谷歌找到一个地方,有人定义了以下内容:
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;
}
}
因此,如果您得到相同的错误,您唯一需要检查的是您是否定义了这个类。Android没有提供它。这可能是因为您不想将文件大小放在代码中……或者只是因为存在错误。您可以在extras项目的示例下载活动中找到此类,该项目还包括一个实现APK扩展文件的非常有用的示例。如果您下载了Google Play扩展库(),您可以在以下位置找到它: 你的androidsdk/extras/google/play\u apk\u expansion/downloader\u library路径 为了方便起见,我将这个类与XAPKFile的xAPKS数组(如扩展库的v3中所示)一起复制粘贴到了这里:
这里面有问题吗?不,这是自我回答的,以避免人们因为同样的错误而迷路。我认为它可能有用。然后请把它分成一个问题和一个单独的答案。谢谢,我不知道如何继续这个。完成!
/**
* 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
)
};