android studio调用python_Android-Python混合开发 1 (java和python互相调用)

众所周知,python的语法简洁,并且拥有丰富强大的开源库,如果能把python移植到Android系统,能够用Android和python混合开发一款app, 那就太酷了。

要想移植python,得需要下载源码并且交叉编译才行。这个过程太复杂。在这里,介绍一款第三方,复杂的过程交给它处理,我们只需要处理逻辑相关的python代码即可。

Chaquopy

0x01 集成

1)打开项目根目录下的build.gradle文件

buildscript {

repositories {

google()

jcenter()

maven { url "https://chaquo.com/maven" }

}

dependencies {

classpath 'com.android.tools.build:gradle:3.2.1'

classpath "com.chaquo.python:gradle:6.3.0"

// NOTE: Do not place your application dependencies here; they belong

// in the individual module build.gradle files

}

}

2)打开module路径下的build.gradle文件

在顶部添加chaquo插件名称

apply plugin: 'com.android.application'

apply plugin: 'com.chaquo.python'

你可能感兴趣的:(android,studio调用python)