Android Studio 3.4 and gradle-5.1.1

Anything libgdx related goes here!

Android Studio 3.4 and gradle-5.1.1

Postby vijaydino » Sun May 05, 2019 7:08 am

Hi,
I ' m using an updated version of the Android Studio that is Android Studio 3.4 and libgdx gradle is not working anymore, because the minimum version of gradle is now 5.1.1 There are several changes
So. i am getting error in desktop module gradle file

Now here is my code of file build.gradle( Module: Desktop)

apply plugin: "java"

sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]

project.ext.mainClassName = "com.dinocodeacademy.blogspot.myfirstgame.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../android/assets");

task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}

task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}

task dist(type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);

manifest {
attributes 'Main-Class': project.mainClassName
}
}

dist.dependsOn classes

eclipse {
project {
name = appName + "-desktop"
linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/android/assets'
}
}

task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
doLast {
def classpath = new XmlParser().parse(file(".classpath"))
new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
def writer = new FileWriter(file(".classpath"))
def printer = new XmlNodePrinter(new PrintWriter(writer))
printer.setPreserveWhitespace(true)
printer.print(classpath)
}
}

------------------------End of the code ----------------------------------------

I 'm getting error on task afterEclipseImport{ } on new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
and also when i try to import the class by Pressing Atl+Enter the error is still because there are lots of classes will pop-pup and i don't know which one is correct

Here is error msg: when the build is failed


ERROR: Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.
Open File



Any help will be appricated
vijaydino
 
Posts: 1
Joined: Sun May 05, 2019 6:43 am

Re: Android Studio 3.4 and gradle-5.1.1

Postby vik182 » Sun May 05, 2019 3:26 pm

vik182
 
Posts: 44
Joined: Wed Jul 04, 2018 9:44 pm

Re: Android Studio 3.4 and gradle-5.1.1

Postby shatterblast » Sun May 05, 2019 7:21 pm

vijaydino wrote:
Here is error msg: when the build is failed


ERROR: Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

Add an 's' to the end of 'classesDir' so that it becomes 'classesDirs'. I made the same mistake.
shatterblast
 
Posts: 404
Joined: Sun Jul 06, 2014 1:14 pm

Re: Android Studio 3.4 and gradle-5.1.1

Postby alexmetalrock » Thu Jul 25, 2019 3:35 am

shatterblast wrote:
vijaydino wrote:
Here is error msg: when the build is failed


ERROR: Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

Add an 's' to the end of 'classesDir' so that it becomes 'classesDirs'. I made the same mistake.



Hi, thank you I was having the same problem and this was the solution!
alexmetalrock
 
Posts: 1
Joined: Thu Jul 25, 2019 3:31 am

Re: Android Studio 3.4 and gradle-5.1.1

Postby amekassa » Sun Jul 28, 2019 2:27 pm

alexmetalrock wrote:
shatterblast wrote:
vijaydino wrote:
Here is error msg: when the build is failed


ERROR: Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

Add an 's' to the end of 'classesDir' so that it becomes 'classesDirs'. I made the same mistake.



Hi, thank you I was having the same problem and this was the solution!

I ' m using an updated version of the Android Studio that is Android Studio 3.4 and libgdx gradle is not working anymore, because the minimum version of gradle is now 5.1.1 There are several changes
amekassa
 
Posts: 2
Joined: Sun Jul 28, 2019 2:25 pm

Re: Android Studio 3.4 and gradle-5.1.1

Postby shatterblast » Sun Jul 28, 2019 7:43 pm

You differently setup Gradle in Android Studio for LibGDX. I believe the native version that naturally comes with Android Studio acts like 3.4, but it has modifications to allow Java 11 and 12. The following YouTube video explains the idea:
https://youtu.be/Xjywi7DTMgw

The versions for both Gradle and the Android Gradle Tool are different than what the video shows, since it dates from 2017.
shatterblast
 
Posts: 404
Joined: Sun Jul 06, 2014 1:14 pm


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest