问题
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