python-3.xandroid-studiochaquopy

How to configure Python interpretor in android studio


I am trying to se python in android studio as a backend code for working on variables and producing answer. My MainActivity is in Java and a directory is created for python code. when I try to write code in python is tells that "no python interpreter configured for the module" I have added Chaquopy and Python Community Plugin. Also I want to know how can I send variables for my MainActivity to python and viceversa.

I am trying to add python in android studio. I have tried Chaquopy and also Python Community Plugin. I have tried to find answers on different places and guides too. But no Luck till now.

buildscript {
    repositories {
        google()
        jcenter()
        maven{url "https://chaquo.com/maven"}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "com.chaquo.python:gradle:0.5.0"
    }
}

this is MainActivity and I want to send my variable "a" to python file to work on it.

package com.example.testingpython;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    int a=2;
    String[] array={"My","Name","Java"};

}

}


Solution

  • when I try to write code in python is tells that "no python interpreter configured for the module"

    Only a few features of the Python Community Edition plugin will work properly in Android Studio. You can still write your Python code in Android Studio if you want, but most of the IDE assistance will be unavailable.

    Even if the code displays error indicators, you can still go ahead and run your app, and if any of the errors are real, the details will be displayed in the Logcat.

    how can I send variables for my MainActivity to python and viceversa.

    See the example code in the Chaquopy documentation and demo app.