热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

AndroidStudio0.9.0-无法解析符号-AndroidStudio0.9.0-Cannotresolvesymbols

After6hspenttryingtofixthisbymyself,ASisdrivingmecrazy.Everythingwasfineyesterdaya

After 6h spent trying to fix this by myself, AS is driving me crazy. Everything was fine yesterday and today it can't resolve any of the support libs nor the R symbols.

在我花了6个小时试图解决这个问题之后,我简直要疯了。昨天一切都很好,今天它不能解决任何支持的lib或R符号。

enter image description here

I tried everthing, including all the suggested fixes I found on StackOverflow. No need to tell me to have a look a this post, I already have and none of the solutions work.

我尝试了所有的东西,包括我在StackOverflow上找到的所有建议的补丁。没有必要告诉我去看一下这篇文章,我已经有了,没有一个解决方案是有效的。

Here's what I tried so far :

以下是我迄今为止所尝试的:

  • rebuilding / cleaning the project (many times...),
  • 重建/清理项目(很多次…)
  • synchronising the project with Gradle Files,
  • 将项目与渐变文件同步,
  • check that the support lib is up-to-date in the SDK Manager,
  • 检查支持库在SDK管理器中是最新的,
  • invalide Caches / restart AS,
  • 使缓存失效/重新启动,
  • delete the .idea folder and the .iml files of my project, and re-importing it in AS,
  • 删除我项目的。idea文件夹和。iml文件,重新导入为AS,
  • update AS from 0.8.11 to 0.9,
  • 从0.8.11更新到0.9,
  • eventually I ended up uninstalling AS and reinstalling it from scratch
  • 最终我卸载了AS并重新安装它

And none of this fixed my issue...

这些都没有解决我的问题……

Something really weird is that I also tried to create a whole new project from scratch and to copy/paste all my classes & resources from my corrupted project to this new one. And it worked for a while (~10 min), until it eventually became corrupted the same way, without any apparent reason.

非常奇怪的是,我还尝试从头创建一个全新的项目,并将我所有的类和资源从损坏的项目复制/粘贴到新的项目中。它工作了一段时间(大约10分钟),直到它最终以同样的方式被腐蚀,没有任何明显的原因。

Moreover, no idea if it's relevant, but when I type "ViewPager" in AndroidStudio and hit CTRL-SPACE, it doesn't suggest me the "android.support.v4.view.ViewPager" class. But if I hit CTRL-SPACE 3 times in a row, it DOES suggest it. So I guess that means that it's able to find the support lib somewhere but not to use it?

此外,不知道它是否相关,但是当我在AndroidStudio中输入“ViewPager”并按下CTRL-SPACE时,它并没有提示我“android.support.v4.view”。:viewpage”类。但是如果我连续三次按CTRL-SPACE,它就会提示我。所以我猜这意味着它可以在某个地方找到支持库但不能使用它?

Here's my build.gradle :

这是我的建立。gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "com.mathieumaree.library"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:support-v13:21.0.0'
}

Please, help me, otherwise I'm gonna break my computer soon.

拜托,帮帮我,不然我很快就会把电脑弄坏的。

Thanks in advance,

提前谢谢,

Mathieu

马修

EDIT 1 :

编辑1:

I forgot to mention that this occurs only in one of my projects. The others seem to be fine (at least for now).

我忘了说这只发生在我的一个项目中。其他人似乎都很好(至少目前如此)。

EDIT 2 :

编辑2:

I also forgot to mention that my project is composed of an application project plus a library module inside it. So here is the app's build.gradle :

我还忘了提到我的项目是由一个应用程序项目和一个库模块组成的。这是这个应用的构建。gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "com.mathieumaree.materialheaderviewpager"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':library')
    compile 'com.android.support:support-v13:21.0.0'
    compile 'com.android.support:appcompat-v7:21.0.0'
}

The app Manifest :

应用程序清单:




    

        
            
                

                
            
        
    


The library manifest :

库清单:



    

    


The main settings.gradle :

主要的设置。gradle:

include ':app', ':library'

And the main build.gradle :

和主要构建。gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.14.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

EDIT 3 :

编辑3:

After trying once more to delete all .idea folers & *.iml files and reloading my project, I noticed that AndroidStudio displayed an error at openning :

在再次尝试删除所有。idea folers & *之后。iml文件和重载我的项目,我注意到AndroidStudio在openning上显示了一个错误:

Accessing invalid virtual file: file://C:/Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21; original:582; found:-: Accessing invalid virtual file: file://C:/Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21; original:582; found:-

访问无效的虚拟文件:文件://C:/用户/Mathieu/AppData/本地/Android/ Android -studio1/sdk/源/Android -21;原:582;发现:-:访问无效的虚拟文件:文件://C:/用户/Mathieu/AppData/本地/Android/ Android/ Android/ Android/ Android/ Android/ Android/ Android -21;原:582;发现:-

I'm pretty sure it means it's looking for the SDK to yet another location (AppData/Local...android-21). What I don't understand is :

我很确定这意味着它正在寻找另一个位置的SDK (AppData/Local…android-21)。我不明白的是:

  • there's no SDK folder at this location
  • 这个位置没有SDK文件夹。
  • the SDK path indicated in the Project Structure is not this one
  • 项目结构中显示的SDK路径不是这个

Any idea what all this means?

你知道这一切意味着什么吗?

2 个解决方案

#1


3  

try addind this to buid.gradle

试试把这个加到buid.gradle上

compile 'com.android.support:support-v4:21.0.0

and change build tools version to 20.0.0

并将构建工具版本更改为20.0.0

Also create a whole new project and see if the same errors are still present in that project.

还要创建一个全新的项目,看看该项目中是否还存在相同的错误。

Try "Tools" -> "Android" -> "Sync Project with Gradle Files"

尝试“工具”->“Android”->“带等级文件的同步项目”

#2


0  

Well, still not a clue what caused this problem but it would look like I managed to get rid of it, although I had to create a new project from scratch. What I really don't understand is that I've already done this yesterday and it didn't work out.

仍然不知道是什么导致了这个问题,但是看起来我设法摆脱了它,尽管我必须从头开始创建一个新项目。我真正不明白的是,我昨天已经做了这件事,但没有成功。


推荐阅读
author-avatar
sannyi
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有