记录链接方便自己查看

284 阅读1分钟

Kotlin协程相关 Kotlin中文社区

Kotlin官网 www.kotlincn.net/docs/refere…

Lottie - 轻松实现复杂的动画效果 juejin.cn/post/684490… lottiefiles.com/featured?pa…

Android与Python混合编程 cloud.tencent.com/developer/a…
blog.csdn.net/weixin_3955…

chaquopy官网 chaquo.com/chaquopy/do…

编译python so库 python setup.py build_ext --inplace

交叉编译python so库给安卓使用 www.jianshu.com/p/99a1d654c… CrystaX_NDK www.crystax.net/en/download python-for-android (p4a) python-for-android.readthedocs.io/en/latest/q… pybridge github.com/joaoventura…

交叉编译python so库步骤: -》1 定义py: -》1.1 bootstrap.py

cython: language_level=3

!/usr/bin/env python

encoding: utf-8

import json

def router(args): values = json.loads(args)

try:
    function = routes[values.get('function')]

    status = 'ok'
    res = function(values)
except KeyError:
    status = 'fail'
    res = None

return json.dumps({
    'status': status,
    'result': res,
})

def hello(ars): a = 10 print("11111111111111111", a) return a;

def greet(args): """Simple function that greets someone.""" return 'Hello %s' % args['name']

def add(args): """Simple function to add two numbers.""" return args['a'] + args['b']

def mul(args): """Simple function to multiply two numbers.""" return args['a'] * args['b']

routes = { 'greet': greet, 'add': add, 'mul': mul, }

-》1.2 setup.py:

cython: language_level=3

!/usr/bin/env python

encoding: utf-8

from distutils.core import setup from Cython.Build import cythonize

setup( ext_modules = cythonize("bootstrap.py") )

-》2 通过命令编译得到bootstrap.c文件 python3 setup.py build_ext --inplace

-》3 将bootstrap.c文件复制到安卓项目的jni目录

-》4 配置Android.mk LOCAL_PATH := $(call my-dir) CRYSTAX_PATH := /Users/kaiwang/Downloads/crystax-ndk-10.3.2

Build pybridge.so

include (CLEARVARS)LOCALMODULE:=bootstrapLOCALSRCFILES:=bootstrap.cLOCALLDLIBS:=llogLOCALSHAREDLIBRARIES:=python3.5minclude(CLEAR_VARS) LOCAL_MODULE := bootstrap LOCAL_SRC_FILES := bootstrap.c LOCAL_LDLIBS := -llog LOCAL_SHARED_LIBRARIES := python3.5m include (BUILD_SHARED_LIBRARY)

Include libpython3.5m.so

include (CLEARVARS)LOCALMODULE:=python3.5mLOCALSRCFILES:=(CLEAR_VARS) LOCAL_MODULE := python3.5m LOCAL_SRC_FILES := (CRYSTAX_PATH)/sources/python/3.5/libs/(TARGETARCHABI)/libpython3.5m.soLOCALEXPORTCFLAGS:=I(TARGET_ARCH_ABI)/libpython3.5m.so LOCAL_EXPORT_CFLAGS := -I (CRYSTAX_PATH)/sources/python/3.5/include/python/ include $(PREBUILT_SHARED_LIBRARY)

-》5 配置Application.mk

APP_PLATFORM := android-19
APP_ABI := armeabi armeabi-v7a x86

-》6 cmd cd /Users/kaiwang/Downloads/pybridgetestx/app/src/main/jni 然后直接 /Users/kaiwang/Downloads/crystax-ndk-10.3.2/ndk-build

生成的bootstrap.so放入libs下面的 python