如何在libGDX的androidstudio上安装Tween引擎?

如何在libGDX的androidstudio上安装Tween引擎?,libgdx,tween,Libgdx,Tween,我下载了两个jar文件,并将它们放在libs文件夹中 当我打开build.gradle项目(“:core”)时,我找不到应该将此代码放入其中的依赖项: compile fileTree(dir: '../libs', include: '*.jar') 它应该是这样的,但我在build中找不到它。gradle: project(":core") { ... dependencies { ... compile fileTree(dir: '../libs', include:

我下载了两个jar文件,并将它们放在libs文件夹中

当我打开build.gradle项目(“:core”)时,我找不到应该将此代码放入其中的依赖项:

compile fileTree(dir: '../libs', include: '*.jar')
它应该是这样的,但我在build中找不到它。gradle:

project(":core") {
...

dependencies {
    ...
    compile fileTree(dir: '../libs', include: '*.jar')
}
}
这是我在Gradle构建日志中得到的错误:

错误:(8,1)评估根项目“runningame”时出现问题

在org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler上找不到参数[directory'../libs']的方法compile()_Decorated@72594296.

我在这里找到了jar文件:

C:\Users\zfilfah\AndroidStudioProjects\game\core\build\libs
还创建了一个新文件夹,用于测试它是否可以工作:

C:\Users\zfilfah\AndroidStudioProjects\game\core\libs
我错过了什么?我还应该做些什么才能让Tween引擎在我的libGDX Android Studio上工作

Android gradle:

android {
    buildToolsVersion "23.0.2"
    compileSdkVersion 23
    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')
    }
    defaultConfig {
        applicationId "com.mygdx.game"
        minSdkVersion 8
        targetSdkVersion 23
    }
}


// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() { 
    file("libs/armeabi/").mkdirs();
    file("libs/armeabi-v7a/").mkdirs();
    file("libs/arm64-v8a/").mkdirs();
    file("libs/x86_64/").mkdirs();
    file("libs/x86/").mkdirs();

    configurations.natives.files.each { jar ->
        def outputDir = null
        if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")        
        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
        if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
        if(outputDir != null) {
            copy {
                from zipTree(jar)
                into outputDir
                include "*.so"
            }
        }
    }
}

task run(type: Exec) {
    def path
    def localProperties = project.file("../local.properties")
    if (localProperties.exists()) {
        Properties properties = new Properties()
        localProperties.withInputStream { instr ->
            properties.load(instr)
        }
        def sdkDir = properties.getProperty('sdk.dir')
        if (sdkDir) {
            path = sdkDir
        } else {
            path = "$System.env.ANDROID_HOME"
        }
    } else {
        path = "$System.env.ANDROID_HOME"
    }

    def adb = path + "/platform-tools/adb"
    commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game/com.mygdx.game.AndroidLauncher'
}

// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
    // need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
    // ignores any nodes added in classpath.file.withXml
    sourceSets {
        main {
            java.srcDirs "src", 'gen'
        }
    }

    jdt {
        sourceCompatibility = 1.6
        targetCompatibility = 1.6
    }

    classpath {
        plusConfigurations += [ project.configurations.compile ]        
        containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'       
    }

    project {
        name = appName + "-android"
        natures 'com.android.ide.eclipse.adt.AndroidNature'
        buildCommands.clear();
        buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
        buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
        buildCommand "org.eclipse.jdt.core.javabuilder"
        buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
    }
}

// sets up the Android Idea project, using the old Ant based build.
idea {
    module {
        sourceDirs += file("src");
        scopes = [ COMPILE: [plus:[project.configurations.compile]]]        

        iml {
            withXml {
                def node = it.asNode()
                def builder = NodeBuilder.newInstance();
                builder.current = node;
                builder.component(name: "FacetManager") {
                    facet(type: "android", name: "Android") {
                        configuration {
                            option(name: "UPDATE_PROPERTY_FILES", value:"true")
                        }
                    }
                }
            }
        }
    }
}
核心梯度:

apply plugin: "java"

sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

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


eclipse.project {
    name = appName + "-core"


}
以下是一个解决方案:

  • 将两个jar放入libs文件夹
  • 打开项目文件夹,找到
    build.gradle
    文件——这是一个根版本
  • 在“core”和“android”的依赖项部分下添加这一行
    compilefiletree(dir:'../libs',include:'*.jar')
    项目
  • 将这两个tween引擎jar添加到IDE中的模块依赖项中
  • 与gradle同步项目

  • 关于我的其他答案:

    编译文件树(dir:'libs',include:'*.jar')

    致:

    编译文件树(目录:'../libs/tween-engine-api-6.3.3 2',包括:'*.jar')


    成功了。(显然,您的文件名可能不同(例如,结尾处没有
    2

    您应该对root build.gradle进行更改,而不是特定于模块。我找不到依赖项部分。我在第一篇文章中添加了核心和安卓代码。请仔细阅读:2。打开项目文件夹,找到
    build.gradle
    文件——这是一个根版本。它不在android或core文件夹中,而是在项目的根目录中谢谢,现在我明白了。但我不确定Tween引擎是否工作。我无法在我的课堂上实现TweenAccessor。有错误吗?更改后是否成功同步项目?错误:任务“:core:compileJava”的执行失败。“>编译失败;有关详细信息,请参阅编译器错误输出。//当我重建项目时。