我執行在Android教程這裏的步驟時:https://developer.android.com/training/basics/firstapp/running-app.html「複製資源」運行官方教程
當我這樣做的步驟(在模擬器上運行)「模擬器上運行」,我得到一個錯誤。
我已經雙重檢查了所有的步驟,但看不到有什麼問題。
任何人都可以幫忙嗎?
以下是編譯輸出:
Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
Error:Execution failed for task ':app:mergeDebugResources'.
> [string/app_name] C:\Users\eddyq\AndroidStudioProjects\MyApplication\app\src\main\res\values\strings.xml [string/app_name] C:\Users\eddyq\AndroidStudioProjects\MyApplication\app\src\main\res\values\styles.xml: Error: Duplicate resources
Information:BUILD FAILED
Information:Total time: 17.608 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
下面是該項目的build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// 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
}
下面是該應用的的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
}
這裏是styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My Application</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
</resources>
這裏的strings.xml:
<resources>
<string name="app_name">My Application</string>
</resources>
你可以發佈你的'build.gradle'? –
當然,但你可以編輯你自己的問題。添加你的代碼。 –