Я новичок в Android, после добавления зависимостей в файл gradle.build и последующей синхронизации проект успешно синхронизируется, и через несколько секунд я получаю сообщение об ошибке ниже:
[string/app_name] C:\Users\User_name\AndroidStudioProjects\Project_Name\app\src\main\res\values\strings.xml [string/app_name] C:\Users\User_name\AndroidStudioProjects\Project_Name\app\build\generated\res\resValues\devBackend\debug\values\generated.xml: Error: Duplicate resources
Что происходитявляется то, что ресурсы в файле strings.xml автоматически сгенерированы в каталог сборки, генерируемый файл .xml, я попытался переименовать файл и app_name, однако я получаю ту же ошибку.Как мне решить эту проблему?
Мой build.gradle (Project) выглядит так:
apply plugin: 'com.github.ben-manes.versions'
buildscript {
ext.kotlinVersion = '1.2.30'
ext.realmVersion = '4.3.4'
ext.gradlePluginVersion = '3.0.1'
ext.mockitoVersion = '2.15.0'
ext.powerMockVersion = '2.0.0-beta.5'
ext.supportLibVersion = '27.1.0'
ext.retrofitVersion = '2.3.0'
ext.okHttpVersion = '3.10.0'
ext.daggerVersion = '2.15'
ext.paperParcelVersion = '2.0.4'
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
//google()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://plugins.gradle.org/m2/" }
google()
}
dependencies {
// classpath "com.android.tools.build:gradle:$gradlePluginVersion"
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
// classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
classpath "io.realm:realm-gradle-plugin:$realmVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath "gradle.plugin.me.tatarka:gradle-retrolambda:3.7.0"
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
А файл build.graddle (module: app) выглядит так:
apply plugin: 'com.android.application'
//apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.jakewharton.hugo'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
flavorDimensions "default"
defaultConfig {
applicationId "com.patloew.countries"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
setProperty("archivesBaseName", "Countries-v$versionName-b$versionCode")
}
buildTypes {
debug {
debuggable true
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
shrinkResources true
proguardFiles 'proguard-rules.pro'
}
}
productFlavors {
devBackend {
applicationIdSuffix ".dev"
resValue "string", "app_name", "Countries Dev"
buildConfigField "String", "BASE_URL", "\"https://restcountries.eu/\""
}
productionBackend {
resValue "string", "app_name", "Countries"
buildConfigField "String", "BASE_URL", "\"https://restcountries.eu/\""
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
lintOptions {
abortOnError false
}
testOptions {
unitTests.returnDefaultValues = true
}
packagingOptions {
// Remove unneeded Realm native libs (nearly no devices use these)
exclude 'lib/mips/librealm-jni.so'
exclude 'lib/x86_64/librealm-jni.so'
}
}
ext.supportLibVersion = '25.3.1'
ext.retrofitVersion = '2.2.0'
ext.okHttpVersion = '3.6.0'
ext.daggerVersion = '2.10'
ext.parcelerVersion = '1.1.6'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:support-fragment:$supportLibVersion"
compile "com.android.support:support-core-ui:$supportLibVersion"
compile "com.android.support:appcompat-v7:$supportLibVersion"
compile "com.android.support:cardview-v7:$supportLibVersion"
compile "com.android.support:recyclerview-v7:$supportLibVersion"
compile "com.android.support:design:$supportLibVersion"
compile 'com.google.code.gson:gson:2.8.0'
compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
compile "com.squareup.okhttp3:okhttp:$okHttpVersion"
compile "com.squareup.okhttp3:logging-interceptor:$okHttpVersion"
compile 'com.simplecityapps:recyclerview-fastscroll:1.0.11'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile "org.parceler:parceler-api:$parcelerVersion"
annotationProcessor "org.parceler:parceler:$parcelerVersion"
annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
annotationProcessor "com.jakewharton:butterknife:7.0.1"
compile "com.google.dagger:dagger:$daggerVersion"
compile 'io.reactivex.rxjava2:rxjava:2.0.8'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile('com.mikepenz:aboutlibraries:5.8.1@aar') {
transitive = true
}
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile "org.powermock:powermock-module-junit4:1.6.5"
testCompile "org.powermock:powermock-module-junit4-rule:1.6.5"
testCompile "org.powermock:powermock-api-mockito:1.6.5"
testCompile 'io.reactivex:rxjava:1.2.9'
androidTestCompile "com.android.support:support-annotations:$supportLibVersion"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
androidTestCompile "com.squareup.okhttp3:okhttp:$okHttpVersion"
androidTestCompile 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'
}