2017-05-27 67 views
2

我剛剛下載了最新的Android Studio 3.0 Preview Canary 2。它已經用最新的gradle com.android.tools.build:gradle:3.0.0-alpha2更新了我的項目。現在我有很多編譯崩潰,如:Android:無效的資源文件

ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-xhdpi-v4\notification_bg_low_normal.9.png not a valid resource file 

ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-xhdpi-v4\notification_bg_low_normal.9.png not a valid resource file 

ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\design-25.3.1.aar\ab2edc05ef7bbad4b3861a867a381098\res\drawable-xxxhdpi-v4\design_ic_visibility.png not a valid resource file 

ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\design-25.3.1.aar\ab2edc05ef7bbad4b3861a867a381098\res\drawable-xxxhdpi-v4\design_ic_visibility.png not a valid resource file 

ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-mdpi-v4\abc_menu_hardkey_panel_mtrl_mult.9.png not a valid resource file 

ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-mdpi-v4\abc_menu_hardkey_panel_mtrl_mult.9.png not a valid resource file 

ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-xxxhdpi-v4\abc_spinner_mtrl_am_alpha.9.png not a valid resource file 

ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-xxxhdpi-v4\abc_spinner_mtrl_am_alpha.9.png not a valid resource file 


ERROR: C:\Users\??????\\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\a33e01f0d19405567201ecab1e032796\res\drawable-mdpi-v4\abc_btn_check_to_on_mtrl_000.png not a valid resource file 

FAILURE: Build failed with an exception. 

* What went wrong: Execution failed for task ':app:mergeDebugResources'. 
> Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed: aapt2 compile -o D:\AndroidProjects\GetPet\app\build\intermediates\res\merged\debug C:\Users\user\\.gradle\caches\transforms-1\files-1.1\design-25.3.1.aar\ab2edc05ef7bbad4b3861a867a381098\res\layout\design_navigation_item.xml Issues: 
    - ERROR: C:\Users\user\\.gradle\caches\transforms-1\files-1.1\design-25.3.1.aar\ab2edc05ef7bbad4b3861a867a381098\res\layout\design_navigation_item.xml not a valid resource file 

我試圖清理項目和gradle緩存,但沒用。

build.gradle

buildscript { 
    repositories { 
     jcenter() 
     maven { 
      url 'https://maven.google.com' 
     } 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:3.0.0-alpha2' 

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

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

而且app\build.gradle

apply plugin: 'com.android.application' 

android { 
    signingConfigs { 
     config { 
      keyAlias 'alias' 
      keyPassword 'pass' 
      storeFile file('release_keystor.jks') 
      storePassword 'pass' 
     } 
    } 
    compileSdkVersion 25 
    buildToolsVersion '25.0.2' 
    defaultConfig { 
     applicationId "com.org.app" 
     minSdkVersion 21 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
     signingConfig signingConfigs.config 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      signingConfig signingConfigs.config 
     } 
    } 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:design:25.3.1' 
    compile 'com.android.volley:volley:1.0.0' 
    compile 'com.android.support:cardview-v7:25.3.1' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.vk:androidsdk:1.6.5' 
} 
+0

歡迎您刪除'C:\ Users \ user \ .gradle \ caches',如果這是問題 –

+0

@ cricket_007,就像我以前寫的那樣,我之前嘗試過。結果是一樣的 – Dropper

+0

「新的Android插件需要Gradle版本4.0 - 里程碑-1或更高版本。」 https://developer.android.com/studio/preview/features/new-android-plugin-migration.html –

回答

2

試圖改變服務目錄路徑的東西沒有西里爾符號,如 「C:/ gradle這個」 在

Settings > Build, Execution, Deployment > Gradle

不要忘記使緩存無效。

+0

西里爾文符號在哪裏? –

+0

而不是路徑** C:\ Users \ ?????? \。gradle **中的問號。我遇到了同樣的問題,我的Windows用戶名是*俄語。我認爲作者也有俄文用戶名,因爲他使用了VK SDK。 – mkruglikov

+0

問號僅用於隱藏此人的姓名。我不認爲它是字面的 –