我正在从Pixmap
实例化一个FileHandle
,该StorageManager
指向来自Google的APK扩展库的OBB文件中的png文件,该文件使用Pixmap
挂载。 OBB文件已加密。
这在我测试的运行Android 5.1和4.3但没有物理SD卡的设备上运行良好,但无法在运行带有物理SD卡的Android 4.4.1的设备上运行。我得到了:
加载pixmap时出错:解码器初始化失败了
这是整个堆栈跟踪:
08-08 15:01:18.839 30228-30285/com.yasesprox.solarball.android W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0x41bbcd58) --------- beginning of /dev/log/system 08-08 15:01:18.859 30228-30285/com.yasesprox.solarball.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 3615 Process: com.yasesprox.solarball.android, PID: 30228 com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: /mnt/obb/e0fb6be85a09d3afdfb4453fcca775e3/stage_1/screenshot.png at com.badlogic.gdx.assets.AssetManager.handleTaskError(AssetManager.java:536) at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:356) at com.yasesprox.solarball.extensions.SolarBallStage.loading(SolarBallStage.java:45) at com.yasesprox.solarball.misc.LoadingStage.update(LoadingStage.java:36) at com.yasesprox.solarball.misc.LoadingStage.act(LoadingStage.java:46) at com.yasesprox.solarball.extensions.SolarBallGame.render(SolarBallGame.java:101) at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:422) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: /mnt/obb/e0fb6be85a09d3afdfb4453fcca775e3/stage_1/screenshot.png at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:140) at com.yasesprox.solarball.data.StageDataProvider.instantiateScreenshot(StageDataProvider.java:41) at com.yasesprox.solarball.data.StageDataProvider.(StageDataProvider.java:24) at com.yasesprox.solarball.data.StageDataProviderLoader.loadSync(StageDataProviderLoader.java:23) at com.yasesprox.solarball.data.StageDataProviderLoader.loadSync(StageDataProviderLoader.java:11) at com.badlogic.gdx.assets.AssetLoadingTask.handleAsyncLoader(AssetLoadingTask.java:123) at com.badlogic.gdx.assets.AssetLoadingTask.update(AssetLoadingTask.java:89) at com.badlogic.gdx.assets.AssetManager.updateTask(AssetManager.java:477) at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:354) at com.yasesprox.solarball.extensions.SolarBallStage.loading(SolarBallStage.java:45) at com.yasesprox.solarball.misc.LoadingStage.update(LoadingStage.java:36) at com.yasesprox.solarball.misc.LoadingStage.act(LoadingStage.java:46) at com.yasesprox.solarball.extensions.SolarBallGame.render(SolarBallGame.java:101) at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:422) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) Caused by: java.io.IOException: Error loading pixmap: decoder init failed for stream at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) at com.yasesprox.solarball.data.StageDataProvider.instantiateScreenshot(StageDataProvider.java:41) at com.yasesprox.solarball.data.StageDataProvider.(StageDataProvider.java:24) at com.yasesprox.solarball.data.StageDataProviderLoader.loadSync(StageDataProviderLoader.java:23) at com.yasesprox.solarball.data.StageDataProviderLoader.loadSync(StageDataProviderLoader.java:11) at com.badlogic.gdx.assets.AssetLoadingTask.handleAsyncLoader(AssetLoadingTask.java:123) at com.badlogic.gdx.assets.AssetLoadingTask.update(AssetLoadingTask.java:89) at com.badlogic.gdx.assets.AssetManager.updateTask(AssetManager.java:477) at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:354) at com.yasesprox.solarball.extensions.SolarBallStage.loading(SolarBallStage.java:45) at com.yasesprox.solarball.misc.LoadingStage.update(LoadingStage.java:36) at com.yasesprox.solarball.misc.LoadingStage.act(LoadingStage.java:46) at com.yasesprox.solarball.extensions.SolarBallGame.render(SolarBallGame.java:101) at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:422) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
我在Pixmap
之前从同一个地方加载其他资源,它们在所有设备上都能正常运行;只是这一个Pixmap
。
此外,如果我使用Gdx.files.internal
(文件位于Android项目的“assets”文件夹中)从内部存储加载,则所有设备上的package com.sprhib.init;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.DispatcherServlet;
public class Initializer implements WebApplicationInitializer {
public void onStartup(ServletContext servletContext)
throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(WebAppConfig.class);
servletContext.addListener(new ContextLoaderListener(ctx));
ctx.setServletContext(servletContext);
Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
servlet.addMapping("/");
servlet.setLoadOnStartup(1);
FilterRegistration.Dynamic filterRegistration = servletContext.addFilter("encodingFilter",
new CharacterEncodingFilter());
filterRegistration.setInitParameter("encoding", "UTF-8");
filterRegistration.setInitParameter("forceEncoding", "true");
filterRegistration.addMappingForUrlPatterns(null,true,"/*");
}
}
都可以正常工作。
发生了什么事?