Kuldeep Bhimte
Kuldeep Bhimte

Reputation: 959

Exporting cocos2d Android application as aar and calling its Activity from another project

I had built a cocos2d Android project from cocos creator. (sample application)

And I exported this android application as an android library (sample.aar)

I created another Android application (MyDemo) and imported the android library (sample.aar)

I am calling the AppActivity of (sample.aar) library from the MainActivity of (MyDemo) application on Button click

aarButton.setOnClickListener(new View.OnClickListener() {
   public void onClick(View v) {
       Intent intent = new Intent();
       intent.setComponent(new ComponentName("org.cocos2d.demo", "org.cocos2dx.javascript.AppActivity"));
       startActivity(intent);
   }
});

The result is MyDemo app crashed.

Below is the error message I get in the console

android.content.ActivityNotFoundException: Unable to find explicit activity class {org.cocos2d.demo/org.cocos2dx.javascript.AppActivity}; have you declared this activity in your AndroidManifest.xml?

Below the screenshot of the error enter image description here

#But there is a trick

If I install the (sample) application on the phone first and then create an aar and import in the MyDemo application, then it works fine.

But I don't want to do like this.

I am stuck with this for couple of days.

Any help would be appreciated

Upvotes: 0

Views: 442

Answers (0)

Related Questions