0

I am using Gradle 2.4 and Android Studio 1.3. I have tried to use AppWarp's JAR file as a dependency in a libGDX project. I have got following error during Gradle sync:

Gradle DSL method not found 'compile()'

I put code below in allprojects section.

dependencies {
    compile files('libs/App42MultiPlayerGamingSDK.jar')
}

2 Answers2

0

You can't put "compile" in the allprojects section because that section does not have the java plugin applied, and therefore can only accept classpath dependencies. You could put apply plugin: "java" at the top of the allprojects block, but that will only lead you to the next problem...

Isn't that jar an Android-based library anyway? It will cause your other modules to fail to compile if you put it in allprojects. It needs to go in the android section's dependencies.

Tenfour04
  • 83,111
  • 11
  • 94
  • 154
  • Okay, but in this case how can it work in desktop project. It is a multi platform framework. –  Nov 13 '15 at 19:10
  • There should be a separate library for each supported platform. Download the various libraries and assign them to their respective platforms in your Gradle file. And you will need to create an interface in the core project that the Desktop, Android, etc. projects use to adapt the library for use in core. Read here: http://saltares.com/blog/games/abstracting-platform-specific-code-in-libgdx/ – Tenfour04 Nov 13 '15 at 19:28
  • That is okay, but how can I make this in Gradle script files? –  Nov 13 '15 at 20:13
  • I don't understand your question. – Tenfour04 Nov 13 '15 at 22:52
  • These are specified in Gradle files, not in Java files. So I cannot use interfaces in Gradle script files. –  Nov 14 '15 at 11:59
  • Read that link I put above. No one said anything about putting an interface in the Gradle file. – Tenfour04 Nov 14 '15 at 12:53
  • That is okay, but if I put this dependency in android section it cannot be used in desktop program. –  Nov 14 '15 at 16:50
  • It can't be used by the desktop project anyway because it's an Android library. That's why I said you need to download a separate desktop library for desktop. – Tenfour04 Nov 14 '15 at 18:23
  • Please see my project files here: https://github.com/kovacsa91/superjumper Can you please make a pull reuest for that file maybe? –  Nov 14 '15 at 20:02
  • Sorry, can't invest the time to learn their API and do that. I honestly don't know how to explain it any clearer than above and what's in that linked article. – Tenfour04 Nov 14 '15 at 21:48
  • I know interfaces and how to use platform specific code on another platform, but Gradle's method seems different. I only would like to now, exactly how to integrate jar into Gradle script. –  Nov 15 '15 at 08:59
  • Gradle sync is now successful, but imports are undefined. –  Nov 15 '15 at 20:43
0

AppWarpMultiPlayerGamingSDK should be added to Android Studio as a module in the core project, by right click on project.

Select Module Setting

And SDK as a module library.

Thanks to AppWarp Support Team!

Community
  • 1
  • 1