In the tropics, the reduction in fallow periods in shifting rice cultivation and deforestation have led to soil degradation. How crop diversity is managed by farmers to adapt to this change remains poorly studied. Our study in Madagascar focuses on the management of 38 species in agroforestry, a practice that was gradually adopted by Betsimisaraka farmers to replace shifting rice cultivation. We describe how farmers perceived changes in the soil and how they adapted their farming practices to these changes, and analyze their knowledge of the interactions between the different plant species and the soil (soil-agrobiodiversity interactions) that underlie these adaptations. The farmers' perceptions of changes in the soil, their causes and consequences, were recorded in 19 individual interviews and three focus groups. Farmers' knowledge of soil-agrobiodiversity interactions was recorded in 84 individual surveys and one focus group. Farmers grouped soils in two main classes according to the topography and used four criteria to characterize them. The main change in the soil they observed was the decline in soil fertility due to deforestation. In response to these changes, farmers changed their crop species and management practices (e.g., spatial organization of crops, fertilization, species associations). These adaptations are based on shared knowledge of the soil requirements of crop species and their effect on fertility, despite the recent adoption of agroforestry. Our study highlights the dynamic and holistic dimension of farmers' knowledge of the soil and its interactions with different plant species.