无法使用导入的库。 Android Studio。 Google云端点jar

时间:2014-03-23 16:58:41

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

背景

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

问题

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

import screen capture

当我添加&#34 ;;" Android Studio会删除我的导入行并设置错误: error message

  

仅允许从事件派发线程访问。   详细信息:当前线程:线程[JobScheduler FJ pool 3 / 4,6,main] 570719363   我们的调度线程:线程[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中       在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)       at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.getCurrentEditorWithProviderComposite(FileEditorManagerImpl.java:1258)       at 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)       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)       在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)       at com.intellij.codeInsight.daemon.impl.PassExecutorService $ ScheduledPass $ 1 $ 1.run(PassExecutorService.java:380)       在com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1153)       at 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)       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)       在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中的对象。 enter image description here

任何人都知道这看起来是jar,gradle还是Android工作室的问题?

1 个答案:

答案 0 :(得分:4)

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