1

In AndroidStudio, I want to create a java-class I can use in several projects. I found a suggestion here, in which I followed the alternative method, and created a project named "LibraryProject" with 'app' renamed to "LibraryModule", and I changed settings.gradle in the main project to the following content:

include ':LibraryModule', ':app'
project(':LibraryModule').projectDir = new File(settingsDir, '../LibraryProject/LibraryModule')

The LibraryProject contains a java class named MyLogger at the location LibraryModule/java/com.example.alexander.libraryproject. But when I try to use it somewhere in the main code (after doing a 'sync'), the MyLogger class is not being found.

Maybe the example in the link is outdated? Or I forgot something 'obvious'? Or made an error somewhere else? How to include the MyLogger java class from LibraryProject into a file in the main project?

Community
  • 1
  • 1
Alex
  • 41,580
  • 88
  • 260
  • 469
  • Maybe MyLogger class is package-private? Have you added LibraryModule to app's build.gradle (using: `compile project(':LibraryModule')`)? – Andrew Oct 07 '16 at 11:51
  • If I do so, I get the following error on a 'sync': `Error:Configuration with name 'default' not found.` – Alex Oct 07 '16 at 11:55
  • That basically means that path is wrong: https://stackoverflow.com/questions/17188489/android-studio-gradle-configuration-with-name-default-not-found – Andrew Oct 07 '16 at 11:56
  • What is the correct path then, given the information in the post? And what path do you mean? Is the answer incorrect I tried to follow? – Alex Oct 07 '16 at 11:58
  • I'm talking about LibraryModule's projectDir - Try absolute path there. I'm guessing that settingsDir is defined in settings.gradle? – Andrew Oct 07 '16 at 12:00
  • I have no idea where 'settingsDir' is defined. – Alex Oct 07 '16 at 12:02
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/125172/discussion-between-jereksel-and-alex). – Andrew Oct 07 '16 at 12:02

0 Answers0