I tried to run my python file so I followed this instructions on the Interent. Here’s the link.
https://chaquo.com/chaquopy/doc/current/android.html#project-setup
I set my build.gradle file on project level
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url "https://chaquo.com/maven" }
}
}
plugins {
id 'com.android.application' version '8.2.2' apply false
}
dependencies {
classpath "com.android.tools.build:gradle:8.0.0"
classpath 'com.chaquo.python:gradle:15.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
and here’s my build.gradle file on app level.
plugins {
id 'com.android.application'
id("com.chaquo.python")
}
android {
namespace 'com.example.fouryou'
compileSdk 34
defaultConfig {
applicationId "com.example.fouryou"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abifilters "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
chaquopy {
defaultConfig {
buildPython("C:/Users/sally/AppData/Local/Programs/Python/Python311/python.exe")
buildPython("python.exe")
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'androidx.fragment:fragment:1.7.1'
implementation 'androidx.navigation:navigation-fragment:2.7.7'
implementation 'androidx.navigation:navigation-ui:2.7.7'
implementation 'com.android.volley:volley:1.2.1'
}
and my settings.gradle file is like
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("com.chaquo.python") version "15.0.1" apply false
}
rootProject.name = "FourYou"
include ':app'
I couldn’t understand what’s the problem with my code.
The Error code is
Could not find method classpath() for arguments [com.android.tools.build:gradle:8.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please help me to run the Python files on the Android Studio on Windows.
Thank you very much.
I really want to run the python files on my android app
isla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.