經過6小時試圖自己解決這個問題,AS令我瘋狂。昨天一切都很好,今天它不能解決任何支持庫和R符號。Android Studio 0.9.0 - 無法解析符號
我想寄託都在內的所有建議的修復我在計算器上找到。沒有必要告訴我看看this post,我已經有了,而且沒有任何解決方案可以工作。
這裏是我試過到目前爲止:
- 重建/清潔項目(很多次......),
- 同步與搖籃文件的項目,
- 檢查支持LIB達-to-日在SDK管理器中,
- invalide緩存/重新開始時,
- 刪除.idea文件夾,我的項目的.iml文件,並重新導入它在AS,
- 更新AS從0.8.11到0.9,
- 我最終結束了AS卸載並從頭
重新安裝它,這一切都不固定我的問題......
一些真正怪異的是,我也嘗試從頭開始創建一個全新的項目,並將我的已損壞項目中的所有類&複製/粘貼到這個新項目中。它有一段時間(〜10分鐘),直到它最終以同樣的方式被破壞,沒有任何明顯的原因。
此外,不知道它是否相關,但是當我在AndroidStudio中鍵入「ViewPager」並敲擊CTRL-SPACE時,它不會提示我「android.support.v4.view.ViewPager」類。但是如果我連續三次擊中CTRL-SPACE,它會提示它。所以我想這意味着它能夠在某處找到支持庫,但不能使用它?
這裏是我的build.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'
}
請幫助我,否則我會很快打破我的電腦。
由於提前,
馬修
編輯1:
我忘了提,這僅僅發生在我的項目之一。其他人似乎沒事(至少現在)。
編輯2:
我也忘了提,我的項目是由一個應用程序項目加上裏面庫模塊。因此,這裏是應用程序的build.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'
}
應用清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mathieumaree.materialheaderviewpager" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.mathieumaree.materialheaderviewpager.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
庫清單:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mathieumaree.library">
<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
</application>
</manifest>
主要settings.gradle
:
include ':app', ':library'
和主build.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()
}
}
編輯3:
試圖再次刪除所有.idea folers & * .iml文件並重新加載我的項目後,我注意到,在AndroidStudio顯示開通的錯誤:
訪問無效虛擬文件: 文件:// C:/用戶/馬修/應用程序數據/本地/ Android設備/機器人-studio1/SDK /來源/機器人-21; 原文:582;發現: - :訪問無效的虛擬文件: file:// C:/ Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21; 原文:582;發現: -
我很確定這意味着它正在尋找SDK到另一個位置(AppData/Local ... android-21)。我不明白的是:
- 有在此位置
- SDK的路徑沒有SDK文件夾中的項目結構表示這不就是一個
任何想法,這一切意味着什麼?
似乎你已經嘗試了所有明顯的事情。您的SDK文件夾位於何處? – stkent 2014-11-03 13:44:46
它曾經在我的C:/ Program Files/Android/AndroidStudio文件夾中。然後,這個問題出現了,我升級了AndroidStudio,並且必須將我的SDK移動到〜/ MyAndroidStudioFolder/SDK(我剛剛關注[這個官方博客文章])(http://tools.android.com/recent/androidstudio0814inbetachannel)) – MathieuMaree 2014-11-03 13:50:46
如果你點擊文件 - >項目結構,是你的SDK顯示的路徑是否正確? (我懷疑這是問題,但最好檢查。) – stkent 2014-11-03 13:56:41