Hi! I just solved this problem and I'd like to share my methods with you. The key problem is not about the texture size( it doesn't need to be size of power of 2).
I worked on the ImageTargets sample, and I needed to get dynamic textures from a server through TCP link. After I dynamically load the texture into mTexture in ImageTarget.java like this( I referred to the loadTextureFromApk() function and wrote the loadTextureFromByteArray() function ):
I added the following codes into the begining of renderFrame() function in ImageTargetRenderer.java, to generate a new texture and bind it to GLES20.GL_TEXTURE_2D, and it worked!
GLES20.glGenTextures(1, mTextures.get(0).mTextureID, 0);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA,
mTextures.get(0).mWidth, mTextures.get(0).mHeight, 0, GLES20.GL_RGBA,
Before that, I tried to call initRendering() after the texture is loaded, but it didn't work. I also tried to change my texture into 512*512 size, which didn't work either.
I've been searching for the solution for almost two days and finally I fixed it with myself! Hope this can help you.
This solution may cost lots of CPU time and I'm looking for a faster solution.