【问题标题】:Can't use imported library. Android Studio. Google cloud endpoints jar无法使用导入的库。安卓工作室。谷歌云端点 jar
【发布时间】:2014-04-30 21:34:20
【问题描述】:

背景

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

问题

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

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

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

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

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

更新

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

有人知道这看起来是 jar、gradle 还是 Android studio 的问题?

【问题讨论】:

    标签: java android python google-app-engine android-studio


    【解决方案1】:

    异常是Android Studio中的一个bug,实际上是一个红鲱鱼;这不是你的问题的原因。您已启用首选项 > 编辑器 > 自动导入 > 即时优化导入。当您键入 import 并按 ; 时,它会优化导入,因为您还没有使用它。要么禁用首选项,要么不要手动输入 import 语句 - 在代码中使用对类的引用,并让编辑器协助为您添加 import

    【讨论】:

    • 感谢您的快速反馈。即时关闭导入消除了我的错误,但我似乎仍然无法访问 jar 文件中的对象。我会更新我的原始帖子,希望您有任何其他反馈。
    • 我创建了一个单独的问题link,专注于我未回答的问题。这个答案解决了我的导入消失问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    • 2013-04-21
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    相关资源
    最近更新 更多