Archive 17/01/2023.

Android gradle build

TooLazyy

Hi, im trying to use Urho3D with Android Studio 2.3 and gradle.
What i need - import Urho3D into my project by gradle with CMake script.
I dont need Urho3D samples - just add Urho3D as library inti project (need to user my own models).
I saw that - https://discourse.urho3d.io/t/android-studio-2-3-build-with-gradle/2995
But for an absolute noob with Urho3D like me it doesnt not help.

What i’ve tried - i downloaded Urho3D-1.7 version rar and extracted into Unrho3D.
Copied the whole Urho3D folder into myProject/app directory.
Updated gradle build file:
added to android root tag.
externalNativeBuild {
cmake {
path ‘./Urho3D/CMakeLists.txt’ // relative path to the Urho3D CMakeLists.txt
}
}
{
jniLibs.srcDirs = [‘libs’]
}

I have tried all CMakeLists.txt i could find in Urho3D. Result is the same - failed.

110106
I have my own .cpp file where i capture android.hardware.Camera frames and draw a simple box in the center of the screen (can provide code if needed).

The question is - how to make it works?
I dont want compile NDK and Urho every time, i want to use my own scenes, i want to use fragment, not activity, but cant get how to achieve that.

#EDIT1
I have included mu own .cpp file into CMakeList.txt

cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_CXX_FLAGS_RELEASE “-Ofast -ffast-math”)
set(CMAKE_C_FLAGS_RELEASE “-Ofast -ffast-math”)
add_library(
mim
SHARED
src/main/jni/mymodel.cpp)

THe problem is the path to Urho3D classes, coz ExternalTexture2D, Texture2D and others are not visible. I have moved Urho3D folder into my jni folder.
Dont know how to do it correctly.

weitjong

Unfortunately our build system does not support Gradle out of the box yet. As far as I know, the link that you mentioned is the next best thing in providing the workaround steps.