Human activity recognition using either wearable devices or smartphones can benefit various applications including healthcare, fitness, smart home, etc. Instead of using wearable devices which are intrusive and require extra cost, we shall leverage on modern smartphones embedded with a variety of sensors. Due to the flexibility of using smartphones, the recognition accuracy will degrade with orientation, placement, and subject variations. In this paper, we propose a robust human activity recognition system in terms of orientation, placement, and subject variations based on coordinate transformation and principal component analysis (CT-PCA) and online support vector machine (OSVM). The proposed CT-PCA scheme is utilized to eliminate the effect of orientation variations. Experiments show that the proposed scheme significantly improves the activity recognition accuracy and outperforms the state-of-the-art methods on leave one orientation out experiments, which demonstrates the generalization ability of the proposed scheme on the data from unseen orientations. We also show the effectiveness of this scheme on placement and subject variations. However, the inherent difference of signal properties for different placement and subject dramatically reduces the recognition accuracy, especially for different placement. Thus, we present an efficient OSVM algorithm, that is, online-independent support vector machine (OISVM), which utilizes a small portion of data from the unseen placement or subject to online update the parameters of the SVM algorithm. The experimental results demonstrate the effectiveness of this OISVM algorithm on placement and subject variations.