Skip to content

Commit

Permalink
treewide: integrate with NDK
Browse files Browse the repository at this point in the history
  • Loading branch information
uditkarode committed Oct 12, 2020
1 parent f2a7beb commit 5b118c7
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .idea/dictionaries/udit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
song-actions

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
src/main/cpp/song-actions.cpp )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

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 )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
song-actions

# Links the target library to the log library
# included in the NDK.
${log-lib} )
13 changes: 13 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
ndkVersion '21.0.6113669'
lintOptions { disable 'RestrictedApi' }
compileSdkVersion 30
buildToolsVersion "29.0.3"
Expand All @@ -12,6 +13,12 @@ android {
targetSdkVersion 30
versionCode 1
versionName "InterdimensionalBoop"

externalNativeBuild {
cmake {
cppFlags ""
}
}
}

compileOptions {
Expand Down Expand Up @@ -44,6 +51,12 @@ android {
}
}

externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}

packagingOptions {
exclude 'lib/x86_64/**'
exclude 'lib/armeabi-v7a/**'
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/cpp/song-actions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <jni.h>

// example fn:
//extern "C" JNIEXPORT jstring JNICALL
//Java_io_github_uditkarode_able_activities_MainActivity_getStringFromJNI( JNIEnv* env,
// jobject thiz ) {
//}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class MainActivity : MusicClientActivity(), Search.SongCallback, ServiceResultRe

override fun onCreate(savedInstanceState: Bundle?) {
NewPipe.init(CustomDownloader.getInstance())
System.loadLibrary("song-actions")

launch(Dispatchers.Default) {
if (checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
Expand Down

0 comments on commit 5b118c7

Please sign in to comment.