0

I have a similar problem as described in this Question

So I have an android project which depends on this popular library XChange. As XChange is not very android friendly (Uses JDK 8 streams etc and Android does not support them fully (Link) and I have some other custom requirements for the library, then I decided to fork the project.

So currently I am using IntteliJ Idea to develop the XChange maven project, commit the changes and use Jitpack.io to include the new commit as dependency to Android studio. This works, but is horribly time consuming.

So I have tried or though of the following ways to overcome this.

1) Convert the Maven project to gradle and use the Android studio import feature - This makes a copy of the source code and therefore the git support drops and I cannot pull the changes from the main origin of XChange

2) Convert to gradle project and try to include it through settings.gradle and include it as dependancy as in the referenced question accepted answer at the beginning. This does not work unfortunately, because as XChange has a lot of subprojects and the subproject dependancy import fails.

include ':xchange-core'
include ':xchange-kraken'
project(':xchange-core').projectDir = new File(settingsDir, '../XChange/xchange-core')
project(':xchange-kraken').projectDir = new File(settingsDir, '../XChange/xchange-kraken')

3) Use MavenLocal somehow, but I have no idea how to get this to work (Using IntelliJ idea)

XChange has the following setup

\XChange (has its own pom.xml with settings for all subprojects)
   + xchange-core (main dependency for all subprojects)
   + xchange-kraken
   + xchange-binance
   + ...

So to sum up, Does anyone has a way to save some time on building the project when I need to include my own fork of dependency from disk to Android Studio?

EDIT

Example problem

Settings.gradle

include ':app'
include ':xchange-core'

project(':xchange-core').projectDir = new File(settingsDir, "../XChange/xchange-core/")

Build.gradle ... compile project(':xchange-core')

Error

Error:(4, 0) Could not find method compile() for arguments [{group=com.github.mmazi, name=rescu, version=2.0.1}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

splangi
  • 683
  • 7
  • 17

1 Answers1

0

Here is how I resolved my problems.

Step 1. clone project (in my case the XChange fork) as git submodule to you main app folder, so you can keep version control

git submodule add 'YOUR_GIT_REPOSITORY'

Step 1.5. If you had a maven library project, then run gradle init from terminal at your library folder. This will convert your maven project to gradle one. Necessary for Android Studio.

Step 2. If you have any top level build.gradle or settings.gradle, then forget about those. Defenitely not a perfect solution, but the only way I got it working. In you main apps settings.gradle, you must define each submodule like this

include ':app'
include ':xchange-core'
...

project(':xchange-core').projectDir = new File(settingsDir, "../XChange/xchange-core/")
...

If you had a top level build.gradle in your library project, then put anything you can in your apps top build.gradle file and everything else I copied to the library submodule build.gradle files (Yes, to each and every one)

Step 3. In your apps build.gradle files, now you can include you library submodules as

...
implementation project(':xchange-core')
...

Also, this Medium post was very useful Link

splangi
  • 683
  • 7
  • 17