Q:

Animation in Cocos2d android not working

I have been trying to animate a sprite with different frames with no luck. Nothing happens.
I have 12 Images (loading1.png to loading12.png).
How can I animate it? This is my code
CCAnimation animation = CCAnimation.animation("frameanimation", 2.0f);
    for(int i = 0; i < 12; i++){
        animation.addFrame(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("gfx/loading/loading" + (i + 1) + ".png"));
    }
    CCAction action = CCAnimate.action(2.0f, animation, true);
    this.runAction(action);

A:

Use your images (loading1.png to loading12.png) to make a texture using TexturePacker, which will generate the texture file and a data(plist) file. Then follow the following steps:
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(plistFile);
CCSpriteBatchNode* batchNode = CCSpriteBatchNode::create(pngTextureFile);
this->addChild(batchNode);
 CCSprite* sprite = CCSprite::createWithSpriteFrameName("first_frame_name");
 CCArray* frames = new CCArray;
 frames->initWithCapacity(frameCount);
 for (int i = 1; i < frameCount; i++) {
        CCString* frameName = CCString::createWithFormat("1-%d.png",i);
        frames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName->getCString()));
    }

 CCAnimation* animation = new CCAnimation;
 bool isLoaded = animation->initWithSpriteFrames(frames);
 sprite->runAction(CCAnimate::create(animation));
 batchNode->addChild(sprite);

