Android studio中 > Task :app:mergeDebugJavaResource FAILED FAILURE: Build completed with…
- User
Android studio中 > Task :app:mergeDebugJavaResource FAILED
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-
What went wrong: A problem was found with the configuration of task ':app:compileDebugJavaWithJavac' (type 'JavaCompile').
-
Gradle detected a problem with the following location: 'D:\workspace\android_scrcpy\app\src\main\assets\scrcpy-server.jar'.
Reason: Task ':app:compileDebugJavaWithJavac' uses this output of task ':server:copyDebug' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
- Declare task ':server:copyDebug' as an input of ':app:compileDebugJavaWithJavac'.
- Declare an explicit dependency on ':server:copyDebug' from ':app:compileDebugJavaWithJavac' using Task#dependsOn.
- Declare an explicit dependency on ':server:copyDebug' from ':app:compileDebugJavaWithJavac' using Task#mustRunAfter.
For more information, please refer to https://docs.gradle.org/8.4/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
-
-
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org. ==============================================================================
2: Task failed with an exception.
-
What went wrong: A problem was found with the configuration of task ':app:mergeDebugJavaResource' (type 'MergeJavaResourceTask').
-
Gradle detected a problem with the following location: 'D:\workspace\android_scrcpy\app\src\main\assets\scrcpy-server.jar'.
Reason: Task ':app:mergeDebugJavaResource' uses this output of task ':server:copyDebug' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
- Declare task ':server:copyDebug' as an input of ':app:mergeDebugJavaResource'.
- Declare an explicit dependency on ':server:copyDebug' from ':app:mergeDebugJavaResource' using Task#dependsOn.
- Declare an explicit dependency on ':server:copyDebug' from ':app:mergeDebugJavaResource' using Task#mustRunAfter.
-
-
- Assistant
It looks like you have an issue with Gradle task dependencies in your Android Studio project. Specifically, tasks in your
appmodule (like:app:compileDebugJavaWithJavacand:app:mergeDebugJavaResource) are using the output of the:server:copyDebugtask without declaring proper dependencies on it. To fix this, you need to explicitly declare the dependencies in your Gradle build scripts.Here's how you can address this issue:
-
Open your
app/build.gradlefile. -
Add task dependencies:
You should modify the build script to include the dependencies on the
:server:copyDebugtask. Here's an example of how you might do it:
-
- User
build.gradle.kts 中修改
- Assistant
If you're using Kotlin DSL (
build.gradle.kts) for your Gradle build scripts, the syntax is slightly different. You will need to use Kotlin syntax to achieve the same task dependency setup.Here's how you can update your
build.gradle.ktsto add the task dependencies:-
Open your
app/build.gradle.ktsfile. -
Add task dependencies:
You should modify the build script to include the dependencies on the
:server:copyDebugtask. Here's an example to guide you:android { // Your existing Android configuration } dependencies { // Your existing dependencies } tasks.named<JavaCompile>("compileDebugJavaWithJavac") { dependsOn(":server:copyDebug") } tasks.named("mergeDebugJavaResource") { dependsOn(":server:copyDebug") }
-
- User
plugins { alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsKotlinAndroid) }
android { namespace = "com.suda.androidscrcpy" compileSdk = 34
defaultConfig { applicationId = "com.suda.androidscrcpy" minSdk = 24 targetSdk = 28 versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } ndkVersion = "21.1.6352462" externalNativeBuild { cmake { abiFilters("armeabi-v7a", "arm64-v8a") } } } externalNativeBuild { cmake { path("${project.projectDir}/CMakeLists.txt") } } buildTypes { release { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } buildFeatures { compose = true viewBinding = true } composeOptions { kotlinCompilerExtensionVersion = "1.5.1" } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } lint { abortOnError=false } - Assistant
- User
Unresolved reference: compileDebugJavaWithJavac
- Assistant
- User
Unexpected tokens (use ';' to separate expressions on the same line)
- Assistant