AndEngineExamples icon indicating copy to clipboard operation
AndEngineExamples copied to clipboard

The constructor BitmapTexture(TextureManager) is undefined

Open alexkempton opened this issue 14 years ago • 4 comments

Error on line 69 of SpriteExample, "The constructor BitmapTexture(TextureManager) is undefined". Seems to be related to changes of the constructors of AndEngine's BitmapTexture in the beginning of march.

alexkempton avatar Mar 06 '12 19:03 alexkempton

By looking at Niffy's fix at https://github.com/nicolasgramlich/AndEngineTexturePackerExtension/issues/2, there seems to be an easy fix. The solution is to change onCreateResources() in SpriteExample.java to:

@Override
public void onCreateResources() {
    try {
        this.mTexture = new BitmapTexture(this.getTextureManager(),  new IInputStreamOpener() {
            @Override
            public InputStream open() throws IOException {
                return getAssets().open("gfx/face_box.png");
            }
        });

        this.mTexture.load();
        this.mFaceTextureRegion = TextureRegionFactory.extractFromTexture(this.mTexture);
    } catch (IOException e) {
        Debug.e(e);
    }
}

alexkempton avatar Mar 08 '12 10:03 alexkempton

to get this fix working, it is also needed this import:

import org.andengine.util.adt.io.in.IInputStreamOpener;

tauame avatar Mar 12 '12 12:03 tauame

I tried the above fix but while the AndEngine Examples force close before starting....Here is my logcat,

03-13 04:50:47.611: E/AndroidRuntime(8241): FATAL EXCEPTION: main 03-13 04:50:47.611: E/AndroidRuntime(8241): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.andengine.examples/org.andengine.examples.launcher.ExampleLauncher}: java.lang.ClassNotFoundException: org.andengine.examples.launcher.ExampleLauncher in loader dalvik.system.PathClassLoader[/data/app/org.andengine.examples-1.apk] 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680) 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784) 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.os.Handler.dispatchMessage(Handler.java:99) 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.os.Looper.loop(Looper.java:130) 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.app.ActivityThread.main(ActivityThread.java:3835) 03-13 04:50:47.611: E/AndroidRuntime(8241): at java.lang.reflect.Method.invokeNative(Native Method) 03-13 04:50:47.611: E/AndroidRuntime(8241): at java.lang.reflect.Method.invoke(Method.java:507) 03-13 04:50:47.611: E/AndroidRuntime(8241): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 03-13 04:50:47.611: E/AndroidRuntime(8241): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 03-13 04:50:47.611: E/AndroidRuntime(8241): at dalvik.system.NativeStart.main(Native Method) 03-13 04:50:47.611: E/AndroidRuntime(8241): Caused by: java.lang.ClassNotFoundException: org.andengine.examples.launcher.ExampleLauncher in loader dalvik.system.PathClassLoader[/data/app/org.andengine.examples-1.apk] 03-13 04:50:47.611: E/AndroidRuntime(8241): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 03-13 04:50:47.611: E/AndroidRuntime(8241): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 03-13 04:50:47.611: E/AndroidRuntime(8241): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 03-13 04:50:47.611: E/AndroidRuntime(8241): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672) 03-13 04:50:47.611: E/AndroidRuntime(8241): ... 11 more 03-13 04:51:32.902: E/jdwp(8341): Failed sending reply to debugger: Broken pipe

What did I do wrong?

kpsfoo avatar Mar 12 '12 23:03 kpsfoo

I don't believe this issue alexkempton reported has anything to do with your error, perhaps you should try the andengine forums.

It seems like your project has some kind of configuration (project properties or androidManifest.xml) error, in you place i would try to get it from the repository again and re-run it.

tauame avatar Mar 13 '12 11:03 tauame