一切都很好,直到我将安卓工作室更新为Canary 6,当我重建或清理或者投射任何项目时:
执行com.android.build.gradle.tasks.MergeResources $ FileGenerationWorkAction
时发生故障
这个错误引导我访问vectors.xml
[所有人都收到此错误]
我当前的应用级别 build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "example.project"
minSdkVersion 15
targetSdkVersion 25
versionCode 42
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//multiDexEnabled = true
}
buildTypes {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'//<-- can't update to new one
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.android.support:palette-v7:25.3.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
此外,当我尝试下载com.android.support
库时,IDE只搜索sdk并且什么都不做。
我的尝试:
清理并重建。
使缓存无效。
答案 0 :(得分:66)
添加多密度矢量图形的优点是使用矢量而不是位图来减小APK的大小,因为可以针对不同的屏幕密度调整相同文件的大小而不会损失图像质量。对于不支持矢量绘图的旧版Android,Vector Asset Studio可以在构建时将矢量绘图转换为每个屏幕密度的不同位图大小
classpath 'com.android.tools.build:gradle:3.0.0-alpha8
的build.gradle
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
答案 1 :(得分:10)
将vectorDrawables.useSupportLibrary = true
添加到build.gradle(Module)的defaultConfig为我工作。 :)
答案 2 :(得分:4)
我有同样的问题。有两种方法可以解决我的问题:
vectorDrawables.useSupportLibrary = true
在我的可绘制向量xml文件中,有@color
的链接:
<path
android:fillColor="@color/white"
...
我替换为
<path
android:fillColor="#fff"
...
问题就消失了。
答案 3 :(得分:2)
android studio canary 6存在很多问题,解决这个问题的最佳方法是改变你的gradle中的依赖关系中的类路径
classpath 'com.android.tools.build:gradle:2.3.3'
答案 4 :(得分:2)
只需在defaultConfig中添加vectorDrawables.useSupportLibrary = true,它对我来说很好用
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
答案 5 :(得分:0)
将此添加到build.gradle
defaultConfig
vectorDrawables.useSupportLibrary = true
。
这将解决您的问题。
答案 6 :(得分:0)
问题在于构建gradle 3.1.4。降级到3.1.3,您应该一切顺利
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}