Cordova 12 compilation failed Could not find method compile() for arguments [com....]

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.
insert image description here

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 compilemethod to add dependencies. As of Gradle 7.0, compilethe method has been removed in favor of adding dependencies using the implementationor method.api

Solution steps

To fix this, you can follow these steps:

  1. platforms/android/Open the file in the directory at the root of your Cordova project build.gradle.

  2. com.tencent.mm.opensdk:wechat-sdk-android-with-mtaFind the line containing the dependency in the file . It might look like this:

    compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
    
  3. compileReplace in that line with implementationor api:

    implementation 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
    

    or:

    api 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
    
  4. 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 compiledependencies added using the method have been replaced implementationor api.

Guess you like

Origin blog.csdn.net/ly_xiamu/article/details/132144574