The invention discloses a method and a system for generating a function calling code based on a calling stack and a dependent path, By monitoring the running of Android applications, the applied behavioral reflection runtime model is obtained, and the target object containing the target data is annotated in the runtime stack model of the behavioral reflection runtime model, All function call setsof the target object are generated, and each function call set is graded according to the difficulty of generating function call code using each function call set, and the function call set is recommended according to the graded function call set to generate function call code. The invention can generate a code corresponding to a function call, For each new object that is not constructed, the functions that are called before the object are quickly found out, and the functions that take the object as parameters and the function call stack are combined to form a plurality of functions, and on this basis, a scheme with high possibility of code generation is recommended, which effectively solves the problem of complex execution sequence in the development of Android application micro-services.