Before we can use your code, you must sign the Google Individual Contributor License Agreement (CLA), which you can do online. The CLA is necessary mainly because you own the copyright to your changes, even after your contribution becomes part of our codebase, so we need your permission to use and distribute your code. We also need to be sure of various other things—for instance that you'll tell us if you know that your code infringes on other people's patents. You don't have to sign the CLA until after you've submitted your code for review and a member has approved it, but you must do it before we can put your code into our codebase.
Before you start working on a larger contribution, you should get in touch with us first through the issue tracker with your idea so that we can help out and possibly guide you. Coordinating up front makes it much easier to avoid frustration later on.
If this has been discussed in an issue, make sure to mention the issue number. If not, go file an issue about this to make sure this is a desirable change.
All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. We adhere to the
Google Java style guide.
In addition, style and lint checks are run on each Travis build to ensure quality. To run the full
suite of tests, checks, lint, etc, use ./gradlew check
(this will ensure the Travis build passes).
- Submit an issue describing your proposed change to the repo in question.
- The repo owner will respond to your issue promptly.
- If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details below).
- Fork the desired repo, develop and test your code changes.
- Ensure that your code adheres to the existing style of the library to which you are contributing.
- Ensure that your code has an appropriate set of unit tests which all pass.
- Submit a pull request and cc the repo owner @cdm2012
We'd love to accept your sample apps and patches! Before we can take them, we have to jump a couple of legal hurdles.
Please fill out either the individual or corporate Contributor License Agreement (CLA).
- If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an individual CLA.
- If you work for a company that wants to allow you to contribute your work, then you'll need to sign a corporate CLA.
Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests.
- Clone the repo into your project:
git clone https://github.com/the-mac/AndroidJniHelpers.git
- Edit your project structure:
Go to File > Project Structure
- Add module into your project:
Click on "+" sign to add new module
- Import Gradle project:
Click "Import Gradle Project" option
- Paste path to AndroidJniHelpers library project
Paste "path/to/your/project/AndroidJniHelpers" folder into Source directory
- Name New Module (you could name its module library):
By default the existing name should be library ":library", but can be updated
- Rewrite the app/CMakeLists.txt similar to the following (you can find an example here):
cmake_minimum_required(VERSION 3.4.1)
set(local_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp)
set(library_JniHelpers_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../AndroidJniHelpers/library/src/main/cpp)
set(library_JniHelpersTest_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../AndroidJniHelpers/library/src/androidTest/cpp)
file(GLOB libLocal_SOURCES ${local_DIR}/*.cpp)
file(GLOB libLocal_HEADERS ${local_DIR}/*.h)
file(GLOB libJniHelpers_SOURCES ${library_JniHelpers_DIR}/*.cpp)
file(GLOB libJniHelpers_HEADERS ${library_JniHelpers_DIR}/*.h)
file(GLOB libJniHelpersTest_SOURCES ${library_JniHelpersTest_DIR}/*.cpp)
file(GLOB libJniHelpersTest_HEADERS ${library_JniHelpersTest_DIR}/*.h)
link_directories(${JNI_LIBRARIES})
add_library(JniHelpers STATIC ${libLocal_SOURCES} ${libJniHelpers_SOURCES})
add_library(JniHelpersTest STATIC ${libLocal_SOURCES} ${libJniHelpers_SOURCES} ${libJniHelpersTest_SOURCES})
include_directories(${local_DIR} ${library_JniHelpers_DIR} ${library_JniHelpersTest_DIR})
if(${ANDROID_TESTING})
set(library_NAME "test-lib")
set(library_Entry_Point "src/androidTest/cpp")
else()
set(library_NAME "native-lib")
set(library_Entry_Point "src/main/cpp")
endif()
add_library( # Sets the name of the library.
${library_NAME}
# Sets the library as a shared library.
SHARED
# The following toggles between the native-lib and test-libs
# files, based upon whehther a test is currently running.
${library_Entry_Point}/${library_NAME}.cpp )
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Only adding JniHelpersTest library if testing
if(${ANDROID_TESTING})
target_link_libraries(${library_NAME} JniHelpers JniHelpersTest ${log-lib} )
else()
target_link_libraries(${library_NAME} JniHelpers ${log-lib} )
endif()
Note: If you're creating JNI helper tests, you should run them on an Android device and using the test-lib reference above (inside your androidTest/cpp folder). Also the ANDROID_TESTING flag is passed in from the build.gradle script, check out an example of that here
Contributions made by corporations are covered by a different agreement than the one above, the Software Grant and Corporate Contributor License Agreement.