gpt4 book ai didi

java - LibGdx 在 Android Studio 中有多个错误

转载 作者:行者123 更新时间:2023-11-29 23:44:50 29 4
gpt4 key购买 nike

一个多星期以来,我一直在尝试通过关注 this tutorial 来使用 Android Studio 学习 LibGDX。 .我永远无法为桌面配置构建和运行。我在互联网上浏览了很多解决方案,但没有找到任何解决方案。下面我将展示有关我的项目和文件的所有详细信息。

很抱歉解释得太长,但我必须显示所有错误和细节以便更好地分析。

我对所有相关内容的版本是:

  1. Android Studio 版本:3.1.3
  2. SDK 工具:26.1.1
  3. Android 平台版本:API 28 修订版 4
  4. 等级:4.6
  5. 安卓插件版本:3.1.0
  6. Java:Java 8 更新 171

这是我在 libgdx 项目设置中选择的设置: LibGdx Project Setup

这是高级选项(仅选择 Eclipse):Advance option

我遇到了两个警告对话框,第一个是:

You have a more recent version of android build tools than the recommended.
Do you want to use your more recent version?

我选择了 NO,然后它告诉我:

Using build tools: 27.0.3

第二个说:

You have a more recent Android API than the recommended.
Do you want to use your more recent version?

我再次选择否,然后它说:

Using API level: 27

成功完成设置后,消息说:

Generating app in C:\AndroidStudioWorkspace\FlappyDemo
Executing 'C:\AndroidStudioWorkspace\FlappyDemo/gradlew.bat clean --no-daemon eclipse afterEclipseImport'
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/4.6/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018
:android:clean UP-TO-DATE
:core:clean UP-TO-DATE
:desktop:clean UP-TO-DATE
:eclipseProject
:eclipse
:android:eclipseClasspath
:android:eclipseJdt
:android:eclipseProject
:android:eclipse
:core:eclipseClasspath
:core:eclipseJdt
:core:eclipseProject
:core:eclipse
:desktop:eclipseClasspath
:desktop:eclipseJdt
:desktop:eclipseProject
:desktop:eclipse
:desktop:afterEclipseImport

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 14s
15 actionable tasks: 12 executed, 3 up-to-date
Done!
To import in Eclipse: File -> Import -> General -> Existing Projects into Workspace
To import to Intellij IDEA: File -> Open -> YourProject.ipr

我启动了 Android Studio 并导入了我使用 LibGdx 项目设置创建的这个项目。

在 Android Studio 中打开项目时我得到的第一个错误是:

Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018

我的主要 build.gradle 文件是这样的:

buildscript {


repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'


}
}

allprojects {
apply plugin: "eclipse"
apply plugin: "idea"

version = '1.0'
ext {
appName = "FlappyDemo"
gdxVersion = '1.9.8'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}

repositories {
mavenLocal()
mavenCentral()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}

project(":desktop") {
apply plugin: "java"


dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"

}
}

project(":android") {
apply plugin: "android"

configurations { natives }

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-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
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-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"

}
}

project(":core") {
apply plugin: "java"


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

}
}

tasks.eclipse.doLast {
delete ".project"
}

我的 gradle-wrapper.properties 是这样的:

#Fri Jun 09 23:06:52 EDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip

我的 gradle.properties 是:

org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx1500m
org.gradle.configureondemand=false

所以我将所有编译更改为实现,我的文件变为:

buildscript {


repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'


}
}

allprojects {
apply plugin: "eclipse"
apply plugin: "idea"

version = '1.0'
ext {
appName = "FlappyDemo"
gdxVersion = '1.9.8'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}

repositories {
mavenLocal()
mavenCentral()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}

project(":desktop") {
apply plugin: "java"


dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"

}
}

project(":android") {
apply plugin: "android"

configurations { natives }

dependencies {
implementation project(":core")
implementation "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-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "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-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"

}
}

project(":core") {
apply plugin: "java"


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

}
}

tasks.eclipse.doLast {
delete ".project"
}

此外,当我在更新文件后进行同步时,我看到了这条消息:

To take advantage of all the latest features (such as Instant Run), improvements and
security fixes, we strongly recommend that you update the Android Gradle plugin to
version 3.1.3 and Gradle to version 4.4.

You can learn more about this version of the plugin from the release notes.

我选择了“明天提醒我”。同步成功!我通过在我的 android 手机上运行它来测试它,一切都很好,除了 1 个警告:

warning: [options] bootstrap class path not set in conjunction with -source 1.6

我还看到了一个 IDE 错误:

Editor of class com.intellij.openapi.editor.impl.EditorImpl hasn't been released:
com.intellij.openapi.util.TraceableDisposable.ObjectNotDisposedException: See stack trace responsible for creation of unreleased object below
at com.intellij.openapi.editor.impl.EditorImpl.<init>(EditorImpl.java:146)
at com.intellij.openapi.editor.impl.EditorFactoryImpl.createEditor(EditorFactoryImpl.java:220)
at com.intellij.openapi.editor.impl.EditorFactoryImpl.createViewer(EditorFactoryImpl.java:190)
at com.intellij.execution.impl.ConsoleViewUtil.setupConsoleEditor(ConsoleViewUtil.java:68)
at com.intellij.execution.impl.ConsoleViewImpl.doCreateConsoleEditor(ConsoleViewImpl.java:903)
at com.intellij.execution.impl.ConsoleViewImpl.lambda$createConsoleEditor$10(ConsoleViewImpl.java:880)
at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:47)
at com.intellij.execution.impl.ConsoleViewImpl.createConsoleEditor(ConsoleViewImpl.java:879)
at com.intellij.execution.impl.ConsoleViewImpl.initConsoleEditor(ConsoleViewImpl.java:452)
at com.intellij.execution.impl.ConsoleViewImpl.getComponent(ConsoleViewImpl.java:431)
at com.intellij.build.BuildTreeConsoleView$DetailsHandler.<init>(BuildTreeConsoleView.java:634)
at com.intellij.build.BuildTreeConsoleView.<init>(BuildTreeConsoleView.java:222)
at com.intellij.build.BuildView.onStartBuild(BuildView.java:128)
at com.intellij.build.BuildView.lambda$onEvent$0(BuildView.java:87)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:653)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:666)
at com.intellij.build.BuildView.onEvent(BuildView.java:86)
at com.intellij.build.MultipleBuildsView.lambda$onEvent$2(MultipleBuildsView.java:163)
at com.intellij.build.MultipleBuildsView.lambda$onEvent$3(MultipleBuildsView.java:288)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:822)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:650)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366)
at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:924)
at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:217)
at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:203)
at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:589)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:409)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:117)
at com.intellij.openapi.progress.impl.CoreProgressManager.runSynchronously(CoreProgressManager.java:318)
at com.intellij.openapi.progress.impl.CoreProgressManager.run(CoreProgressManager.java:303)
at com.intellij.openapi.progress.Task.queue(Task.java:115)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.refreshProject(ExternalSystemUtil.java:621)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.refreshProject(ExternalSystemUtil.java:381)
at com.android.tools.idea.gradle.project.sync.idea.IdeaGradleSync.sync(IdeaGradleSync.java:169)
at com.android.tools.idea.gradle.project.sync.GradleSyncInvoker.sync(GradleSyncInvoker.java:241)
at com.android.tools.idea.gradle.project.sync.GradleSyncInvoker.lambda$requestProjectSync$0(GradleSyncInvoker.java:128)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:153)
at com.android.tools.idea.gradle.project.sync.GradleSyncInvoker.requestProjectSync(GradleSyncInvoker.java:145)
at com.android.tools.idea.gradle.project.importing.GradleProjectImporter.openOrImportProject(GradleProjectImporter.java:210)
at com.android.tools.idea.gradle.project.importing.GradleProjectImporter.openOrImportProject(GradleProjectImporter.java:110)
at com.android.tools.idea.gradle.project.importing.GradleProjectImporter.importProject(GradleProjectImporter.java:96)
at com.android.tools.idea.actions.AndroidImportProjectAction.createImportWizard(AndroidImportProjectAction.java:201)
at com.android.tools.idea.actions.AndroidImportProjectAction.selectFileAndCreateWizard(AndroidImportProjectAction.java:163)
at com.android.tools.idea.actions.AndroidImportProjectAction.selectFileAndCreateWizard(AndroidImportProjectAction.java:143)
at com.android.tools.idea.actions.AndroidImportProjectAction.actionPerformed(AndroidImportProjectAction.java:102)
at com.intellij.ui.components.labels.ActionLink$1.linkSelected(ActionLink.java:66)
at com.intellij.ui.components.labels.LinkLabel.doClick(LinkLabel.java:156)
at com.intellij.ui.components.labels.ActionLink.doClick(ActionLink.java:79)
at com.intellij.ui.components.labels.LinkLabel$MyMouseHandler.mouseReleased(LinkLabel.java:338)
at java.awt.Component.processMouseEvent(Component.java:6541)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6306)
at java.awt.Container.processEvent(Container.java:2237)
at java.awt.Component.dispatchEventImpl(Component.java:4897)
at java.awt.Container.dispatchEventImpl(Container.java:2295)
at java.awt.Component.dispatchEvent(Component.java:4719)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
at java.awt.Container.dispatchEventImpl(Container.java:2281)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4719)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.awt.EventQueue$4.run(EventQueue.java:735)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:822)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:646)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

我从同一个教程配置桌面运行,图片如下:Desktop Configuration

完成此操作后,我在选择桌面的情况下运行程序,并收到此错误:

Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.6-bin.zip'.

这是我卡住的地方,在 Android 手机上运行时一切正常,但是当选择桌面时,这是我得到的错误。现在我遵循了互联网上的许多解决方案,但每个解决方案都进一步给出了其他错误,每个解决方案给出了不同的错误,所以我不能把所有的分支都放在这里。

此时我非常需要帮助,谢谢。

最佳答案

希望您使用的是 latest buildgdx-setup.jar .

按需禁用配置

  • 在您的 gradle.properties 文件中按需禁用配置,如下所示:

    org.gradle.configureondemand=false

  • 要在 Android Studio 设置中禁用按需配置,请选择文件 > 设置(Mac 上为 Android Studio > 首选项),选择编译器类别左 Pane ,然后清除按需配置复选框。


我目前正在为 LibGDX 使用以下版本组合,建议您更新其中的一些。

  1. buildToolsVersion "27.0.3"
  2. Android Gradle 插件版本:3.1.3
  3. Gradle 4.6
  4. Android API 28
  5. Android Studio 3.1.3

编辑

您还可以使用gradle 任务运行您的桌面模块

  1. 使用终端

    • 使用 View => 工具窗口选择终端 => Android Studio 中的终端
    • 在终端 (Windows) 上使用 gradlew desktop:run
  2. 使用运行/调试配置

    enter image description here

    • 添加新配置
    • 选择 Gradle
    • Gradle 项目 => 选择项目的 :desktop 模块
    • 任务: => 输入run
    • 确定应用
    • 选择你的配置并运行

关于java - LibGdx 在 Android Studio 中有多个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51517904/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com