0

I know similar questions have been asked many times in the past, I'm working to try import a Github project to be a library Github Project for my existing project. I've reference to related stackoverflow solutions discussed here for the steps (visually or setting.gradle/build.gradle code solution) to import it but without any success in it.

Tried including include ':library:CanvasView' into setting.gradle and compile project(':library:CanvasView')into build.gradle

Had error statement Error:Configuration with name 'default' not found. Tried solutions here to solve it without any success.

But for once, I've managed to gradle compile it with this statement, compile it fileTree(dir: 'library', include: ['CanvasView']) in build.gradle

To my dismay, I realize that I was not able to call the API of the library in my main project, because the java file of the imported library was marked with an red icon. Tried solutions here but isn't helping to call the API. Thanks for any help rendered!

Community
  • 1
  • 1
Vivian
  • 1,071
  • 5
  • 16
  • 29

1 Answers1

0

Make sure you have the right names. Note this is assuming you have already checkout your project from github. I usually put the projects under the same workspace directory. Like such:

-Workspace
          --MyApp
          --SomeLib

1.In your settings.gradle make sure you are pointing to the right place. My example:

include ':SomeLib'
project (':SomeLib').projectDir = new File('../SomeLib/SomeLib')

2.In your build gradle make sure you are compiling the right Module name

compile project(':SomeLib')

A good check to see if you are doing things correctly at step 1. Before you go to step 2 make sure the library comes to the Project View. If it comes make sure your actual source code is there. Java classes etc. If you see that stuff then go to step 2. From step 2 you should be good. Let me know how it goes.

To be exact this is your example: settings.gradle

include ':CanvasView'
project (':CanvasView').projectDir = new File('../CanvasView/CanvasView')

build.gradle

compile project(':CanvasView')
TerNovi
  • 390
  • 5
  • 16
  • I've followed exactly as what you stated for setting.gradle and everything seems good where the library come into my project view and content inside, then i proceed to step 2 for build.gradle compiling with the exact code statement you suggested above but error occur stating Error:Configuration with name 'default' not found. If you don't mind can you import successfully too as a library or is the file corrupted? – Vivian Oct 10 '16 at 15:11
  • So the problem might be with another lib. Have you tried to remove CanvasView and then compile? Does it compile fine? – TerNovi Oct 10 '16 at 15:15
  • Also make sure you didn't leave any old includes or are trying to compile anything that doesn't exists. – TerNovi Oct 10 '16 at 15:15
  • Yes I tried removing the old Canvasview and recopy it and recompile it was fine at setting.gradle. Old libraries have been removed when compiling at setting.gradle when the system prompted me. The error occur at build.gradle – Vivian Oct 10 '16 at 15:20
  • Just look at the github project. It isn't compiled as a library – OneCricketeer Oct 10 '16 at 15:21
  • Then how i should be using the API of the github project if i don't import it as a library sorry rather new to android development? – Vivian Oct 10 '16 at 15:23