chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
809 stars 131 forks source link

Build python error #399

Closed Manavjain25 closed 3 years ago

Manavjain25 commented 3 years ago

Hey , I am getting an error - No signature of method: build_2y9jex6zynqwuovvyp05096wt.android() is applicable for argument types: (build_2y9jex6zynqwuovvyp05096wt$_run_closure1) values: [build_2y9jex6zynqwuovvyp05096wt$_run_closure1@5a340d39] My code :-

 sourceSets{
            main{
                python{
                    srcDirs = ["src/main/python"]
                }
            }
        }

        python{
              buildPython "C:\\Users\\Python39\\python.exe"  // this is the location where I have my python.exe file
              buildPython "python3"
        }
        ndk{
            abiFilters "armeabi-v7a","x86"
        }

Pls help !

mhsmith commented 3 years ago

As shown in the documentation, the python and ndk blocks should be inside the defaultConfig block.

Unfortunately this kind of error message has become much less helpful in the newest version of Android Studio.

Manavjain25 commented 3 years ago

@mhsmith , Actually I didn't post the whole code . This is the whole code .

defaultConfig {
        applicationId "com.example.helloworld"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        sourceSets{
            main{
                python{
                    srcDirs = ["src/main/python"]
                }
            }
        }

        python{
              buildPython "C:\\Users\\Python39\\python.exe"
              buildPython "python3"
        }
        ndk{
            abiFilters "armeabi-v7a","x86"
        }

    }
mhsmith commented 3 years ago

As shown in the documentation, the sourceSets block should not be within defaultConfig.

But src/main/python is actually the default directory, so you don't need the sourceSets block at all. Just delete it.

If that still doesn't work, make sure you've applied the Chaquopy plugin correctly.

Manavjain25 commented 3 years ago

@mhsmith thanks a lot