private repo is not compatible with native modules

I have a private gitlab repo and i added this repo to my App’s package.json.

index.js in my private gitlab repo

module.exports = function() {
    console.log("Hello World!!!!")

Now in my App’s package.json i just call this gitlab repo using the deploy token.
Run “npm install” and this package is installed.

enter image description here

Finally import this in my App.js.
This works perfectly. RNN() is called and “Hello World” is logged in the console.

enter image description here

Now in my private Gitlab repo, i changed the index.js to the below code.

// module.exports = function() {
//    console.log("Hello World!!!!")
// }

import { NativeModules } from 'react-native';

const { RNNativeToastLibrary } = NativeModules;

export default RNNativeToastLibrary;

In my android, i have created a new module with a method that just returns the device build model.

enter image description here

Now i install this gitlab repo again in my App. I run “npm install” it shows that package is installed. I run “react-native link native-toast” to link all the dependencies in android. But now when i try to run the app i get this error

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve project :native-toast.
     Required by:
         project :app
      > Unable to find a matching configuration of project :native-toast:
          - None of the consumable configurations have attributes.

I can see settings.gradle has the package enter image description here

In build.gradle(app) enter image description here

But for some reason i cannot add the package in my
It throws cannot recognise symbol error

enter image description here

What am i doing wrong here???
Why isn’t my package being recognised??


If you’ve created the android module yourself, the configuration is definitely wrong somewhere. Instead of debugging this – I suggest you use a module template like builder-bob


npx create-react-native-library [your-lib-name]

to create a completely setup native library (with a sample native bridge method!)

Leave a Reply

Your email address will not be published. Required fields are marked *