有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法使用导入的库。安卓工作室。谷歌云端点jar

背景

我已经创建了一个带有端点注释的基本python应用程序引擎应用程序。我使用python控制台工具导出java客户机库(jar)文件(Based on this example)。我使用了“add as library”并验证了gradle文件gradle

问题

我没有尝试将jar文件导入Android Studio 0.5.2。我遵循了示例中的说明,但似乎无法访问jar文件中的模型Based on this part of the example我应该能够导入我的库,并像其他任何类一样使用模型

import screen capture

当我加上“;”Android Studio删除我的导入行并设置错误: error message

Access is allowed from event dispatch thread only. Details: Current thread: Thread[JobScheduler FJ pool 3/4,6,main] 570719363 Our dispatch thread:Thread[AWT-EventQueue-0 0.5.2#AI-135.1078000, eap:true,6,main] 12400241 SystemEventQueueThread: Thread[AWT-EventQueue-0 0.5.2#AI-135.1078000, eap:true,6,main] 12400241 java.lang.Throwable at com.intellij.openapi.diagnostic.Logger.error(Logger.java:124) at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:1085) at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:1073) at com.intellij.openapi.wm.impl.FocusManagerImpl.assertDispatchThread(FocusManagerImpl.java:1159) at com.intellij.openapi.wm.impl.FocusManagerImpl.getFocusOwner(FocusManagerImpl.java:888) at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.getFocusOwner(IdeFocusManagerImpl.java:119) at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$2.run(FileEditorManagerImpl.java:202) at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.getActiveSplitters(FileEditorManagerImpl.java:230) at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.getSplitters(FileEditorManagerImpl.java:1180) at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.getCurrentEditorWithProviderComposite(FileEditorManagerImpl.java:1258) at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.getEditors(FileEditorManagerImpl.java:1230) at com.intellij.codeInsight.daemon.impl.DaemonListeners.canUndo(DaemonListeners.java:390) at com.intellij.codeInsight.daemon.impl.DaemonListeners.canChangeFileSilently(DaemonListeners.java:386) at com.intellij.codeInsight.intention.impl.config.QuickFixFactoryImpl.timeToOptimizeImports(QuickFixFactoryImpl.java:741) at com.intellij.codeInsight.intention.impl.config.QuickFixFactoryImpl.access$000(QuickFixFactoryImpl.java:70) at com.intellij.codeInsight.intention.impl.config.QuickFixFactoryImpl$1.isAvailable(QuickFixFactoryImpl.java:621) at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.addAvailableActionsForGroups(ShowIntentionsPass.java:129) at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.access$000(ShowIntentionsPass.java:69) at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass$1.process(ShowIntentionsPass.java:88) at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass$1.process(ShowIntentionsPass.java:85) at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl$6.process(DaemonCodeAnalyzerImpl.java:545) at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl$6.process(DaemonCodeAnalyzerImpl.java:539) at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx$1.process(DaemonCodeAnalyzerEx.java:59) at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx$1.process(DaemonCodeAnalyzerEx.java:53) at com.intellij.openapi.editor.impl.IntervalTreeImpl$IntervalNode.processAliveKeys(IntervalTreeImpl.java:97) at com.intellij.openapi.editor.impl.IntervalTreeImpl.processOverlappingWith(IntervalTreeImpl.java:468) at com.intellij.openapi.editor.impl.IntervalTreeImpl.processOverlappingWith(IntervalTreeImpl.java:463) at com.intellij.openapi.editor.impl.IntervalTreeImpl.processOverlappingWith(IntervalTreeImpl.java:476) at com.intellij.openapi.editor.impl.IntervalTreeImpl.processOverlappingWith(IntervalTreeImpl.java:476) at com.intellij.openapi.editor.impl.IntervalTreeImpl.processOverlappingWith(IntervalTreeImpl.java:463) at com.intellij.openapi.editor.impl.IntervalTreeImpl.processOverlappingWith(IntervalTreeImpl.java:463) at com.intellij.openapi.editor.impl.IntervalTreeImpl.processOverlappingWith(IntervalTreeImpl.java:463) at com.intellij.openapi.editor.impl.IntervalTreeImpl.processOverlappingWith(IntervalTreeImpl.java:440) at com.intellij.openapi.editor.impl.MarkupModelImpl.processRangeHighlightersOverlappingWith(MarkupModelImpl.java:264) at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx.processHighlights(DaemonCodeAnalyzerEx.java:53) at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl.processHighlightsNearOffset(DaemonCodeAnalyzerImpl.java:539) at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getAvailableActions(ShowIntentionsPass.java:85) at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:260) at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getIntentionActionsToShow(ShowIntentionsPass.java:212) at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.doCollectInformation(ShowIntentionsPass.java:186) at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:61) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:380) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1153) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:371) at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:368) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:344) at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask.exec(JobLauncherImpl.java:193) at jsr166e.ForkJoinTask.doExec(ForkJoinTask.java:260) at jsr166e.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:858) at jsr166e.ForkJoinPool.scan(ForkJoinPool.java:1687) at jsr166e.ForkJoinPool.runWorker(ForkJoinPool.java:1642) at jsr166e.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:109)

错误消息包含4个部分,看起来与上述内容非常相似

我到处都找遍了,似乎不知所措。使用这个库对我的项目至关重要,我已经花了10多个小时试图独自解决这个问题。非常感谢任何提示或指导

更新

@Scott的反馈已经解决了导入消失的问题,但我似乎仍然无法访问jar中的对象。 enter image description here

有人知道这是不是jar、gradle或Android studio的问题吗


共 (1) 个答案

  1. # 1 楼答案

    唯一的例外是Android Studio中的一个bug,实际上是一个骗局;这不是你问题的原因。你有偏好> 编辑> 自动导入> 动态优化导入已启用。当你输入import并按,它优化了导入,因为您还没有使用它。禁用首选项,或者不要手动键入import语句,在代码中使用对类的引用,并让编辑器帮助为您添加import