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

荒凉一梦 提交于 2020-07-10 10:25:18

问题


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

#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

来源:https://stackoverflow.com/questions/62792660/exporting-cocos2d-android-application-as-aar-and-calling-its-activity-from-anoth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!