'Why Android Studio can't run projects written with chaquopy?

My project is completely written under the rules of chquopy, but it does not run. what is my problem?

this is my MainActivity code:

package com.example.use_chaquopy;

import static com.chaquo.python.Python.getInstance;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.chaquo.python.PyObject;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        PyObject sys = getInstance().getModule("sys");
        sys.get("maxsize").toLong();
        sys.get("version").toString();
        sys.callAttr("is_finalizing").toBoolean();
    }
}

and this is build.gradle(:app) code:

plugins {
    id 'com.android.application'
    id 'com.chaquo.python'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.use_chaquopy"
        minSdk 21
        targetSdk 21
        versionCode 1
        versionName "1.0"

        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }

        sourceSets{
            main{
                python.srcDir "src/main/python"
            }
        }

        python {
            buildPython "C:/Users/Digital/New folder/yes.exe"
            pyc {
                src false
            }
        }

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'com.google.firebase:firebase-database:20.0.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

build.gradle(project_name):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.3"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id 'com.chaquo.python' version '11.0.0' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

setting.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        pluginManagement {
            repositories {
                maven { url "https://chaquo.com/maven" }
            }
        }
    }
}

rootProject.name = "use_Chaquopy"
include ':app'

and finaly my python script code (program uses exe version):

import sys
sys.maxsize
sys.version
sys.is_finalizing()

just like what chaquopy say

what's the problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source