Unable to use an android sdk created by me into the other projects

20 Views Asked by At

I am trying to create an android sdk for this I have created new project and in that I created new Module for creating an sdk, here is the code of the module:-

fun calculateFormula(a: Double, b: Double, c: Double, d: Double, e: Double): Double {
    if (c == 0.0) {
        throw IllegalArgumentException("Argument 'c' cannot be zero.")
    }
    return a * b / c + d - e * 65
}

I have successfully use this in the app of the project like this:-

implementation(files("libs/formula-debug.aar"))


            val a = calculateFormula(1.00,1.00,1.00,1.00,1.00)

Then I tried to publish the sdk like this:-

publishing {
    publications {
        create<MavenPublication>("maven") {
            groupId = "com.formula"
            artifactId = "Formula"
            version = "1.0.0"
        }
    }
}

Then I published by running this in the terminal:-

./gradlew publishToMavenLocal

It has successfully created Formula-1.0.0.pom file in C:\Users\user.m2\repository\com\formula\Formula\1.0.0

Formula-1.0.0.pom:-

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.formula</groupId>
  <artifactId>Formula</artifactId>
  <version>1.0.0</version>
  <packaging>pom</packaging>
</project>

Then I implemented the same dependency in other projects like this:- implementation 'com.formula:Formula:1.0.0'

There dependency is injected successfully but when I try to use this same code in the other project I got this error:-

 val a = calculateFormula(1.00,1.00,1.00,1.00,1.00)

I got this error:- Unresolved reference: calculateFormula

When I tried to import it like this:- import com.formula.Formula

still I got this error:- Unresolved reference: formula

In other project I have also added the mavenLocal()

0

There are 0 best solutions below