apache / apache/cordova-android

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
Dominant language
JavaScript
Stars
3.8k
Forks
1.6k
Avg merge
16h 18m
Merged PRs (30d)
11

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:

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

- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.