Android Fatal Signal 11

前端 未结 10 1208
小鲜肉
小鲜肉 2020-12-14 05:25

In the app I\'m developing on Android, I keep getting a Fatal Signal 11 error.

I think it\'s something to do with the way that I\'m accessing the memory but I can\'t

相关标签:
10条回答
  • 2020-12-14 05:47

    I had the same problem with an instance of android.media.MediaRecorder.

    The code accessed #getMaxAmplitude() after #reset() and #release() on the MediaRecorder instance had been called.

    0 讨论(0)
  • 2020-12-14 05:50

    Same thing happened to me during game development using LibGDX framework for Android, and here's why:

    I have 2 screens - GameScreen and BattleScreen. GameScreen is where I move my character on the map. When I have collision with enemy sprite I instantly use game.setScreen(new BattleScreen(this)) and change current screen to BattleScreen. Here's where the Fatal Signal 11 used to happen. At first I thought it had something to do with loading assets, because my asset manager instance was static. I was trying multiple ways of loading them but nothing worked. It turned out I was changing the screen in the wrong place. For my GameScreen I had WorldController and WorldRenderer instance. I was using worldController.update() and worldRenderer.render() inside GameScreen's render(float deltaTime) method. Inside worldController.update() I was checking for collisions and changing screen as soon as I found one with the enemy. It was not good for Android, maybe because it happened between update and render, or it took some time, while update was still running and it lead to conflicts - I don't know. But here is how I fixed it:

    1. I added a boolean flag (false by default) inside WorldController and everytime a collision with enemy happened I was setting it to true
    2. In GameScreen's render() I was checking this flag - if it was true I would change the screen to BattleScreen, otherwise I would update and render GameScreen

    Now it works perfectly everytime, no FATAL SIGNAL ERROR 11 whatsoever

    Here's my GameScreen's render() method:

    @Override
    public void render(float deltaTime) {
    
        if(worldController.isCollisionWithEnemy()) {
    
            game.setScreen(game.battleScreen);
    
        } else {
    
            if(!paused) {
                worldController.update(deltaTime);
            }
    
            Gdx.gl.glClearColor(57.0f / 255.0f, 181.0f / 225.0f, 115.0f / 255.0f, 1.0f);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    
            worldRenderer.render();
        }
    
    }
    
    0 讨论(0)
  • 2020-12-14 05:58

    I had been trying to call an uninitialised Canvas inside another Class so when it was trying to get the height or width of it, it would crash.

    0 讨论(0)
  • 2020-12-14 05:58

    In my case the BluetoothSocket was null when trying to establish a Bluetooth connection

    0 讨论(0)
  • 2020-12-14 05:59

    In my case, it was a null pointer exception inside an onDraw event that prevent the draw to be completed on the canvas. I think is a general error message given when a draw problem ocurr.

    0 讨论(0)
  • 2020-12-14 06:00

    I too had this error when using Libgdx for android, and I found out this error is caused by Box2d which uses native code, it is better to look at part of your code which uses Box2d and see if there is any null pointers.

    0 讨论(0)
提交回复
热议问题