GithubHelp home page GithubHelp logo

andreasluca / ndk-app-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from polishcode/ndk-app-template

0.0 0.0 0.0 112 KB

A revised template for NDK apps.

License: BSD Zero Clause License

C++ 20.28% Kotlin 48.33% CMake 31.38%

ndk-app-template's Introduction

NDK App Template

This is a template application that configures a bit more than the new project wizard in Android Studio. The differences are:

  • Better default gitignore
  • A gitattributes file
  • Includes testing support
  • Removed empty proguard config
  • Updated out of date dependencies
  • A less cluttered CMakeLists.txt
  • Added a version script to protect the app's symbol visibility
  • Uses RegisterNatives via JNI_OnLoad instead of name-based lookups
  • Added C++ unit tests
  • Enable clang-tidy

You should change the following after forking this template:

  1. Change the project name using the rootProject.name property in settings.gradle.
  2. Update the groupId and applicationId. git grep com.example and git grep -i myapplication to find places to update. You'll also need to rename and com/example/myapplication directories to match your new IDs, and update the argument to env->FindClass in JNI_OnLoad.
  3. Update the CMake project name in CMakeLists.txt.
  4. (Optional) Relicense the project if you don't want your code covered by Zero Clause BSD.

How to use this template in Android Studio

Open Android Studio and open this directory when selecting a project.

How to use this template in Visual Studio Code

Warning: I struggled a lot to get this to work, and wasn't happy with the result. The C++ features are annoying to keep working, and I didn't find any answers about how to work with Kotlin or even Java in Android projects. Please send a PR if you figure out better instructions.

Open VSCode and open this directory to create the workspace.

Install the C++ extension.

The C++ extension needs the compile_commands.json file that is generated by CMake during the build, so build the project once to prepare that for the editor: ./gradlew assemble.

Next you need to configure VSCode to use the generated compile_commands.json file. If you open a C++ file in the app project, VSCode may pop up a dialog in the bottom right of the window that will do that for you. If it doesn't, you can configure it manually:

  1. Run find app/.cxx -name compile_commands.json to find the fils that were generated.
  2. Open the C/C++: Edit Configurations (UI) window (ctrl+shift+P or cmd+shift+P on macOS, then search for that)
  3. (Optional) Add a new configuration for this build type, such as Android Debug arm64-v8a (the name doesn't have any special meaning, it's just for your benefit).
  4. Expand the "Advanced" settings
  5. Set the "Compile commands" field to the path of the compile_commands.json file.

In either case, you'll have multiple compile_commands.json files to choose from; one per CMake build type and ABI combo. For example, you'll have RelWithDebInfo/<some hash>/arm64-v8a and Debug/<some hash>/x86. Pick whichever is appropriate for the config you're testing.

Warning: The output location of compile_commands.json is not stable because AGP uses a hash of the CMake commands as part of the output directory as a way to share objects between identical build variants. This means that you may need to repeat these steps if you change your build.gradle file. If the find command above is showing more than one hash for each CMake build type, you'll need to do a clean build and then rebuild to determine which path is the correct one. See https://issuetracker.google.com/232986281 for more information.

ndk-app-template's People

Contributors

danalbert avatar

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.