Application development and deployment on Mobile Ad Hoc Networks (MANET) is a major challenge in the widespread use of MANET. The increasing D2D communication in 5G networks has renewed interest in an effective middleware design for MANET where application developers face various challenges such as unstable connectivity, high error rate, mobility induced disruption and disconnection, and limited battery power. We find that unstructured overlay network provides a good abstraction to facilitate application development and deployment on MANET. In this paper, we present the design of a middleware that builds a Resource-Aware Overlay Network (RAON), which is an unstructured overlay network of nodes engaged in the application that employs a query–reply mechanism for resource discovery. RAON is enhanced with features such as proactive neighbor replacement, congestion-aware data download and cooperative caching. Simulation results show that these features are effective in reducing query delay, improving data availability, and balancing node power consumption with protocol performance. We also present the middleware software design that offers the API based on node and path abstractions to applications. The middleware implements a generic context framework for acquiring device and user context. We discuss the implementation of application-level multicast and credit-based file-sharing applications using the middleware API. The middleware is implemented in Java J2ME on Android, which is tested in an ad hoc network of Nexus 7 devices running OLSR.