Digital2Slave / ncnn-android-yolov8-seg

a sample yolov8 object segment android project based on ncnn and opencv.
68 stars 8 forks source link

Could not find method ndkVersion() for arguments [24.0.821588] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension #11

Closed Selfpline6 closed 2 months ago

Selfpline6 commented 3 months ago

A problem occurred evaluating project ':app'.

Could not find method ndkVersion() for arguments [24.0.8215888] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

Selfpline6 commented 3 months ago

本项目运用的 jdk11 or jdk 17 or jdk 20?

Digital2Slave commented 2 months ago

本项目运用的 jdk11 or jdk 17 or jdk 20?

languageLevel="JDK_1_8" project-jdk-name="1.8"

Digital2Slave commented 2 months ago

Question: "Could not find method ndkVersion() for arguments [24.0.8215888] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension."

通义千问:This error message typically occurs when you're trying to specify the NDK version in your Android project's build.gradle file, but the syntax or configuration is incorrect, or the plugin version you're using doesn't support specifying the NDK version in that particular way.

Here's how you can resolve this issue:

  1. Check Your Gradle Plugin Version: The method to specify the NDK version can vary based on the version of the Android Gradle Plugin (AGP) you're using. If you're using AGP 3.0 or higher, you should use ndkVersion inside the android.defaultConfig block. However, if you're using an older version, the method might not be available or could be different.

  2. Correct Syntax for AGP 3.0+: If you're using a compatible version, ensure your build.gradle (Module: app) file has the correct syntax for specifying the NDK version. It should look something like this:

    android {
       compileSdkVersion XX
       buildToolsVersion "XX.X.X"
    
       defaultConfig {
           // Other configurations...
           ndkVersion "24.0.8215888"
       }
       // Other blocks...
    }

    Replace XX and XX.X.X with your actual SDK version and Build Tools version.

  3. Update Gradle Plugin: If your plugin version is too old and does not support direct NDK version specification, consider updating your Android Gradle Plugin to a newer version that supports it. You can do this by changing the classpath entry in your project-level build.gradle file:

    buildscript {
       repositories {
           google()
           jcenter()
       }
       dependencies {
           classpath 'com.android.tools.build:gradle:XX.Y.Z' // Update XX.Y.Z to the latest version
       }
    }

    Make sure to check the Android Gradle Plugin release notes for the latest version and compatibility information.

  4. Clean & Rebuild: After making changes, try cleaning and rebuilding your project. In Android Studio, you can do this by navigating to Build > Clean Project followed by Build > Rebuild Project.

If you've confirmed your setup aligns with these suggestions and are still encountering issues, it may be worth checking for any specific issues or workarounds mentioned in the Android Developer documentation or forums related to your exact plugin and NDK versions.

Selfpline6 commented 2 months ago

I replaced some of the configuration versions in the original project, which solved the problem