NPE - http://pastebin.com/gzuf3x1k (This comes up when I execute the obfuscated file). (StackTrace with LineNumbers: http://pastebin.com/ddY3Ei9G)
NPE - http://pastebin.com/gzuf3x1k(当我执行混淆文件时出现)。 (带有LineNumbers的StackTrace:http://pastebin.com/ddY3Ei9G)
(The obfuscated stacktrace: http://pastebin.com/svipdakN)
(混淆的堆栈跟踪:http://pastebin.com/svipdakN)
addRefreshedVersionsListener(VersionManager.java):
public void addRefreshedVersionsListener(RefreshedVersionsListener listener){
this.refreshedVersionsListeners.add(listener);
}
getResourceFiles(VersionManager.java):
private Set<Downloadable> getResourceFiles(Proxy proxy, File baseDirectory, CompleteVersion version)
{
Set result = new HashSet();
InputStream inputStream = null;
File assets = new File(baseDirectory, "assets");
File objectsFolder = new File(assets, "objects");
File indexesFolder = new File(assets, "indexes");
String indexName = version.getAssets();
long start = System.nanoTime();
if (indexName == null) {
indexName = "legacy";
}
File indexFile = new File(indexesFolder, indexName + ".json");
try
{
URL indexUrl = new URL("https://s3.amazonaws.com/Minecraft.Download/indexes/" + indexName + ".json");
inputStream = indexUrl.openConnection(proxy).getInputStream();
String json = IOUtils.toString(inputStream);
FileUtils.writeStringToFile(indexFile, json);
AssetIndex index = (AssetIndex)this.gson.fromJson(json, AssetIndex.class);
for (AssetIndex.AssetObject object : index.getUniqueObjects())
{
String filename = object.getHash().substring(0, 2) + "/" + object.getHash();
File file = new File(objectsFolder, filename);
if ((!file.isFile()) || (FileUtils.sizeOf(file) != object.getSize()))
{
Downloadable downloadable = new AssetDownloadable(proxy, new URL("http://resources.download.minecraft.net/" + filename), file, false, object.getHash(), object.getSize());
downloadable.setExpectedSize(object.getSize());
result.add(downloadable);
}
}
long end = System.nanoTime();
long delta = end - start;
Launcher.getInstance().println("Delta time to compare resources: " + delta / 1000000L + " ms ");
}
catch (IOException|JsonSyntaxException ex)
{
Launcher.getInstance().println("Couldn't download resources", ex);
}
finally
{
IOUtils.closeQuietly(inputStream);
}
return result;
}
& The first cause [at net.minecraft.launcher.updater.VersionManager.refreshVersions(VersionManager.java)]
&第一个原因[在net.minecraft.launcher.updater.VersionManager.refreshVersions(VersionManager.java)]
public void refreshVersions() throws IOException {
this.clearCache();
File[] files = this.baseVersionsDir.listFiles();
if(files != null) {
File[] i$ = files;
int version = files.length;
for(int type = 0; type < version; ++type) {
File directory = i$[type];
String id = directory.getName();
File jsonFile = new File(directory, id + ".json");
if(directory.isDirectory() && jsonFile.exists()) {
try {
String ex = "versions/" + id + "/" + id + ".json";
CompleteVersion version1 = (CompleteVersion)this.gson.fromJson(this.getContent(ex), CompleteVersion.class);
if(version1.getId().equals(id)) {
this.addVersion(version1);
} else if(Launcher.getInstance() != null) {
Launcher.getInstance().println("Ignoring: " + ex + "; it contains id: \'" + version1.getId() + "\' expected \'" + id + "\'");
}
} catch (RuntimeException var10) {
if(Launcher.getInstance() == null) {
throw new JsonSyntaxException("Loading file: " + jsonFile.toString(), var10);
}
Launcher.getInstance().println("Couldn\'t load local version " + jsonFile.getAbsolutePath(), var10);
}
}
}
Location of the cause on stacktrace:
堆栈跟踪上的原因位置:
CompleteVersion version1 = (CompleteVersion)this.gson.fromJson(this.getContent(ex), CompleteVersion.class);
if(version1.getId().equals(id)) {
this.addVersion(version1);
} else if(Launcher.getInstance() != null) {
Launcher.getInstance().println("Ignoring: " + ex + "; it contains id: \'" + version1.getId() + "\' expected \'" + id + "\'");
}
For some odd reason, this ALWAYS occurs with the fromJson method from GSON API (when executed after obfuscation).
由于一些奇怪的原因,这总是发生在GSON API的fromJson方法中(在混淆后执行时)。
CompleteVersion Class : http://pastebin.com/dF6aXCjS
CompleteVersion类:http://pastebin.com/dF6aXCjS
1 个解决方案
#1
I'm guessing that this is because when GSON tries to parse the JSON, it uses the property names in the CompleteVersion class. If those names are mangled, GSON won't find the property names in the JSON, so the properties will simply be null.
我猜这是因为当GSON尝试解析JSON时,它使用CompleteVersion类中的属性名称。如果这些名称被破坏,GSON将无法在JSON中找到属性名称,因此属性将仅为null。
Another * question appears to have several solutions to this problem. I've never used ProGuard personally, but it looks like you can try adding something like -keep class net.minecraft.launcher.versions.CompleteVersion { *; }
to proguard.cfg so that the CompleteVersion class won't be touched by ProGuard.
另一个*问题似乎有几个解决此问题的方法。我从未亲自使用ProGuard,但看起来你可以尝试添加类似-keep class net.minecraft.launcher.versions.CompleteVersion {*; }到proguard.cfg,以便ProGuard不会触及CompleteVersion类。
#1
I'm guessing that this is because when GSON tries to parse the JSON, it uses the property names in the CompleteVersion class. If those names are mangled, GSON won't find the property names in the JSON, so the properties will simply be null.
我猜这是因为当GSON尝试解析JSON时,它使用CompleteVersion类中的属性名称。如果这些名称被破坏,GSON将无法在JSON中找到属性名称,因此属性将仅为null。
Another * question appears to have several solutions to this problem. I've never used ProGuard personally, but it looks like you can try adding something like -keep class net.minecraft.launcher.versions.CompleteVersion { *; }
to proguard.cfg so that the CompleteVersion class won't be touched by ProGuard.
另一个*问题似乎有几个解决此问题的方法。我从未亲自使用ProGuard,但看起来你可以尝试添加类似-keep class net.minecraft.launcher.versions.CompleteVersion {*; }到proguard.cfg,以便ProGuard不会触及CompleteVersion类。