Android en C++ sans JAVA et sans IDE, yeah !
amand fd3a8471d2 rename to TEMPLATE 1 year ago
app first commit 1 year ago
.gitignore first commit 1 year ago
README.md rename to TEMPLATE 1 year ago
build.gradle-TEMPLATE rename to TEMPLATE 1 year ago
local.properties first commit 1 year ago
settings.gradle-TEMPLATE rename to TEMPLATE 1 year ago

README.md

NDK Android without IDE and JAVA

xbps-install gradle

https://developer.okta.com/blog/2018/08/10/basic-android-without-an-ide https://github.com/googlesamples/android-ndk/tree/master

Command

$ cd project $ gradle init

$ cp build.gradle-TEMPLATE build.gradle $ cp settings.gradle-TEMPLATE settings.gradle

$ mkdir -p app/src/main/cpp

create files

$ ./gradlew build $ ./gradlew installDebug

Files

create local.properties sdk.dir=/path/to/sdk ndk.dir=/path/to/ndk

create settings.gradle include ‘:app’

create build.gradle buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}

}

allprojects {

repositories {
    google()
    jcenter()
}

}

task clean(type: Delete) {

delete rootProject.buildDir

}

create gradle.properties ?

create app/build.gradle apply plugin: ‘com.android.application’

android {

compileSdkVersion 28

defaultConfig {
    applicationId 'in.gobel.helloworld'
    minSdkVersion 24
    targetSdkVersion 28
    externalNativeBuild {
        cmake {
            arguments '-DANDROID_STL=c++_static'
        }
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
externalNativeBuild {
    cmake {
        path = 'src/main/cpp/CMakeLists.txt'
    }
}

}

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

}

create app/src/main/cpp/CMakeLists.txt cmake_minimum_required(VERSION 3.4.1)

set(${CMAKE_C_FLAGS}, “${CMAKE_C_FLAGS}“) add_library(native_app_glue STATIC

${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)

set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -Werror”)

set(CMAKE_SHARED_LINKER_FLAGS

"${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")

add_library(helloworld SHARED main.cpp)

target_include_directories(helloworld PRIVATE

${ANDROID_NDK}/sources/android/native_app_glue)

target_link_libraries(helloworld

android
native_app_glue
EGL
GLESv1_CM
log)

create /app/src/main/cpp/main.cpp #include

void android_main(struct android_app *state) { }