由于Google最近宣布Android Studio是Android开发的官方IDE,因此我决定将工作环境从Eclipse IDE更改为Android Studio。Android Studio找不到现有资源
将项目导入到Android Studio后,我遇到了一个奇怪的错误。 错误表示它无法在一个R.drawable数组中找到两个现有的R.drawable,这些资源是两个png图片。
这里是阵列的语法:
flag = new int[] {R.drawable.thegodfather,R.drawable.thegeneral,R.drawable.kingofcomedy,
R.drawable.drstrangelove,R.drawable.thebiglebowski}
两个R.drawables导致该错误是thegodfather和kingofcomedy。
以下是错误消息: (1)
> Error:(101, 32) error: cannot find symbol variable thegodfather
> Error:(101, 78) error: cannot find symbol variable kingofcomedy
> Note: Some input files use or override a deprecated API.
> Note: Recompile with -Xlint:deprecation for details.
> Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> > Compilation failed; see the compiler error output for details.
(2)
/Users/rawandsultani/Documents/ANDROID/V1/v11/app/src/main/java/com/exple/top100/Top100Activity.java:101: error: cannot find symbol
flag = new int[] {R.drawable.thegodfather,R.drawable.thegeneral,R.drawable.kingofcomedy,
^
symbol: variable thegodfather
location: class drawable
/Users/rawandsultani/Documents/ANDROID/V1/v11/app/src/main/java/com/exple/top100/Top100Activity.java:101: error: cannot find symbol
flag = new int[] {R.drawable.thegodfather,R.drawable.thegeneral,R.drawable.kingofcomedy,
^
symbol: variable kingofcomedy
location: class drawable
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
后的cleansings,rebuildings,invertings无数的努力,并重新启动同样的错误依然存在。我已经检查过资源是否真的在那里,我已经删除并替换它只是为了确保。它仍然不起作用。
什么导致Android Studio忽略这两个资源?
这是我的Android清单文件的开头:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exple.v1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
这里是我的Gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.exple.v1"
minSdkVersion 11
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
}
同样,我不知道是什么原因造成了这个问题。在Stack上搜索之后,我发现有些人遇到了类似的问题,但是通过清理项目或重新启动Android Studio来解决这个问题。
清单文件和Gradle.build用于额外信息 ,以防万一需要查看它。
是的,我已经验证,它们都存在。 –
你能描述一下怎么做,以避免潜在的误解? –