2015-09-04 143 views
2

由于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用于额外信息 ,以防万一需要查看它。

回答

0

您是否验证了在Android项目中正确名称的appropiate文件夹中是否存在?

编辑:

你试过从Android工作室,而不是进口的版本中删除(删除),并加入他们吗?

+0

是的,我已经验证,它们都存在。 –

+0

你能描述一下怎么做,以避免潜在的误解? –

0

我在Eclipse中导入的项目中存在与现有资源相同的问题。在我的情况下,问题是,名为loading.png的资源实际上是.gif,在我修复了扩展后,编译器生成了正确的R.drawable.loading变量。

当Android Studio中导入项目它显示这个消息,但我并没有出现在子序列汇编

:app:mergeDebugResources 
AAPT out(251470765) : No Delegate set : lost message:Done 
AAPT err(251470765): libpng error: Not a PNG file