Reputation: 3309
I'm trying to implement Google Play Game Services, and I need to have BaseGameUtils as a library in my project. Following google tutorials I could not find a way to include this in a project that I already have in android studio. Importing manually in Android Studio...
How should I import BaseGameUtils in a project that already exists? What is the best practice?
Should I copy the whole BaseGameUtils in the libs folder in my module? Or should I copy BaseGameUtils in my project folder?
\Project
|--\module
|--|--\libs
|--|--|--android-support-v4.jar
|--|--|--...
|--|--|--\BaseGameUtils
|--|--|--|--...
|--|--\src
|--|--|--...
or
\Project
|--\module
|--|--\libs
|--|--|--android-support-v4.jar
|--|--|--...
|--|--\src
|--|--|--...
|--\libraries
|--|--\BaseGameUtils
Except in the gradle file (in BaseGameUtils) should I mention anywhere else that BaseGameUtils is a library?
Upvotes: 7
Views: 5041
Reputation: 932
I have been having the same problem for a long time, but I finally found a solution.
compile project(':BaseGameUtils')
to the first line of the dependencies listUpvotes: 1
Reputation: 1539
Upvotes: 4
Reputation: 3489
In Eclipse, you define BaseGameUtils as a library project and add it as a reference to your project.
These instructions cover Android Studio and were (I think) written by the guy who wrote the Google Play Game Services sample programs :
https://github.com/playgameservices/android-samples/blob/master/README.md
They appear to answer you question.
Update:
In Eclipse, what I did was to copy GameHelper and BaseGameActivity (the two sources in BaseGameUtils) into my project. I then added the dependencies (resources). This approach worked fine. However, since I did this Google made this video which advises you against this approach. This is why I answered the question in the way that I did.
https://developers.google.com/live/shows/5936979195723776
Upvotes: 0