Read texture with c++ SDL2_image on Android

Hi, I’m trying to understand how to use the assets files of an APK from SDL2 ,here is what i want to do: load a texture from assets/background.jpg, render it on each loop.
I’ve put the texture in the assets dir, I can see it when the apk is generated using an extractor, so it’s good to go, but the file can’t be read from the SDL_image function to do so…

 SDL_Texture *img = NULL;
	int w, h; // texture width & height
        //later in the code
	if (img == NULL) {
  	        // load our image
		img = IMG_LoadTexture(state->renderers[0], "background.jpg");

		if (img != NULL)
			SDL_Log("Image loaded ok -background.jpg-");
			SDL_Log("Could not load the background.jpg");

I’m always getting the "Could not load the background.jpg , do I need to add permises to the AndroidManifest?, should i be using AssetManager from a JNI bridge from Java?
like this:
or maybe my sdl2_image library is not compiled ok, since i had to make my own .so version with VStudio2017 and the sources…

first of of all, print the error message with SDL_GetError()

Thanks , the problem was that i was not using the flags USE_JPG when compiling the SDL2_image libraries, now it loads the image with a renderer, but i can’t see the image on the screen :thinking:
What I do in main.cpp is:
add the include
#include "SDL_image.h"
then init just the jpg:

int flags = IMG_INIT_JPG;// | IMG_INIT_PNG;
if (IMG_Init(flags) != flags)
	SDL_Log("Could not initialize IMG JPG");
	SDL_Log("IMG Load error: %s", SDL_GetError());

create the renderer:
SDL_Renderer *imgRenderer = SDL_CreateRenderer(state->windows[0], -1, SDL_RENDERER_ACCELERATED);
then ,load the image:

            SDL_Texture *img = IMG_LoadTexture(imgRenderer, "background.jpg");
            int w,h;
            if (img != NULL)
			SDL_Log("Image loaded ok %s\n", "background.jpg");
			SDL_QueryTexture(img, NULL, NULL, &w, &h);
			texr.x = w/2; texr.y = h/2; texr.w = w; texr.h = h;
			SDL_Log("Error loading Image: %s\n", "background.jpg");
			SDL_Log("SDL Error: %s", SDL_GetError());

finally, render it
SDL_RenderCopy(imgRenderer, img, NULL, &texr);

full code

so,what am i missing? like i said, the image is being loaded…

08-27 14:22:13.054: I/SDL/APP(9070): Trying to load the image…
08-27 14:22:13.054: V/SDL(9070): onWindowFocusChanged(): true
08-27 14:22:13.384: I/SDL/APP(9070): Image loaded ok background.jpg


Try using SDL_RenderPresent() instead of SDL_GL_SwapWindow()

That didn’t work…
Maybe I need to draw it I a different way for gles2?

what’s the size of your image?
can you try without the texr?
SDL_RenderCopy(imgRenderer, img, NULL, NULL);

i fixed it, thanks for the help Sanette