2

So, I'm completely new to LibGDX, this is my first time creating a project. When I created it, then I set it to the regular stuff, got my SDK path and entered it, made the website be com.example.MY_COMPUTER_NAME.gametest. I generated the project, and went over to Android Studio (I made it so I'm only developing it for android BTW), imported the project from a file I made in an android file in a programming file in my desktop, and let it load. But, when synchronizing the Gradle, several errors popped up, and the ability to run the application is not working either. Here are the errors:

Error inside of android/build.gradle:

Warning:An 'android' block should only appear in build files that correspond to a module and have an 'apply plugin: 'com.android.application'' or 'apply plugin: 'com.android.library'' statement.

Here is the code of android/build.gradle that the error is directing me to:

android {
    buildToolsVersion "22.0.1"
    compileSdkVersion 22
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }

        instrumentTest.setRoot('tests')
    }
}

Also, at the top of that file, it gives a warning that says:

This folder does not belong to a Gradle project. Make sure it is registered in settings.gradle.

Here is the code for settings.gradle: include 'android', 'core'.

Next, there are two errors in the project's build.gradle, not the android's or core's gradle file. One is this:

Warning:(36, 4) A 'dependencies' block doesn't belong here.

That error, when selected to jump to source, leads to this code:

dependencies {
    compile project(":core")
    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
}

The other error for the project's build.gradle is:

Warning:(53, 4) A dependencies block doesn't belong here.

That code leads to this code when jumping to the source:

dependencies {
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}

Finally, there is this last error that leads to the project's, and not the android nor core's, local.properties file:

Error:(1, 8) Windows file separators () must be escaped (\); use C:/Users/MY_COMPUTER_NAME/AppData/Local/Android/android-sdk

Here is the code of the entire local.properties file:

# Location of the android SDK
sdk.dir=C:/Users/MY_COMPUTER_NAME/AppData/Local/Android/android-sdk

That last one doesn't make any sense to me since the recommended file path and set file path are the same. Anyway, I'm completely lost, and don't know any way to help the cause. Thanks in advance to anyone who may help me out, and please question me about any clarifications you may need. Thank you.

EDIT

There's also an error in the error log that says this:

Failed to set up Android modules in project 'LibGDXTest2': Unsupported method: BaseArtifact.getJavaCompileTaskName(). The version of Gradle you connect to does not support that method. To resolve the problem you can change/upgrade the target version of Gradle you connect to. Alternatively, you can ignore this exception and read other information from the model.

That's said to be an UnsupportedMethodException. BTW I'm using Android Studio version 0.8.6, and LibGDX version 1.6.4.

  • I don't understands what this means: "imported the project from a file I made in an android file in a programming file in my desktop". But after you create a project using the Libgdx Setup Utility, in Android Studio you need to go to Open Project (not Import Project!) and select the build.gradle file in the root directory of your project. – Tenfour04 Aug 01 '15 at 13:18
  • I mean, I have a programming folder in my desktop. I have an app dev folder in there, and the project in that folder. Anyway, I selected Open instead, and its still not working for the same reasons. – Shivashriganesh Mahato Aug 01 '15 at 18:15

1 Answers1

1

I hope I'm not wrong, but I'd say all your problems come mainly from the fact that you're using an obsolete version of Android Studio. Upgrade or use IntelliJ Idea, which is bascially the same thing. Also make sure your Android SDK is up to date.

And one more thing: did you try to "open" the project you already tried to "import"? I'd expect it to be broken now. Generate a new one and open that instead (in the upgraded studio!).

EDIT: And always run studio as admin.

NoHarmDan
  • 492
  • 5
  • 16
  • I just noticed how out of date my Android Studio was, so I went to http://tools.android.com/download/studio/canary/latest and downloaded the latest Android Studio (Canary 1.3). Upon download, the wizard asked me if I wanted to do this: http://stackoverflow.com/questions/24458923/from-where-do-i-import-settings-from-previous-version-of-android-studio I use that question for reference since I wanted to do it but didn't know how. Anyway, I used Gabriele Mariotti's answer, and it was working out fine. Then, some time after that, the wizard said that the SDK didn't download properly. – Shivashriganesh Mahato Aug 01 '15 at 19:24
  • Upon opening Android Studio, an error came up once again that says: – Shivashriganesh Mahato Aug 01 '15 at 19:27
  • Error:(16, 0) Gradle DSL method not found: 'runProguard()' Possible causes: – Shivashriganesh Mahato Aug 01 '15 at 19:28
  • Yes, if I remember well, ProGuard is deprecated now - just delete all mentions of it in project gradle files and you should be good. Also make sure the project target SDK used in libgdx creation app is the same that your Android Studio uses. (The new version might have its own, I'm not very sure about this though..) – NoHarmDan Aug 01 '15 at 19:35
  • I can't find `ProGaurd` anywhere, actually, in the files of the folders that are marked red (I'm guessing since they have some error in them), nor can I find it in any other gradle files. So, I closed Android Studio and reopened it. The setup wizard is trying to download the SDK components again, and the same error is occurring as the last time it tried downloading the components. Here is what it says: `The following SDK components were not installed: extra-android-m2repository and tools`. I'm not sure how to install those components. – Shivashriganesh Mahato Aug 01 '15 at 19:54
  • http://stackoverflow.com/questions/27376465/android-studio-doesnt-start-fails-saying-components-not-installed ? – NoHarmDan Aug 01 '15 at 20:21
  • It works! Awesome! Thanks so much for helping me out! – Shivashriganesh Mahato Aug 01 '15 at 21:34
  • Glad to hear that. :) – NoHarmDan Aug 01 '15 at 22:35