
- Android ndk sample code how to#
- Android ndk sample code android#
- Android ndk sample code software#
- Android ndk sample code code#
- Android ndk sample code license#
Android ndk sample code code#
This code will set the clear color to red, and will clear the screen every time on_draw_frame() is called. Let’s add the following implementation to game.c: This header file defines three functions that we’ll be calling from Java. h file is known as a header file, and can be considered as an interface for a given. You can create these files by right-clicking on the folder and selecting New->File. Let’s create two new files in the common folder, game.c and game.h. You should now see a new folder in your project called common, linked to the folder that we created. Enter ‘common’ as the folder name and select Finish, then close the Properties window. Right-click the project again and select Build Path->Link Source…, select Variables…, select COMMON_SRC_LOC, and select OK.Once that’s done, click OK until the Properties window is closed. Now we can set the body of onCreate() as void onCreate(Bundle savedInstanceState) \.\common’ as the location. We’ll first add two member variables to the top of our activity class: With our project created, we can now edit the default activity and configure it to initialize OpenGL. This will create a new folder called jni in the project tree. When asked for the Library Name, enter ‘game’ and hit Finish, so that the library will be called libgame.so.
Android ndk sample code android#
Once the project has been created, right-click on the project in the Package Explorer, select Android Tools from the drop-down menu, then select Add Native Support…. Leaving the rest as defaults or filling out as you prefer, save this new project in a new folder called android, inside of the airhockey folder that we created in the previous step. To create a new project, select File->New->Android Application Project, and then create a new project called ‘AirHockey’, with the application name set to ‘Air Hockey’ and the package name set to ‘’.

Android ndk sample code how to#
To learn more about how to use Git, see the Git documentation. Git is a source version control system that will help you keep track of changes to the source and to roll back changes if anything goes wrong. The first thing to do is create a new Android project in Eclipse, with support for the NDK. You can follow along all of the code at the GitHub project.īefore creating the new project, create a new folder called airhockey, and then create a new Git repository in that folder. To prepare and test the code for this article, I used revision 22.0.1 of the ADT plugin and SDK tools, and revision 17 of the platform and build tools, along with revision 8e of the NDK and Eclipse Juno Service Pack 2.
Android ndk sample code license#
Unless required by applicable law or agreed to in writing, softwareĭistributed under the License is distributed on an "AS IS" BASIS, WITHOUT Use this file except in compliance with the License. The ASF licenses thisįile to you under the Apache License, Version 2.0 (the "License") you may not See the NOTICE file distributed with this work forĪdditional information regarding copyright ownership.
Android ndk sample code software#
Licensed to the Apache Software Foundation (ASF) under one or more contributor LicenseĬopyright 2018 The Android Open Source Project, Inc. Please see CONTRIBUTING.md for more details. Submitting a pull request through GitHub. Patches and new samples are encouraged, and may be submitted by forking this project and If you've found an error in these samples, please file an issue.

