dir.by  
  Search  
Programming, development, testing
Android, Google Play phone, tablet (writing an app, a game)
C++ game (for Android phone) in Android Studio | Android NDK, OpenGL ES
Download bmp file from Assets and draw textures in "Android Native C++ Game" for your phone | Android Studio, Android NDK, OpenGL ES v2 (shader), C++
  Looked at 4031 times    
 Download bmp file from Assets and draw textures in "Android Native C++ Game" for your phone | Android Studio, Android NDK, OpenGL ES v2 (shader), C++ 
last updated: 14 November 2024
Download bmp file from Assets and draw textures in "Android Native C++ Texture Game" for your phone | Android Studio  Android NDK  OpenGL ES v2  shader   C++
Download bmp file from Assets and draw textures in "Android Native C++ Texture Game" for your phone | Android Studio, Android NDK, OpenGL ES v2 (shader), C++
Download the project from github.com:
In Google Chrome open github.com/EvgenProjects/AndroidNative_BasicGame_Texture
Step 1. Creating a project
Step 2. Let's change the code in the file my_game.h
  C++  
#include <android/input.h>
#include <android/asset_manager.h>
#include <EGL/egl.h>
#include "texture_buffer_shader.h"

class MyGame
{
     // constructor
     public: MyGame(AAssetManager* pAssetManager);

     // my objects
protected:
     TextureImageOpenGL m_TextureImage_Hero;
     TextureImageOpenGL m_TextureImage_Ghost;

     BufferPointsOpenGL m_BufferPoints_Hero;
     BufferPointsOpenGL m_BufferPoints_Ghost1;
     BufferPointsOpenGL m_BufferPoints_Ghost2;

     ShaderOpenGL m_ShaderOpenGL;


     // fields
     protected: AAssetManager* m_pAssetManager;
     protected: EGLDisplay m_Display = EGL_NO_DISPLAY;
     protected: EGLSurface m_Surface = EGL_NO_SURFACE;
     protected: EGLContext m_Context = EGL_NO_CONTEXT;
     protected: EGLConfig m_configOpenGL = nullptr;
     protected: int32_t m_Width;
     protected: int32_t m_Height;

     // events
     public: void OnActiveFocus();
     public: void OnLostFocus();
     public: bool OnHandleTouch(AInputEvent* pEvent);
     public: void OnNextTick();

     // OpenGL
     public: void CreateSurfaceFromWindow_OpenGL(ANativeWindow* pWindow); // calling when window set focus (need recreate Surface OpenGL)
     public: void KillSurface_OpenGL(); // calling when window kill focus (need destroy Surface OpenGL)
     public: bool MakeCurrent_Display_Surface_Context_OpenGL();
     public: bool InitGraphic_OpenGL(ANativeWindow* pWindow);
     public: void CloseGraphic_OpenGL();
     public: void DrawGraphic_OpenGL();
};
Step 3. Let's change the code in the file my_game.cpp
File my_game.cpp
...
 
void MyGame::DrawGraphic_OpenGL()
{
     if (m_Display == EGL_NO_DISPLAY || m_Surface == EGL_NO_SURFACE)
          return;

     if (m_Context == EGL_NO_CONTEXT)
          return;

     // green color
     glClearColor(0.72f, 0.87f, 0.55f, 1);
     glClear(GL_COLOR_BUFFER_BIT);

     m_ShaderOpenGL.MakeActive();
     m_ShaderOpenGL.Draw(m_TextureImage_Hero, m_BufferPoints_Hero);
     m_ShaderOpenGL.Draw(m_TextureImage_Ghost, m_BufferPoints_Ghost1);
     m_ShaderOpenGL.Draw(m_TextureImage_Ghost, m_BufferPoints_Ghost2);
     m_ShaderOpenGL.Disable();

     eglSwapBuffers(m_Display, m_Surface);
}
 
...
 
bool MyGame::InitGraphic_OpenGL(ANativeWindow* pWindow)
{
     // init Display
     m_Display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     eglInitialize(m_Display, nullptr, nullptr);

     // init Surface
     CreateSurfaceFromWindow_OpenGL(pWindow);

     // init Context
     EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2,EGL_NONE };
     m_Context = eglCreateContext(m_Display, m_configOpenGL, NULL, contextAttribs);

     if (!MakeCurrent_Display_Surface_Context_OpenGL())
          return false;

     EGLint w, h;
     eglQuerySurface(m_Display, m_Surface, EGL_WIDTH, &w);
     eglQuerySurface(m_Display, m_Surface, EGL_HEIGHT, &h);

     m_Width = w;
     m_Height = h;

     // Open GL states
     glDisable(GL_CULL_FACE);
     glDisable(GL_DEPTH_TEST);
     glEnable(GL_TEXTURE_2D);

     // for alpha color (transparency)
     glEnable( GL_BLEND );
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

     // create shader (for drawing vertex very fast)
     m_ShaderOpenGL.Create();

     // load textures
     m_TextureImage_Hero.Create(m_pAssetManager, "hero.bmp", GL_RGB);
     m_TextureImage_Ghost.Create(m_pAssetManager, "ghost.bmp", GL_RGB);

     // create display points and texture points
     float z = 0;
     PosXYZ_TextureXY* pBuffer = nullptr;

     pBuffer = new PosXYZ_TextureXY[]{
               {.x=0.0, .y=0.5, .z=z, .texture_x=0, .texture_y=0}, // left top
               {.x=0.4, .y=0.5, .z=z, .texture_x=1, .texture_y=0}, // right top
               {.x=0.0, .y=0.9, .z=z, .texture_x=0, .texture_y=1}, // left bottom
               {.x=0.4, .y=0.9, .z=z, .texture_x=1, .texture_y=1} // right bottom
     };
     m_BufferPoints_Hero.Create(pBuffer, 4,GL_TRIANGLE_STRIP);
     delete[] pBuffer;

     pBuffer = new PosXYZ_TextureXY[]{
               {.x=0.5, .y=0.2, .z=z, .texture_x=0, .texture_y=0}, // left top
               {.x=0.7, .y=0.2, .z=z, .texture_x=1, .texture_y=0}, // right top
               {.x=0.5, .y=0.4, .z=z, .texture_x=0, .texture_y=1}, // left bottom
               {.x=0.7, .y=0.4, .z=z, .texture_x=1, .texture_y=1} // right bottom
     };
     m_BufferPoints_Ghost1.Create(pBuffer, 4,GL_TRIANGLE_STRIP);
     delete[] pBuffer;

     pBuffer = new PosXYZ_TextureXY[]{
               {.x=0.8, .y=0.6, .z=z, .texture_x=0, .texture_y=0}, // left top
               {.x=1, .y=0.6, .z=z, .texture_x=1, .texture_y=0}, // right top
               {.x=0.8, .y=0.8, .z=z, .texture_x=0, .texture_y=1}, // left bottom
               {.x=1, .y=0.8, .z=z, .texture_x=1, .texture_y=1} // right bottom
     };
     m_BufferPoints_Ghost2.Create(pBuffer, 4,GL_TRIANGLE_STRIP);
     delete[] pBuffer;


     return true;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Draw textures in OpenGL using Shader
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// load textures
m_TextureImage_Hero.Create(m_pAssetManager, "hero.bmp", GL_RGB);
 // it means loading file hero.bmp from assets folder and will be created texture OpenGL id

m_TextureImage_Ghost.Create(m_pAssetManager, "ghost.bmp", GL_RGB);
 // it means loading file ghost.bmp from assets folder and will be created texture OpenGL id

A note about assets folder:
 I created a folder assets and put 2 files hero.bmp and ghost.bmp in it.
Just like that:
  D:\MyGit\AndroidNative_BasicGame\app\src\main\assets\
      hero.bmp
      ghost.bmp
To create the assets folder, I opened File Explorer and created a new folder.
This path does not need to be connected to the project anywhere.
Read more: How to get bmp file located in Assets inside apk file ... | Android Studio, NDK, C++
 
It's important about the bmp file size for the texture!
When drawing a texture on the screen, the width bmp of the picture must be divided by 4 and the height of the picture must be divided by 4. If it is not divisible by 4, then the texture will not be drawn on the screen
Examples of bmp file:
A good bmp for the texture is: width = 100 points, height = 60 points.
Bad bmp for texture: width = 90 points, height = 60 points (bad because 90 is not divisible by 4). 
 
 
 
 
Step 4. Let's create a new file texture_buffer_shader.h
In this file, I wrote 3 classes:
class TextureImageOpenGL
Loading bmp file from the assets folder and creating OpenGL texture id
class BufferPointsOpenGL
storing 3D points in video card buffer and creating OpenGL buffer id
class ShaderOpenGL
Very fast drawing of 3D points using OpenGL shader
  C++     File texture_buffer_shader.h
#pragma once

#include <GLES2/gl2.h>

struct PosXYZ_TextureXY
{
     float x;
     float y;
     float z;
     float texture_x;
     float texture_y;
};

class TextureImageOpenGL
{
     public:
     TextureImageOpenGL();
     virtual ~TextureImageOpenGL();

     public:
     bool Create(AAssetManager* pAssetManager, const char* filename, GLuint imgFormat);
     int32_t GetTextureId();

     private:
     GLuint m_TextureId;
     void* LoadImageFromAssets(AAssetManager* pAssetManager, const char* filename, int* pFileSize);
     void Swap24BitColors(void* pBuffer, int count);
     void Bmp24BitUpDownLines(void* pColorData, int width, int height);
     void GetBmpWidthHeight(void* pFileData, int count, int* pWidth, int* pHeight, int* pDataOffset);
};

class BufferPointsOpenGL
{
     public:
     BufferPointsOpenGL();
     virtual ~BufferPointsOpenGL();

     public:
     bool Create(PosXYZ_TextureXY* pBuffer, int pointsCount, GLuint pointsModeHowToDraw);
     int32_t GetBufferId();
     GLuint GetPointsModeHowToDraw();
     GLuint GetPointsCount();

     private:
     GLuint m_BufferId;
     GLuint m_PointsModeHowToDraw;
     GLuint m_PointsCount;
};

class ShaderOpenGL
{
     public:
     ShaderOpenGL();
     virtual ~ShaderOpenGL();

     public:
     bool Create();
     void MakeActive();
     void Draw(TextureImageOpenGL& rTextureImageOpenGL, BufferPointsOpenGL& rBufferPointsOpenGL);
     void Disable();
     void Close();

     private:
     GLuint LoadShader(const char *shaderSrc, GLenum type);
     int32_t m_ShaderId;
     int m_SHADER_TEXTURE_parameter_position_index;
     int m_SHADER_TEXTURE_parameter_texture_index;
};
Step 5. Let's create a new file texture_buffer_shader.cpp
  C++     File texture_buffer_shader.cpp
#include <android/native_window.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <android/asset_manager.h>
#include "texture_buffer_shader.h"

#include <string>

bool WaitOpenGlStatus(int goodOpenGlStatus, int waitSeonds)
{
     timespec timeNow1;
     clock_gettime(CLOCK_MONOTONIC, &timeNow1);

     while (true)
     {
          if (glGetError()==goodOpenGlStatus)
               return true;

          sleep(1); // sleep 1 second

          timespec timeNow2;
          clock_gettime(CLOCK_MONOTONIC, &timeNow2);
          if ((timeNow2.tv_sec- timeNow1.tv_sec)>waitSeonds)
               return false;
     };
}

/////////// class TextureImageOpenGL //////////////
TextureImageOpenGL::TextureImageOpenGL()
{
     m_TextureId = 0;
}

TextureImageOpenGL::~TextureImageOpenGL()
{
}

bool TextureImageOpenGL::Create(AAssetManager* pAssetManager, const char* filename, GLuint imgFormat)
{
     m_TextureId = 0;
     int fileSize = 0;
     void* pFileData = LoadImageFromAssets(pAssetManager, filename, &fileSize);

     int width = 0;
     int height = 0;
     int dataOffset = 0;
     GetBmpWidthHeight(pFileData, fileSize, &width, &height, &dataOffset);

     void* pColorData = (char*)pFileData + dataOffset;
     Swap24BitColors(pColorData, fileSize-dataOffset);
     Bmp24BitUpDownLines(pColorData, width, height);

     GLuint textureID = 0;
     glGenTextures(1, &textureID);
     glBindTexture(GL_TEXTURE_2D, textureID);

     glTexImage2D(GL_TEXTURE_2D, 0, imgFormat, width, height, 0, imgFormat, GL_UNSIGNED_BYTE, pColorData);

     if (WaitOpenGlStatus(GL_NO_ERROR, 5 /*seconds to finish wait*/))
     {
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
          glGenerateMipmap(GL_TEXTURE_2D);
     }
     else // error
     {
          textureID = 0;
          return false;
     }

     if (pFileData!= nullptr)
          delete[] ((char*)pFileData);

     glBindTexture(GL_TEXTURE_2D, 0);

     m_TextureId = textureID;
     return true;
}

int32_t TextureImageOpenGL::GetTextureId()
{
     return m_TextureId;
}

void* TextureImageOpenGL::LoadImageFromAssets(AAssetManager* pAssetManager, const char* filename, int* pFileSize)
{
     *pFileSize = 0;
     int readBytesCount = 0;
     char* buffer = nullptr;

     // open file
     AAsset* pAsset = AAssetManager_open(pAssetManager, filename, AASSET_MODE_UNKNOWN);
     if (pAsset== nullptr)
          return nullptr;

     int fileSize = AAsset_getLength64(pAsset);
     if (fileSize==0)
          return nullptr;

     *pFileSize = fileSize;

     buffer = new char [fileSize];
     if (buffer== nullptr)
          return nullptr;

     // read file
     readBytesCount = AAsset_read(pAsset, buffer, fileSize);
     AAsset_close(pAsset);

     if (readBytesCount==fileSize) // good
          return buffer;

     delete[] buffer;
     return nullptr;
}

void TextureImageOpenGL::Swap24BitColors(void* pColorData, int count)
{
     unsigned char* pBuffer = (unsigned char*)pColorData;
     for (int i=0; i<(count-2); i+=3)
          std::swap(pBuffer[i], pBuffer[i+2]);
}

void TextureImageOpenGL::Bmp24BitUpDownLines(void* pColorData, int width, int height)
{
     int bytesCountPerColor = 3;
     const int bytesCountFor1Line = width * bytesCountPerColor;
     char* pData =(char*) pColorData;
     char* pLine = new char[bytesCountFor1Line];
     int iBottom = 0;
     for (int iTop=0; iTop< height / 2; iTop++)
     {
          iBottom = height-1 - iTop;
          memcpy(pLine, pData+(iTop*bytesCountFor1Line), bytesCountFor1Line);
          memcpy(pData+(iTop*bytesCountFor1Line), pData+(iBottom*bytesCountFor1Line), bytesCountFor1Line);
          memcpy(pData+(iBottom*bytesCountFor1Line), pLine, bytesCountFor1Line);
     }
     delete[] pLine;
}

void TextureImageOpenGL::GetBmpWidthHeight(void* pFileData, int count, int* pWidth, int* pHeight, int* pDataOffset)
{
     const int DATA_OFFSET_OFFSET = 0x000A;
     const int WIDTH_OFFSET = 0x0012;
     const int HEIGHT_OFFSET = 0x0016;

     *pWidth = *(int*)((char*)pFileData + WIDTH_OFFSET);
     *pHeight = *(int*)((char*)pFileData + HEIGHT_OFFSET);
     *pDataOffset = *(int*)((char*)pFileData + DATA_OFFSET_OFFSET);
}

//////////// class BufferPointsOpenGL to create 3d points in video card buffer ///////////////
BufferPointsOpenGL::BufferPointsOpenGL()
{
     m_BufferId = 0;
     m_PointsCount = 0;
     m_PointsModeHowToDraw = 0;
}

BufferPointsOpenGL::~BufferPointsOpenGL()
{
}

bool BufferPointsOpenGL::Create(PosXYZ_TextureXY* pBuffer, int itemsCount, GLuint pointsModeHowToDraw)
{
     m_BufferId = 0;
     m_PointsCount = itemsCount;
     m_PointsModeHowToDraw = pointsModeHowToDraw;

     glGenBuffers(1, &m_BufferId);
     glBindBuffer(GL_ARRAY_BUFFER, m_BufferId);
     glBufferData(GL_ARRAY_BUFFER, sizeof(PosXYZ_TextureXY)*itemsCount, pBuffer, GL_STATIC_DRAW);
     return true;
}

int32_t BufferPointsOpenGL::GetBufferId()
{
     return m_BufferId;
}

GLuint BufferPointsOpenGL::GetPointsModeHowToDraw()
{
     return m_PointsModeHowToDraw;
}

GLuint BufferPointsOpenGL::GetPointsCount()
{
     return m_PointsCount;
}

//////////////////// class ShaderOpenGL ///////////////
ShaderOpenGL::ShaderOpenGL()
{
     m_ShaderId = 0;
     m_SHADER_TEXTURE_parameter_position_index = 0;
     m_SHADER_TEXTURE_parameter_texture_index = 0;
}

ShaderOpenGL::~ShaderOpenGL()
{
     Close();
}

bool ShaderOpenGL::Create()
{
     m_ShaderId = 0;

     const char* vertexShaderStr = R"(
               attribute vec3 aPos;
               attribute vec2 aTexCoord;

               varying vec2 TexCoord;

               void main()
               {
                    gl_Position = vec4(aPos, 1.0);
                    gl_Position.x = gl_Position.x * 2.0 - 1.0; // I use x from [0, 1] in my files. This line converts x from [0, 1] -> openGL standard [-1, 1]
                    gl_Position.y = -(gl_Position.y * 2.0 - 1.0); // I use y from [0, 1] in my files. This line converts y from [0, 1] -> openGL standard [1, -1]
                    TexCoord = vec2(aTexCoord.x, aTexCoord.y);
               }
     )"
;

     const char* fragmentShaderStr = R"(
               precision mediump float;
               varying vec2 TexCoord;

               uniform sampler2D textureGood;
               void main()
               {
                    gl_FragColor = texture2D(textureGood, TexCoord);
               }
     )"
;

     GLuint vertexShader;
     GLuint fragmentShader;
     GLint linked;

     // Load the vertex/fragment shaders
     vertexShader = LoadShader(vertexShaderStr, GL_VERTEX_SHADER);
     fragmentShader = LoadShader(fragmentShaderStr, GL_FRAGMENT_SHADER);

     // Create the program object
     int32_t myGraphicObject = glCreateProgram();
     if(myGraphicObject == 0)
     {
          return false;
     }

     // Attach shaders to program
     glAttachShader(myGraphicObject, vertexShader);
     glAttachShader(myGraphicObject, fragmentShader);

     // Link the program
     glLinkProgram(myGraphicObject);

     m_SHADER_TEXTURE_parameter_position_index = glGetAttribLocation(myGraphicObject, "aPos");
     m_SHADER_TEXTURE_parameter_texture_index = glGetAttribLocation(myGraphicObject, "aTexCoord");

     // Check the link status
     glGetProgramiv(myGraphicObject, GL_LINK_STATUS, &linked);
     if(!linked)
     {
          GLint infoLen = 0;
          glGetProgramiv(myGraphicObject, GL_INFO_LOG_LENGTH, &infoLen);

          if(infoLen > 1)
          {
               char* infoLog = new char[infoLen];
               glGetProgramInfoLog(myGraphicObject, infoLen, NULL, infoLog);
               //LOG_WARN("Error linking program:\n%s\n", infoLog);

               delete[] infoLog;
          }

          glDeleteShader(vertexShader);
          glDeleteShader(fragmentShader);

          glDeleteProgram(myGraphicObject);
          return false;
     }

     glDeleteShader(vertexShader);
     glDeleteShader(fragmentShader);

     m_ShaderId = myGraphicObject;
     return true;
}

void ShaderOpenGL::Close()
{
     if (m_ShaderId!=0)
     {
          glDeleteProgram(m_ShaderId);
          m_ShaderId = 0;
     }
}

GLuint ShaderOpenGL::LoadShader(const char *shaderSrc, GLenum type)
{
     GLuint shader;
     GLint compiled;

     // Create the shader object
     shader = glCreateShader(type);
     if(shader != 0)
     {
          // Load the shader source
          glShaderSource(shader, 1, &shaderSrc, NULL);

          // Compile the shader
          glCompileShader(shader);
          // Check the compile status
          glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);

          if(!compiled)
          {
               GLint infoLen = 0;
               glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);

               if(infoLen > 1)
               {
                    char* infoLog = new char[infoLen];
                    glGetShaderInfoLog(shader, infoLen, NULL, infoLog);
                    //LOG_WARN("Error compiling shader:\n%s\n", infoLog);
                    delete[] infoLog;
               }
               glDeleteShader(shader);
               shader = 0;
          }
     }
     return shader;
}

void ShaderOpenGL::MakeActive()
{
     // Use the program object
     glUseProgram(m_ShaderId);

     glEnableVertexAttribArray(m_SHADER_TEXTURE_parameter_position_index);
     glEnableVertexAttribArray(m_SHADER_TEXTURE_parameter_texture_index);
}

void ShaderOpenGL::Disable()
{
     glDisableVertexAttribArray(m_SHADER_TEXTURE_parameter_position_index);
     glDisableVertexAttribArray(m_SHADER_TEXTURE_parameter_texture_index);
     glUseProgram(0);
}

void ShaderOpenGL::Draw(TextureImageOpenGL& rTextureImageOpenGL, BufferPointsOpenGL& rBufferPointsOpenGL)
{
     glBindTexture(GL_TEXTURE_2D, rTextureImageOpenGL.GetTextureId());

     // data
     glBindBuffer(GL_ARRAY_BUFFER, rBufferPointsOpenGL.GetBufferId());

     // vertex pos and texture coord
     glVertexAttribPointer(m_SHADER_TEXTURE_parameter_position_index,
                              3 /*fields with type float*/, // x,y,z
                              GL_FLOAT,
                              GL_FALSE,
                              sizeof(PosXYZ_TextureXY),
                              (GLvoid*)0
     );

     // texture
     glVertexAttribPointer(m_SHADER_TEXTURE_parameter_texture_index,
                              2 /*fields with type float*/, // texture_x, texture_y
                              GL_FLOAT,
                              GL_FALSE,
                              sizeof(PosXYZ_TextureXY),
                              (GLvoid*)( sizeof(PosXYZ_TextureXY::x) + sizeof(PosXYZ_TextureXY::y) + sizeof(PosXYZ_TextureXY::z) )
     );

     // draw
     glDrawArrays(rBufferPointsOpenGL.GetPointsModeHowToDraw(), 0, rBufferPointsOpenGL.GetPointsCount());
}
Note!
Vertex Shader is responsible for transforming coordinates.
Fragment Shader takes texture coordinates and computes color to each pixel.
Step 6. Let's change the code in the file CMakeLists.txt
I include the file texture_buffer_shader.cpp in the project, i.e. this file will participate in the compilation
  File CMakeLists.txt
...

add_library(MyCPlusPlusActivity
          SHARED
          main.cpp
          texture_buffer_shader.cpp
          my_game.cpp)

...
 
← Previous topic
Draw a triangle with paint inside in "Android Native C++ Game" for phone | Android Studio, Android NDK, OpenGL ES v1, C++
 
Next topic →
How to get bmp file located in Assets inside apk file ? | Android Studio, NDK, C++
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

  Объявления  
  Объявления  
 
What is the Android operating system? What version numbers were in Android
What are ARM processors? | Android
Что такое AndroidX?
Java application (for Android phone) in Android Studio
Why Android applications are written in Java?
Download and install Android Studio to write programs for Android phones in Java, Kotlin
Open Android Studio on the computer (Windows 10)
Create a new project on Java with one simple Activity in Android Studio (write a program for Android phones, tablets) in Windows 10
Compile and run the application in Android Studio on computer (Windows) in emulator mode Android Device
Running the application Android Studio in debugging on computer (Windows) in emulator mode Android Device
Error "error while waiting for device: the emulator process for ..... has terminated" when running an application in Android Studio on a computer (Windows) in emulator mode Android Device
Error "Error while waiting for device: Illegal char <*> at index 0: *.lock ..." when running the application in Android Studio
Error "AVD is already running ..." when running the application in Android Studio
Error "CMake "3.18.1" was not found in SDK, PATH, or by cmake.dir property" when compiling a project to Android Studio
Error "Execution failed for task ":app:compressDebugAssets" when compiling a project to Android Studio
All errors when starting the Android application
What is Android SDK (a copy of the Android operating system)? Installing Android SDK 8.1 in Android Studio ...
Create a Android virtual device in Android Studio
Install HAXM
Activity in Android
Kotlin application (for Android phone) in Android Studio
Download and install Android Studio to write programs for Android phones in Java, Kotlin
Create a new project "Empty Views Activity" on Kotlin in Android Studio (write a program for Android phones, tablets) in Windows 10
Compile and run Kotlin an application in Android Studio on a computer (Windows) in emulator mode Android Device
Run Kotlin an application in Android Studio in debugging on a computer (Windows) in emulator mode Android Device
Running and debugging Kotlin Android Studio app on my phone via USB
Long wait when running Kotlin Android application. I see the message: "I/zygote:Waiting for a blocking GC ProfileSaver"
Create Android project, add TextView and show the value on the phone | Android Telephone, Android Studio, Kotlin, Windows 10
Copy the data in the class and object. We use the attribute @Parcelize and the interface Parcelable. | Kotlin | Android Studio
Error "Class is not abstract and does not implement abstract member public abstract fun describeContents(): Int defined in android.os.Parcelable" | Kotlin | Android Studio | @Parcelize | Parcelable
Show a window with 2 buttons: yes, no and you don't need to add any resource, layout | I call the AlertDialog function in Kotlin | Android Studio
Android Kotlin application takes photo using camera and draws in the application | Android Studio | Kotlin
Android Kotlin choose photo from gallery and draws in the application | Android Studio | Kotlin ...
getExternalFilesDir - function that returns the full path to an external directory where our application can place persistent files | Android Studio, Kotlin
getFilesDir - function that returns the full path to directory where our application can place files | Android Studio, Kotlin
How do I work with files media in Android? What are content Uri and file path. The difference between getExternalFilesDir and getFilesDir ... | Android Studio, Kotlin
How to Make a Variable in the build.gradle File and Pass It to the Manifest File AndroidManifest.xml | Android Studio | Kotlin
How to Make a Variable in a build.gradle File and Pass It to a Kotlin File | Android Studio | Kotlin
Moshi (converting json text to a class object) | deserialization in Kotlin | Android Studio
Moshi (converting array json to list of object) | deserialization in Kotlin | Android Studio
Error "Failed to find the generated JsonAdapter class for class com.example.androidkotlinapp1.MyBook" | Exception | Kotlin | Moshi | Android Studio
Error "A problem occurred evaluating project ':app'. Caused by: CustomMessageMissingMethodException: Could not find method kapt() for arguments [com.squareup.moshi:moshi-kotlin-codegen:1.14.0]" | When compiling a Kotlin, Moshi project in Android Studio
Jetpack application (for Android phone) in Android Studio | Kotlin
What is Jetpack for Android?
Create a new project "Jetpack Compose" on Kotlin in Android Studio (write a program for Android phones, tablets) in Windows 10
Compilation error "Dependency 'androidx.core:core-ktx:1.17.0' requires Android Gradle plugin 8.9.1 or higher" | Jetpack | Kotlin | Android Studio
C++ game (for Android phone) in Android Studio | Android NDK, OpenGL ES
What is Android NDK for Android phone? This is the C++ library for the Android phone.
What is Android OpenGL ES for Android phone? This is the C++ graphics library for the Android phone.
Create a project "Android Native C++ Game" for the phone | Android Studio, Android NDK, OpenGL ES, C++
Drawing a lake by points for the 2D game
Drawing an enemy airplane as a vector graphic in Adobe Illustrator. I take the coordinates of the points from Adobe Illustrator and add them to my 2D game on C++ OpenGL
Compile and run "Android Native C++ Game" in Android Studio on a computer (Windows) in Android Device emulator mode
Error "[CXX1405] error when building with cmake using CMakeLists.txt: C build system [configure] failed while executing cmake.exe" when compiling Android Native C++ an application to Android Studio on computer (Windows)
Error "ninja: error: rebuilding 'build.ninja': subcommand failed" when compiling Android Native C++ an application to Android Studio on computer (Windows)
Draw a triangle with paint inside in "Android Native C++ Game" for phone | Android Studio, Android NDK, OpenGL ES v1, C++
Download bmp file from Assets and draw textures in "Android Native C++ Game" for your phone | Android Studio, Android NDK, OpenGL ES v2 (shader), C++
How to get bmp file located in Assets inside apk file ? | Android Studio, NDK, C++
How to use alpha transparency in displaying texture using OpenGL? | Android Studio, OpenGL ES, NDK, C++
Why does glTexImage2D return error code 1280? | Android Studio, OpenGL ES, NDK, C++
What are cpp and h files in C++? | Android Studio, NDK, C++
How to create new h file and add to project android NDK C++? | Android Studio, NDK, C++
How to create new cpp file and add to project android NDK C++? | Android Studio, NDK, C++, CMakeLists.txt
dynamic_cast in C++ (converting a pointer to a different type and checking validity in runtime) | Android Studio, NDK, C++
std::map<Key, Value> is a set of keys and values in C++. | Android Studio, NDK, C++
Pass a function as a parameter to a function (callback) | C++ | Android Studio, NDK, C++
How to find event when display rotated (changed orientation) in Android phone | Android Studio, NDK, C++
How to handle events in Android phone (create/terminate window event, set focus, lost focus, touch in phone) | Android Studio, NDK, C++
Create a signed apk file in Android Studio | Android NDK, OpenGL ES
Google Play Console (for developer)
Creating a Google Play account developer | Google Play Console
The developer in Google Play Console needs to verify the identity | Google Play Console
The developer in Google Play Console needs to confirm developer account | Google Play Console
Developer account is not in use | Developer account is at risk of being closed | Google Play Console
Compile app and send it for production in Google Play Console | My app in Google Play Console
Policy status "Invalid Privacy policy" | Provide link to a valid privacy policy page | My app in Google Play Console
Policy status "App must target Android 15 (API level 35) or higher" | Status "You won't be able to release app updates" | My app in Google Play Console
Policy status "App must target Android 14 (API level 34) or higher" | Status "You won't be able to release app updates" | My app in Google Play Console
Policy app content "Remove Photo and video permissions permission or submit declaration" | My app in Google Play Console
Create an application in Google Play Console (in the option I select that it will be a game) | My game in Google Play Console
Important parameters: package, applicationId, versionCode, versionName, android:label (in AndroidManifest.xml, build.gradle) to create a test version for Google Play Console | My game in Google Play Console
Create a signed .aab file in Android Studio | My game in Google Play Console
Compile the game and send it for internal testing in Google Play Console | My game in Google Play Console
Google automatically ran tests and made pictures, a report on how the game runs on different brands of phones | My game in Google Play Console
How do I ask Google Play Developer Console a support question?
Google Play Developer Console support feedback
Topics about Google Play Billing & in-app purchase | Google Play Console
Can I use (integrate) payments in my Google game if I am a developer from Belarus? | Monetization in Google Play Console
How can I change the Google Play Console language? | Google Chrome
How to change country in payments profile? | Google Play Console
How do I view (open) a payment page in Google Play? | Google Play Console

  Ваши вопросы присылайте по почте: info@dir.by  
Яндекс.Метрика