我的代码
这是我的身材。grad尔
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
flavorDimensions"mode"
defaultConfig {
applicationId "com.research.home"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
productFlavors{
sandbox{
applicationId "com.research.home"
resValue "string", "app_name", "Rumah Riset"
buildConfigField "string", "MERCHANT_BASE_URL", "\"My Url Server/\""
buildConfigField "string", "MERCHANT_CLIENT_KEY", "My client key kode"
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
configurations {
compile.exclude group: "junit", module: "junit"
}
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.20"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'org.testng:testng:6.9.6'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.karumi:dexter:6.2.1'
implementation 'com.google.firebase:firebase-core:18.0.0'
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation 'com.google.firebase:firebase-auth:20.0.1'
implementation 'com.google.firebase:firebase-storage:19.2.0'
implementation 'com.google.firebase:firebase-database:19.5.1'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.firebase:firebase-messaging:21.0.0'
//picasso
implementation 'com.squareup.picasso:picasso:2.5.2'
//circle image view library
implementation 'de.hdodenhof:circleimageview:3.1.0'
//glide library
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.google.android.exoplayer:exoplayer:2.10.8'
implementation 'com.google.android.exoplayer:exoplayer-core:2.10.8'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.10.8'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.10.8'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.10.8'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.10.8'
implementation 'com.firebaseui:firebase-ui-database:6.2.0'
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
//implementation 'com.github.naya-aastra:SkewPdfView:1.1'
implementation 'com.github.kk121:File-Loader:1.2'
//Neorophism
//implementation 'com.github.4inodev:Neomorphic-FrameLayout-Android:1.03'
//Tooltip
implementation 'com.github.florent37:viewtooltip:1.2.2'
//midtrans.com
// For using the Midtrans Sandbox
implementation 'com.midtrans:uikit:1.24.1-SANDBOX' // change the number to the latest version
// For using the Midtrans Production
// implementation 'com.midtrans:uikit:1.24.1' // change the number to the latest version
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
如何修复此错误代码
此错误代码
> Task :app:mergeSandboxDebugResources FAILED
AGPBI: {"kind":"error","text":"Duplicate resources","sources":[{"file":{"description":"string/app_name","path":"C:\\Users\\ASUS\\Downloads\\Documents\\android\\BuildTwo\\app\\src\\main\\res\\values\\strings.xml"}},{"file":{"description":"string/app_name","path":"C:\\Users\\ASUS\\Downloads\\Documents\\android\\BuildTwo\\app\\build\\generated\\res\\resValues\\sandbox\\debug\\values\\gradleResValues.xml"}}],"tool":"Resource and asset merger"}
Execution failed for task ':app:mergeSandboxDebugResources'.
> [string/app_name] C:\Users\ASUS\Downloads\Documents\android\BuildTwo\app\src\main\res\values\strings.xml [string/app_name] C:\Users\ASUS\Downloads\Documents\android\BuildTwo\app\build\generated\res\resValues\sandbox\debug\values\gradleResValues.xml:
Error: Duplicate resources
当我构建代码时,它会显示这样一个错误,
这是my string.xml
<resources>
<string name="app_name">Research Home</string>
<string name="already_have_account">Already Have Account ?</string>
<string name="sign_in">Sign In</string>
<string name="sign_up">Sign Up</string>
<string name="full_name">Full Name</string>
<string name="email">Email</string>
<string name="password">Password</string>
<string name="confirmation_password">Confirmation Password</string>
<string name="choose_your_class">Choose Your Class</string>
<string name="menu_home" translatable="false">Home</string>
<string name="menu_chat" translatable="false">Chat</string>
<string name="menu_profile" translatable="false">Profile</string>
<string name="menu_payment" translatable="false">Payment</string>
<string name="welcome_admin">Welcome, Admin</string>
<string name="no_file_selected">No File Selected</string>
<string name="pls_select_a_podcast">Please Select a Podcast</string>
<string name="select_podcast">Select Podcast</string>
<string name="upload">Upload</string>
<string name="select_video">Select Video</string>
<string name="please_select_a_video">Please Select a Video</string>
<string name="question">Question</string>
<string name="write_a_question" translatable="false">Write a Question</string>
<string name="answer">Answer</string>
<string name="answerAlpha" translatable="false">A</string>
<string name="writeanswer" translatable="false">Write a Answer</string>
<string name="answerBravo" translatable="false">B</string>
<string name="answerCharlie" translatable="false">C</string>
<string name="answerDelta" translatable="false">D</string>
<string name="upload_quiz">Upload Quiz</string>
<string name="edit_quiz">Edit Quiz</string>
<string name="classess">Class</string>
<string name="directss">Direct</string>
<string name="pay">Pay</string>
<string name="edit">Edit</string>
<string name="delete">Delete</string>
<string name="business_management" translatable="false">Business Management</string>
<string name="enterpreneur" translatable="false">Enterpreneur</string>
<string name="enrichment" translatable="false">Enrichment</string>
<string name="click_to_play">Click to Play</string>
<string-array name="Podcast_Path">
<item>Select Podcast List</item>
<item>Podcast1</item>
<item>Podcast2</item>
<item>Podcast3</item>
</string-array>
<string-array name="Podcast_Edit_Path">
<item>Podcast1</item>
<item>Podcast2</item>
<item>Podcast3</item>
</string-array>
<string-array name="Video_Path">
<item>Select Video Path</item>
<item>Business Management Basic</item>
<item>Business Management Middle Science</item>
<item>Business Managemen Middle Social Science</item>
<item>Business Management Advance Science</item>
<item>Business Management Advance Social Science</item>
<!-- Enterpreneur -->
<item>Enterpreneur Basic</item>
<item>Enterpreneur Middle Science</item>
<item>Enterpreneur Middle Social Science</item>
<item>Enterpreneur Advance Science</item>
<item>Enterpreneur Advance Social Science</item>
<!-- Enrichment -->
<item>Enrichment Basic</item>
<item>Enrichment Middle Science</item>
<item>Enrichment Middle Social Science</item>
<item>Enrichment Advance Science</item>
<item>Enrichment Advance Social Science</item>
</string-array>
<string-array name="Quiz_Path">
<item>Select Quiz Path</item>
<item>Business Management Quiz</item>
<item>Enterpreneur Quiz</item>
<item>Enrichment Quiz</item>
<item>Video Path 3</item>
</string-array>
<string-array name="Quiz_Path_Edit">
<item>Business Management Quiz</item>
<item>Enterpreneur Quiz</item>
<item>Enrichment Quiz</item>
<item>Video Path 3</item>
</string-array>
<string-array name="Quiz_Num">
<item>Select Quiz Number</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
</string-array>
<string-array name="Quiz_Theory">
<item>Select Quiz Theory</item>
<item>Quiz Theory 1</item>
<item>Quiz Theory 2</item>
<item>Quiz Theory 3</item>
<item>Quiz Theory 4</item>
<item>Quiz Theory 5</item>
<item>Quiz Theory 6</item>
</string-array>
<string-array name="Video_Theory">
<item>Select Video Theory</item>
<item>Theory 1</item>
<item>Theory 2</item>
<item>Theory 3</item>
<item>Theory 4</item>
<item>Theory 5</item>
<item>Theory 6</item>
<item>Theory 7</item>
<item>Theory 8</item>
<item>Theory 9</item>
<item>Theory 10</item>
<item>Theory 11</item>
<item>Theory 12</item>
</string-array>
<string-array name="Video_Edit_Path">
<item>Business Management Basic</item>
<item>Business Management Middle Science</item>
<item>Business Managemen Middle Social Science</item>
<item>Business Management Advance Science</item>
<item>Business Management Advance Social Science</item>
<!-- Enterpreneur -->
<item>Enterpreneur Basic</item>
<item>Enterpreneur Middle Science</item>
<item>Enterpreneur Middle Social Science</item>
<item>Enterpreneur Advance Science</item>
<item>Enterpreneur Advance Social Science</item>
<!-- Enrichment -->
<item>Enrichment Basic</item>
<item>Enrichment Middle Science</item>
<item>Enrichment Middle Social Science</item>
<item>Enrichment Advance Science</item>
<item>Enrichment Advance Social Science</item>
</string-array>
<string-array name="Video_Edit_Theory">
<item>Theory 1</item>
<item>Theory 2</item>
<item>Theory 3</item>
<item>Theory 4</item>
<item>Theory 5</item>
<item>Theory 6</item>
<item>Theory 7</item>
<item>Theory 8</item>
<item>Theory 9</item>
<item>Theory 10</item>
<item>Theory 11</item>
<item>Theory 12</item>
</string-array>
<string-array name="Ebook_Path">
<item>Select Ebook Path</item>
<item>Business Management Basic</item>
<item>Business Management Middle Science</item>
<item>Business Managemen Middle Social Science</item>
<item>Business Management Advance Science</item>
<item>Business Management Advance Social Science</item>
<!-- Enterpreneur -->
<item>Enterpreneur Basic</item>
<item>Enterpreneur Middle Science</item>
<item>Enterpreneur Middle Social Science</item>
<item>Enterpreneur Advance Science</item>
<item>Enterpreneur Advance Social Science</item>
<!-- Enrichment -->
<item>Enrichment Basic</item>
<item>Enrichment Middle Science</item>
<item>Enrichment Middle Social Science</item>
<item>Enrichment Advance Science</item>
<item>Enrichment Advance Social Science</item>
</string-array>
<string-array name="Ebook_Theory">
<item>Select Ebook Theory</item>
<item>Theory 1</item>
<item>Theory 2</item>
<item>Theory 3</item>
<item>Theory 4</item>
<item>Theory 5</item>
<item>Theory 6</item>
<item>Theory 7</item>
<item>Theory 8</item>
<item>Theory 9</item>
<item>Theory 10</item>
<item>Theory 11</item>
<item>Theory 12</item>
</string-array>
<string name="theory">Theory</string>
<string name="press_back_again">Press back again to Exit</string>
<string name="email_is_required">Email can\'t be empty</string>
<string name="password_is_required">Password can\'t be empty</string>
<string name="fname_is_required">Name can\'t be empty</string>
<string name="password_must_same">Confirm your password</string>
<string name="password_character">Password must have 8 character or more</string>
<string name="lang">English</string>
<string name="scores">Scores</string>
<string name="forgot_password">Forgot password?</string>
<string name="basicexplain">Recommended for Beginner (the Basics of Scientists ) </string>
<string name="middleexplain">Recommended for Middle ( the Middless of Scientists )</string>
<string name="advanceexplain">Recommended for Advance ( the Advances of Scientists )</string>
<string name="cancel">Cancel</string>
<string name="change">Change</string>
</resources>
这个错误立即指向我创建的字符串,但是字符串中没有错误或重复。
我尝试在build.gradle中更改app\u name和application id,但仍然显示重复的资源
请帮我修复这个代码
谢谢:)
2条答案
按热度按时间83qze16e1#
此文件中有错误
gradleResValues.xml
试试这个去顶吧project
>>>clean
以及rebuild
它导致这个错误的原因是,当你在布局中引用时,android认为以下内容是相同的。
krcsximq2#
是,存在名为app\u name的重复字符串资源:
要解决此问题,可以声明
app_name
在defaultconfig中为空: