GithubHelp home page GithubHelp logo

skanti / android-manual-build-command-line Goto Github PK

View Code? Open in Web Editor NEW
81.0 11.0 14.0 75 KB

Sample Code on the creation of Android APKs using command line & makefile only.

Makefile 7.84% Java 7.21% CMake 38.56% C++ 46.39%

android-manual-build-command-line's Introduction

Android-Manual-Build-Command-Line

Sample Code on the creation of Android APKs using command line & makefile only.

This is a sample/example code on how to create an android project with the command line only.

  • No use of gradle, ant, maven, android.mk and all that other stuff.

Description

I prepared 2 samples:

  • hello-jni: This is the same demo as the one you find in the android-ndk official sample repository. However, with the difference that I do not use gradle.

  • native-activity: This should be the more interesting sample because I completely bypass having Java code - no Java UI. That means c++ wrappers are not needed nor System.loadLibrary("hellojni"); calls from Java. The entry point (main) for the program is in the .cpp file like a regular c++ software. It is a little bit difficult to understand what is going on because you have to take care of the main loop, the rendering and querying inputs yourself. It is more low-level but I think you want that kind of control. Again, no gradle involved.

Why

  • Your want full flexibility and know what you do.
  • You not need most of gradles services
  • You do not want bloat your project.
  • 15+ seconds build time via gradle is unacceptable.

Dependencies (aka what I was using)

  • android built-tools 25.0.3
  • andrioid ndk r14b
  • Java JDK 1.8.0_131 (dex has issues with Java 1.8 for the moment, but we can compile Java 1.7 compatible code.)

How-To Build & Run

Note that in the CMakeLists.txt file you have to update the paths with your individual paths. That means, you have to download a bunch of software, place them in a folder and set up the native standalone toolchain from the android ndk.

The command to create the standalone-toolchain is

$NDK/build/tools/make_standalone_toolchain.py --arch arm64 --api 24 --install-dir some_folder

Note that api 25 is not available with ndk-r14b because there are no new features since version 24 (android-ndk guys told me).

To build & run in terminal:

cd {hello-jni, native-activity}
mkdir ./build 
cd ./build
cmake ../
make build
make deploy (phone needs to be connected to computer)

If everything goes right, your build will look like this:

good-build

To-Do

  • have CMake as build-system
  • remove Android.mk makefiles. Instead, compile everything by hand. This will give so much more control (no more hidden compilation flags, etc.)

Contact

Feel free to contact me if you have questions or just want to chat about it.

android-manual-build-command-line's People

Contributors

skanti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-manual-build-command-line's Issues

Cannot run makefile command line

Hi @skanti ,
I am trying to using makefile to build android application. When I used your tool, I received this error during the command line: make build

error: 'malloc' was not declared in this scope
             engine->app->savedState = malloc(sizeof(struct saved_state));

Can you take a look? Thank you very much for your support

Trying to follow your sample...

Hi @skanti, just writting here because I couldn't find an email.

I'm trying to support "simple" Makefile building for Android projects for raylib. Right now it's the only supported platform that uses another build system other than plain Makefiles.

After LOT of research I found your project, probably the best reference in the net for a custom and simple Android APK building by command line, I tried to generate Makefiles with CMake but it didn't work.

Would it be possible to get a plain Makefile with all the required targets to build an Android project from command line, or maybe just get the cmd lines required? --> GOT IT!

Another question: Does your current implementation support assets/resources building? --> WORKING on IT...

UPDATE 1: Looking at CMakeList.txt more carefully, I can get command line steps directly from there. Still wondering about assets/resources building...

UPDATE 2: Just got command lines and testing it, also testing resources embedding with aapt -A command...

I think I dropped the issue too soon... in any case, thank you very much for such a great sample!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.