sharewire / google-maps-clustering

Fast marker clustering library for Google Maps Android API.
Apache License 2.0
292 stars 77 forks source link

Modifying Library in Existing App #6

Closed Therefore closed 6 years ago

Therefore commented 6 years ago

@makovkastar I need to modify some of the library classes such as QuadTree so I can pass additional variables to ClusterItem, but it says that the library is read only since I imported it with gradle.

So I followed guides trying to import it as a module, but always got build errors such as Error:(11, 0) Could not find method compile() for arguments [project ':subProject:library'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. <a href="openFile:C:\Users\Nathan\Android Projects\ImportModule4\build.gradle">Open File</a>

and

Error:(18, 0) Could not find method android() for arguments [build_enfbvdz6abztfoiqie2qzfmjg$_run_closure1@58eced6f] on root project 'ModuleImport2' of type org.gradle.api.Project. <a href="openFile:C:\Users\Nathan\Android Projects\ModuleImport2\build.gradle">Open File</a>

I followed these guides: https://stackoverflow.com/questions/41764338/importing-module-in-android-studio and https://github.com/MagicMicky/FreemiumLibrary/wiki/Import-the-library-in-Android-Studio

Do you have a recommended method to adding your library to an existing project and be able to modify files?

makovkastar commented 6 years ago

Hello @Therefore. Which folder are you choosing when importing the library module? Make sure it's library.

Therefore commented 6 years ago

@makovkastar Would this be the best was to import? File>Import Gradle project> navigate to the library folder?

makovkastar commented 6 years ago

File -> New -> Import module.

Therefore commented 6 years ago

@makovkastar I'm still receiving an error. File>import>new Module. I import the folder google-maps-clustering/library

but still receive: Error:(14, 0) Could not get unknown property 'compileSdkVersion' for root project 'ImportModule13' of type org.gradle.api.Project. <a href="openFile:C:\Users\UserName\Android Projects\ImportModule13\library\build.gradle">Open File</a>

makovkastar commented 6 years ago

OK, I see. You need to go to the build.gradle file of the library module and replace compileSdkVersion, buildToolsVersion, minSdkVersion, targetSdkVersion, versionCode and versionName with the correct values (you can take them from the root build.gradle file).

makovkastar commented 6 years ago

Due to the inactivity, I assume that you managed to import the library. Closing the issue.

Therefore commented 6 years ago

@makovkastar sorry for the lack of responses. I was on vacation for a week and since the topic was closed I kept trying. Today I finally got it to work. here is a brief summary of my steps.

  1. Download the whole project and unzip
  2. in android studio File>new>Import Module - browse to the source and import the "library" folder only.
  3. Modify the Libray's grade file to include the compiled SDK version, build version, minsdk version, targetsdk version, version code, version name, comment out annotations, put your play-version-maps:X.X.X, and publish name. All of this information will be in the project settings.
  4. in the main app's gradle file add compile project(':NAME-OF-THE-LIBRARY)`

from what I have tried so far you can now use the libary as if you had imported it using the steps provided in the read-me.

The purpose for the import in the library was to add the .rotation(float) to the Marker Options.

I want to thank you for this awesome library. If it works how I am hoping it will be the corner stone of my app. I really appreciate you helping me day after day. All the best.