cordova run android fails to launch apps with fully qualified activity names in AndroidManifest.xml

Open Beginner friendly
#1,913 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
android, javascript
Domain
mobile-dev

Research direction

Start in lib/target.js at the launch-name construction described in the issue, then reproduce with the provided cordova create, platform add android, manifest edit, and cordova run android commands. Done means apps launch successfully with both fully qualified activity names and existing relative activity names.

Written by the indexing model from the issue text.

Description

Bug Report

Problem

What is expected to happen?

cordova run android should install and launch the app successfully when the main activity in AndroidManifest.xml uses a fully qualified class name that is outside the app's package namespace (e.g., com.other.package.MainActivity instead of .MainActivity).

What does actually happen?

The app installs successfully but the launch fails with:

Error type 3
Error: Activity class {com.example.myapp/com.example.myapp.com.other.package.MainActivity} does not exist.

The activity name is incorrectly resolved because lib/target.js always uses the /. (relative) notation when constructing the launch intent component name:
const launchName = pkgName + '/.' + manifest.getActivity().getName();

For a fully qualified activity name like com.other.package.MainActivity, this produces com.example.myapp/.com.other.package.MainActivity, which Android resolves as com.example.myapp.com.other.package.MainActivity — a class that does not exist.

Information

This issue affects any Cordova plugin that overrides the main activity with a fully qualified class name via edit-config in plugin.xml. For example:

The resulting AndroidManifest.xml contains:

<activity android:name="com.other.package.MainActivity" ...>

The fix is straightforward — check if the activity name is already fully qualified and use / instead of /.:

const activityName = manifest.getActivity().getName();
const launchName = activityName.includes('.')
? pkgName + '/' + activityName
: pkgName + '/.' + activityName;

This preserves existing behavior for relative names (.MainActivity) while correctly handling fully qualified names.

Command or Code

cordova create myapp com.example.myapp MyApp
cd myapp
cordova platform add android

Add a plugin that overrides the activity with a fully qualified name, or manually

edit platforms/android/app/src/main/AndroidManifest.xml to set:

android:name="com.other.package.MainActivity"

cordova run android

Result: INSTALL SUCCESS followed by launch failure

Environment, Platform, Device

macOS

Android emulator and physical devices

Issue is in lib/target.js — platform and device independent

Version information

Cordova CLI: 13.0.0

cordova-android: 13.0.0, 14.0.1, 15.0.0 (all affected — same code at line 133 of lib/target.js)

Node.js: >= 20.7.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
Dominant language
JavaScript
Stars
3.8k
Forks
1.6k
Avg merge
10h 11m
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/cordova-android

All issues in apache/cordova-android

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.