Java Question Simple Library Compiler + Gradle dependencies

warwound

Expert
Licensed User
Longtime User
I'm try to compile an old eclipse b4a library project that i've converted into an Android Studio project.
The android studio project build.gradle file contains a line:

B4X:
dependencies {
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
}

And Simple Library Compiler fails when it cannot find classes in the above dependency:

Starting step: Compiling Java code.
javac 1.8.0_231
C:\Users\martin\Programming\Basic4Android\SimpleLibraryCompiler\b4a-extras\MapsForgeTileProvider\src\org\mapsforge\android\maps\MapsForgeTileProviderImpl.java:16: error: package com.google.android.gms.maps.model does not exist
public class MapsForgeTileProviderImpl implements com.google.android.gms.maps.model.TileProvider{
^
1 error


Error.

How do i fix this and tell SLC to use the gradle dependency?

Thanks.
 

drgottjr

Expert
Licensed User
Longtime User
you add this to your source:
B4X:
@ShortName("")
@Version()
@DependsOn(values={"com.google.android.gms:play-services-maps:17.0.0"})

then you go find that jar at maven and put in in the libs folder of the slc project. then you copy that jar to your add'l downloads folder. it's what i do when i need something that's not included in the sdk. whether or not finding the jar through the sdk changes things, i'm not sure. i do it as described. at the very least you need to add the @DependsOn() line to the source. and why you need both a copy of the jar in the libs folder and in add'l downloads i can't say. it's what i pieced together from the various slc posts here on the forum. it's worked for a number of my projects and seems to cause no harm.[/code]
 

DonManfred

Expert
Licensed User
Longtime User
How do i fix this and tell SLC to use the gradle dependency?
I don´t know/think SLC is using any Maven functionality.

When i do a wrapper i usually need to find the Mavenartifact needed, extract the classes.jar from the aar and add it to the libs folder of my wrappersource.
I then tell Eclipse to use this dependency.

for my Chromecast library (Casty) i was adding different mavenartifacts (always the classes.jar from a AAR renamed to somewhat.jar and put it in the LIBS folder of my Eclipse project.
 

warwound

Expert
Licensed User
Longtime User
OK so downloading the dependency from the maven repo and extracting the classes.jar to my SLC project seems to have done the trick.

Thanks for the help.
 

drgottjr

Expert
Licensed User
Longtime User
you could use the .aar. in the "dependson" line you have to add the ".aar" suffix. with a ".jar", you don't.
 
Top