Android的一室公寓内联编译器显示红色的错误,但编译与摇篮工作正常 [英] Android Studio inline compiler showing red errors, but compilation with gradle works fine

查看:401
本文介绍了Android的一室公寓内联编译器显示红色的错误,但编译与摇篮工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了我的项目在Android的工作室使用方眼库,按照这个问题

I've set up my project in Android Studio to use the Square Wire library, as per this question.

构建 - > 编制项目正常工作

Build -> Compile Project works fine.

2:03:10 PM Compilation completed successfully in 31 sec

不过,如果我打开我的生成协议缓冲文件之一,那么方包没有被认可。

However, if I open one of my generated Protocol Buffer files, then the Square package is not being recognized.

另一个症状是从广场继承的方法消息类都显示为无法解析法在编辑器中的编译错误,即使他们建立并运行良好。

Another symptom is that methods inherited from the Square Message class are showing as "Cannot resolve method" compile errors in the editor, even though they build and run fine.

我需要做一些事情不仅仅是增加在 build.gradle 的依赖我的模块中我的项目?

Do I need to do something more than just adding the dependency in build.gradle for my module in my project?

推荐答案

感谢free3dom是他们让我在正确的轨道在这里。

Thanks to free3dom for getting me on the right track here.

诊断

同步工程与摇篮文件在Android的工作室的选择似乎保持项目结构库是最新的。

The Sync Project with Gradle Files option in Android Studio seems to keep the Project Structure libraries up to date.

不过,在我的情况下,出现了一些误区:

However, in my case there were some errors:

扩大(不是很明显)链接显示的细节。我的线运行时库被显示在一个不正确的位置:

Expanding the (not very obvious) link showed the detail. My wire-runtime library was showing in an incorrect location:

这似乎是从我的,我已经导入的JAR到libs文件夹中的原始配置宿醉。

This seemed to be a hangover from my original configuration where I had imported the JAR into a libs folder.

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

我后来改成了直接从中央Maven的进口(<一href="http://stackoverflow.com/questions/20130471/best-way-to-add-dependency-for-wire-using-gradle-in-android-studio">as每此处),它似乎是旧的设置是从来没有覆盖新的。

I subsequently changed it to be imported directly from Maven Central (as per here), and it seems that the old setting was never overwritten with the new one.

的修订

解决方法是从项目结构屏幕中删除该库的依赖,然后同步工程与摇篮文件

The fix is to delete the library dependency from the Project Structure screen and then Sync Project with Gradle Files again.

更多详细信息

您还可以看到什么样的路径正在被打开用于资源.idea /库/ wire_runtime_1_2_0.xml 直接

You can also see what path is being used to the resource by opening the .idea/libraries/wire_runtime_1_2_0.xml directly.

我破碎的一个是:

  <component name="libraryTable">
  <library name="wire-runtime-1.2.0">
    <CLASSES>
      <root url="jar://$PROJECT_DIR$/MY_MODULE/libs/wire-runtime-1.2.0.jar!/" />
    </CLASSES>
    <JAVADOC />
    <SOURCES />

在删除并重新添加它改变了根网址图书馆:

After deleting and re-adding the library it changed the root url to:

      <root url="jar://$USER_HOME$/.gradle/caches/artifacts-26/filestore/com.squareup.wire/wire-runtime/1.2.0/jar/44e7acbd5eb6f29698181dc3d67a60acf7efee80/wire-runtime-1.2.0.jar!/" />

更新

Android的工作室v0.4.4 明显修复其他错误具有相同的症状,因此,如果你有一个旧版本不妨升级。

Android Studio v0.4.4 apparently fixes other bugs which have the same symptoms, so if you have an older version you may wish to upgrade.

这篇关于Android的一室公寓内联编译器显示红色的错误,但编译与摇篮工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆