Guidelines for connecting a local JAR dependency in a NativeScript Plugin

Currently, I am working on a NativeScript plugin that involves wrapping functionalities from a JAVA library. The usual method followed by users is to define a dependency using `compile 'org.namespace:library:x.y.z'` in `src/platforms/android/include.gradle`. However, the specific library I am working with is not available in any JAVA repositories; instead, it is in a standalone `.jar` file.

I have attempted various suggestions that are commonly used for actual Android apps, but as NativeScript operates differently, these methods have proven unsuccessful so far.

Here are the steps I have tried:

1) Modify `platforms/android/include.gradle`

repositories {
  flatDir {
    dirs 'libs'
  }
}

dependencies {
  compile name: 'SimpleNetworking'
}

2) Another modification in `platforms/android/include.gradle`

dependencies {
  compile files('libs/SimpleNetworking.jar')
}

Both of my attempts resulted in failure when testing this plugin in a NativeScript app that requires it as a dependency:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration 
':app:debugCompileClasspath'.
 > Could not find :SimpleNetworking:.
   Required by:
     project :app

The specific plugin I'm currently addressing can be found here.


Update

Upon referring to the Android Studio documentation regarding build dependencies and making changes to the `include.gradle` file as follows:

dependencies {
  implementation files('libs/SimpleNetworking.jar')
}

Now, it seems like the file has been located! However, there appears to be another issue:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Failed to transform file 'SimpleNetworking.jar' to match attributes {artifactType=processed-jar} using transform IdentityTransform
> Transform output file /Users/USERNAME/git/ons-testapp/platforms/android/app/libs/SimpleNetworking.jar does not exist.

It's unclear whether this error is related or something entirely new.

Answer №1

To add your JAR / AAR files to the platforms/android directory, simply place them there and your plugin will detect them during the compilation process.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issues with exporting function and interface have been identified

When exporting a function and type from the library in the convertToUpper.ts file, I have the following code: export function Sample() { console.log('sample') } export type IProp = { name: string age: number } The index.ts file in my lib ...

Passing data from the front-end of an Angular component (app.component.html) to the back-end of another component (other.component.ts)

Imagine a scenario involving basic crud operations. Within the app.component.html file, there are multiple input fields and buttons. Upon clicking a button in app.component.html, the value of an HTML field is sent to the 'other.component.ts' comp ...

Verify the dates in various formats

I need to create a function that compares two different models. One model is from the initial state of a form, retrieved from a backend service as a date object. The other model is after conversion in the front end. function findDateDifferences(obj1, ...

Create a function that takes in a function as an argument and generates a new function that is identical to the original function, except it has one

I want to establish a function called outerFn that takes another function (referred to as innerFn) as a parameter. The innerFn function should expect an object argument with a mandatory user parameter. The main purpose of outerFn is to return a new functio ...

Is it possible for a conditional type in TypeScript to be based on its own value?

Is it possible to use this type in TypeScript? type Person = { who: string; } type Person = Person.who === "me" ? Person & Me : Person; ...

Understanding the concept of inconsistent return points in Typescript: What implications does it carry?

I am currently working on converting a NodeJs JavaScript code to TypeScript. The code snippet below shows how I save uploaded files using JavaScript and now I'm encountering an error when trying to do the same in TypeScript. The error message says "Fu ...

`How can I extract HTMLElements from slots in vue3?`

When attempting to develop a Layer component, I encountered some challenges. Here is the code: // Wrapper.vue <template> <slot v-bind="attrs"></slot> </template> <script lang="ts" setup> import { defi ...

Why is it that TypeScript struggles to maintain accurate type information within array functions such as map or find?

Within the if block in this scenario, the p property obtains the type of an object. However, inside the arrow function, it can be either an object or undefined. const o: { p?: { sp?: string } } = { p: {} } if (o.p) { const b = ['a'].map(x => ...

Dynamic Object properties are not included in type inference for Object.fromEntries()

Hey there, I've been experimenting with dynamically generating styles using material UI's makeStyles(). However, I've run into an issue where the type isn't being correctly inferred when I use Object.fromEntries. import * as React from ...

Hibernate Entities are experiencing issues with updating and editing functionality

After attempting various cascade type combinations on Team and TeamMembers, I am still facing difficulties in updating/editing a specific TeamMember using manual/Selenium tests. The root of the issue seems to be with hibernate: SEVERE: Servlet.service() f ...

Is there a way to convert my messages into different languages without relying on the 'translate' directive or pipe?

Currently, my Angular application is set up with ngx-translate for translation purposes. While it is currently monolingual, I am already looking ahead to the possibility of needing to translate it in the future. Everything is functioning perfectly, but I w ...

"Modify page parameters on a modal window close event in the 6th wicket

I am utilizing Wicket version 6.17.0 to develop an application. The application comprises of two main pages, PollInvullenPage and PollAanmakenPage. PollInvullenPage is utilized by the user to fill out an existing poll that was created with PollAanmakenPage ...

Generating a Two-Dimensional Array from a File and Calculating the Mean

Does anyone have any advice on how to create a 2D array from numbers in a text file, print it, and find the average of each column? I keep getting a "Type mismatch: cannot convert from java.lang.String to int" error on "int rows" and "int columns". Any hel ...

Encasing distinct HTML text with a custom color palette

How can I create a specific color scheme for my HTML table's Status parameter, where the values can be SUCCESS, FAILURE, or IN PROGRESS? I'm utilizing Angular 4 (HTML and TypeScript) for this task. Any tips on how to achieve this? ...

Confirm the Keycloak token by checking it against two separate URLs

In my system, I have a setup based on Docker compose with back-end and front-end components. The back-end is developed using Python Flask and runs in multiple docker containers, while the front-end is coded in TypeScript with Angular. Communication between ...

In Java, computing the hash code of an object can be done using either `object

Here's a straightforward inquiry: are object.hashCode() and Objects.hashCode(object) equivalent? What sets them apart? Do they generate the same hash value for objects? ...

Dealing with an AWS S3 bucket file not found error: A comprehensive guide

My image route uses a controller like this: public getImage(request: Request, response: Response): Response { try { const key = request.params.key; const read = getFileStream(key); return read.pipe(response); } catch (error ...

Invoke the REST API when a checkbox is selected

I have a React component that I need help with: import * as React from 'react'; import './Pless.css'; interface Props { handleClose: () => void; showPless: boolean; } export class Pless extends React.Component<Props> ...

The functioning of the dot operator when used with objects

As I familiarized myself with the working principles of the dot operator, which functions similarly to the * operator in C++, as they both serve the purpose of dereferencing. When we use the dot operator on a class or object, we navigate to the heap of the ...

What is the best way to include a minified bootstrap file in a TypeScript project?

Instead of using react-bootstrap, I only want to add the minified CSS. I went ahead and copied the original CSS file into my project, then added the path in the index.html, but unfortunately, it's still not working. <head> <meta charset=&quo ...