Java Question (SOLVED) Gradle Dependencies compileOnly

walterf25

Expert
Licensed User
Longtime User
Hi all, i was wondering if i could get some insight on whether Projects created in Android Studio would have slight differences specifically when using the compileOnly directive in the build.gradle file.

The reason i ask this is because I am wrapping a library for someone for a POS SDK, and i am facing an issue that i had never seen before, i have wrapped many POS libraries before but never came across this issue.

The issue i am facing is that the Printing function doesn't seem to work, everything else works fine, the NFC function, MagneticCardReader, Barcode Scanner etc.. But for some reason the Printer function doesn't seem to work, however i do not get any errors or exceptions, it just simply does not print.

I used the same code (Code provided by the Manufacturer) in an small Android Studio project, compiled and installed the apk into the Device and it works just fine, But for some reason the same code doesn't work in the library wrapper. The only differences I can think of are the gradle settings in Android Studio, specifically the compileOnly under dependencies.

From my understanding the definition of compileOnly is the following:
Compile-only dependencies are distinctly different than regular compile dependencies. They are not included on the runtime classpath and they are non-transitive, meaning they are not included in dependent projects. This is true when using Gradle project dependencies and also when publishing to Maven or Ivy repositories. In the latter case, compile-only dependencies are simply omitted from published metadata.

There is also a line that needs to be added to the Manifest file which is the following:
B4X:
<uses-library android:name="com.pos.device"></uses-library>

without this line in the Manifest file the app will crash, when it is added the app compiles and runs but as mentioned above the Printing function doesn't work.

I have tried pretty much everything i can think of but am very puzzled at the fact that the Project with the same code in Android Studio works and the same code in the library wrapper using B4A doesn't.

If anyone has any thoughts or ideas as to why that would be please feel free to comment, i am running out of ideas and need to figure out why this is.

Thanks All,
Walter
 

DonManfred

Expert
Licensed User
Longtime User
Java questions should be postet in the java questions forum like i suggested
 

walterf25

Expert
Licensed User
Longtime User
Remove the jar dependency from the @DependsOn line.

Add it with:
B4X:
#AdditionalJar: yourjar, ReferenceOnly
Wow, so easy, i had actually used the #ExcludeClass and excluded all the classes in the library this seemed to work, but had forgotten about the ReferenceOnly part, dang it.

Thanks guys,
Walter
 

moster67

Expert
Licensed User
Longtime User
Never seen that one. Good to know.
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
Was the printer issue solved?
Yes, this was the problem, the device already has the SDK.jar file inside the system/jar folder and i guess there some complications having the same jar file inside the wrapper library and the device at the same time.

Thanks Erel.
Walter
 
Top