Skip to content

How to publish android .aar packages? #137

@mrousavy

Description

@mrousavy

Ask your Question

What do I need to do to publish android .aar packages?

I have a package that contains a lot of native (.cpp) code, which I'd like to pre-build for the user.

My android folder in my react-native library looks like this:

Screenshot 2021-02-25 at 09 36 44

I'd like to pre-compile the following files/directories:

  • cpp-adapter.cpp
  • MMKV/Android
  • MMKV/Core
  1. How do I do that? Those 3 files/folders are already mentioned in the CMakeLists.txt, I assume that's enough
  2. What other changes do I need to make? Do I need to add something to the build.gradle?
  3. What files to I have to publish to npm? I currently have:
{
  "files": [
    "android/src",
    "android/build.gradle",
    "android/gradle.properties",
    "lib/aar",
    "lib/commonjs",
    "lib/module",
    "lib/typescript",
    "ios/**/*.h",
    "ios/**/*.m",
    "ios/**/*.mm",
    "ios/**/*.cpp",
    "react-native-mmkv.podspec",
    "README.md"
  ],
}

but that doesn't work since it can't find the CMakeLists.txt I mentioned in my build.gradle. If I add the CMakeLists.txt it complains since it can't find the .cpp files. If I remove android/ entirely, it simply doesn't use the native module.

I believe it simply ignores the lib/aar folder 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions