GithubHelp home page GithubHelp logo

Comments (8)

howardpang avatar howardpang commented on June 27, 2024

from androidnativebundle.

marandaneto avatar marandaneto commented on June 27, 2024

sure.
here is the gradle https://github.com/getsentry/sentry-android/blob/feat/ndk_link/sentry-sample/build.gradle.kts
and here is the cmakelist https://github.com/getsentry/sentry-android/blob/feat/ndk_link/sentry-sample/CMakeLists.txt

trying to import sentry.h here https://github.com/getsentry/sentry-android/blob/feat/ndk_link/sentry-sample/src/main/cpp/native-sample.cpp

thanks a lot.

from androidnativebundle.

howardpang avatar howardpang commented on June 27, 2024

i didn't see the app have dependency for the sentry-android-ndk lib, here is your app dependencies

dependencies{
	implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

	implementation(project(":sentry-android"))

	implementation(Config.Libs.appCompat)

	// debugging purpose
	implementation(Config.Libs.timber)
	debugImplementation(Config.Libs.leakCanary)


	testImplementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))
	testImplementation(Config.TestLibs.junit)
	androidTestImplementation(Config.TestLibs.espressoCore)
	androidTestImplementation(Config.TestLibs.androidxCore)
	androidTestImplementation(Config.TestLibs.androidxRunner)
	androidTestImplementation(Config.TestLibs.androidxJunit)
	androidTestUtil(Config.TestLibs.androidxOrchestrator)
}

you can try to publish your sentry-android-ndk module to maven local, and then add a dependency to app, like this implementation(com.xx.yy:sentry-android-ndk:1.0.0)

from androidnativebundle.

marandaneto avatar marandaneto commented on June 27, 2024

@howardpang ok I see, thanks for pointing it out.
actually our SDK is on jcenter and bintray already so no need to publish it on mavenLocal.

The thing is, sentry-android has the dependency of sentry-android-ndk so it's not need to depend on it directly. maybe that's the issue, does the plugin support transitive dependencies?
I'll try to add the dependency of sentry-android-ndk directly as well just to check if it works.

If the plugin doesn't support transitive dependencies, are you willing to implement it and count on me to help you out? I'd like to help :)

Thanks again.

from androidnativebundle.

marandaneto avatar marandaneto commented on June 27, 2024

actually it worked even as a transitive dependency, nice.
the thing is, it only works when the dependency is a maven dependency, but not a referenced module in the same project.
@howardpang do you have an idea why's that? thanks again.

from androidnativebundle.

howardpang avatar howardpang commented on June 27, 2024

the plugin is design to solve the app module depend a lib module that not in the same project with app. in your satuation, you can use another easy way to implement it. cmake support include other cmake project, here is example:

app CMakeList.txt

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.

set(mylib_src_DIR ../myndklib/src/main/cpp) # another CMakeLists.txt dir

add_subdirectory(${mylib_src_DIR}

        myndklib/outputs # any name you want to set
        )


include_directories(${mylib_src_DIR})


add_library( # Sets the name of the library.
             nativeapp

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             src/main/cpp/native-app.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.
                       nativeapp
                       nativelib  #another library
                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )

lib CMakeLists.txt

 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.
             nativelib

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             mylib.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.
        nativelib


        # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )

from androidnativebundle.

marandaneto avatar marandaneto commented on June 27, 2024

perfect will give it a try, thanks :)

from androidnativebundle.

marandaneto avatar marandaneto commented on June 27, 2024

it worked like a charm, thank you :)

from androidnativebundle.

Related Issues (17)

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.