![](/img/trans.png)
[英]Android Studio Project Build Output Error: Task :app:mergeDebugResources FAILED
[英]Android Studio fails building project in task mergeDebugResources
我正在嘗試將項目從Eclipse遷移到Android Studio。 創建完所有模塊(應用程序有幾個庫項目)后,Gradle始終失敗,並顯示以下錯誤:
Error:Execution failed for task ':AppLib:mergeDebugResources'.
> Unsupported type 'database' in file C:\Android\Code\AS_workspace\SuperApp\Infra\src\main\res\values\database.xml
此XML文件是在庫項目中定義的,並在app模塊中以相同的名稱覆蓋。
針頭說這在Eclipse上很久以來效果很好...
任何想法?
謝謝。
添加build.gradle文件:
這是應用程序文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.app.superapp"
minSdkVersion 10
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(':library1')
}
這是模塊:library1的文件,這是一個android庫:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 10
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library2')
}
這是模塊:library2的文件,該文件也是一個庫:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 10
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':AppLib')
}
現在是AppLib的庫:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 10
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':GooglePlayServices')
compile project(':facebook')
}
我有很多庫,但是一旦我完全理解Gradle的風格,就可以將它們簡化為兩個模塊。
AppLib中的Database.xml是:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="NAME" format="string" type="database"/>
<item name="TABLE_NAME" format="string" type="database"/>
<item name="DATABASE_VERSION" format="integer" type="database">101</item>
<item name="MIN_APPLICATION_DATABASE_VERSION" format="integer" type="database">10</item>
</resources>
SuperApp中的Database.xml僅添加字符串。
https://code.google.com/p/android/issues/detail?id=52962
以上處理傳遞庫的依賴關系。 對於名稱值的沖突,它的長度很長,並非完全符合您的意思,但是您可能需要檢查一下。
我會嘗試使用AS 0.8.14+中的項目導入對話框,它與庫之間的傳遞依賴關系相當好...不用擔心對“ build.gradles”及其詳細信息進行編碼。 而是讓導入器對其進行重整,然后,如果構建失敗,請返回上方問題鏈接的詳細信息,然后嘗試執行以下操作:
releaseCompile project(path: '..:$Path-to-Library1', configuration: 'release')
debugCompile project(path: '..:$Path-to-Library1', configuration: 'debug')
和您的“ Library2”相同
假設:您的eclipse.project.properties像下面這樣來指導AS導入器...
android.library.reference.1=../Library1
我認為您需要在應用程序build.gradle中指定使用更新的gradle版本。
例如:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.3'
}
}
較早的gradle版本更頻繁地給mergeDebugResources錯誤。
這顯然是因為android studio不適用於“自定義”類型,如我放置“數據庫”一樣。 將其設置為字符串和整數后,我開始工作。
不知道為什么在Eclipse中可以,但是AS抱怨。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.