feat: add automatic Android API Level detection via getprop - #3153
feat: add automatic Android API Level detection via getprop#3153MartheusX wants to merge 1 commit into
Conversation
|
I don't believe this is strictly required, Though it does not hurt to include this, but please verify the claim. |
|
So you are saying the lower API level 24 does not work on Termux, any errors? Could you also check the output of |
|
On Fairphone 4 LineageOS 23.2: On 08/06/2026 with Python 3.13: getprop ro.build.version.sdkpip install -U pydantic-coreOutput:Source: Benjamin_Loison/pydantic-core/issues/2 export ANDROID_API_LEVEL=$(getprop ro.build.version.sdk)seems to have solved the issue according to my notes. python3 -m pip debug --verboseOutput: |
|
@Benjamin-Loison |
|
I had struggle establishing my Fairphone 4 environment for tens of minutes, so if you are fine with it, the following continues the investigation with Virtual Machine Manager LineageOS 23.0 virtual machine Termux: Personal notes:getpropEnvironment setup:pip install pydantic-coreOutput:apt install -y rustcOutput:apt install -y rustupOutput:apt install -y rustOutput:time pip install --verbose pydantic-coreThis output may not be the right one. time pip install pydantic-coreOutput:So I reproduce the mentioned error. export ANDROID_API_LEVEL=16
pip install --verbose pydantic-coreOutput:getprop ro.build.version.sdkclang -dumpmachineOutput: |

Description
Currently,
maturinrequires theANDROID_API_LEVELenvironment variable to be explicitly set when building on-device in environments like Termux. If missing, the build fails even though the host system is a live Android instance where this information is readily available.This PR introduces a fallback mechanism:
ANDROID_API_LEVELand other clues (linker/CC) are missing, it attempts to querygetprop ro.build.version.sdk.Motivation
I encountered this issue while trying to install tools in Termux on my Redmi Note 8 Pro. Automating this step removes a manual barrier for many mobile developers.
Testing