question:
Could not find method compile() for arguments [com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
problem causes:
In Cordova projects, compile()
methods are deprecated in Cordova 9 and earlier. Starting with Cordova 9, there has been a switch to using the Gradle build system.
This error usually means that your Cordova project uses a deprecated compile
method to add dependencies. As of Gradle 7.0, compile
the method has been removed in favor of adding dependencies using the implementation
or method.api
Solution steps
To fix this, you can follow these steps:
-
platforms/android/
Open the file in the directory at the root of your Cordova projectbuild.gradle
. -
com.tencent.mm.opensdk:wechat-sdk-android-with-mta
Find the line containing the dependency in the file . It might look like this:compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
-
compile
Replace in that line withimplementation
orapi
:implementation 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
or:
api 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
-
Save the file and recompile your Cordova project.
Note that depending on your specific situation, you may need to modify multiple dependencies. Make sure all compile
dependencies added using the method have been replaced implementation
or api
.