vbansal-bb opened a new issue, #1913:
URL: https://github.com/apache/cordova-android/issues/1913

   # 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
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   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:
   
   <edit-config file="app/src/main/AndroidManifest.xml" 
target="/manifest/application/activity" mode="merge">
       <activity android:name="com.other.package.MainActivity"/>
   </edit-config>
   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
   <!-- What command or code is needed to reproduce the problem? -->
   
   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
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   macOS
   
   Android emulator and physical devices
   
   Issue is in lib/target.js — platform and device independent
   
   
   
   ### Version information
   <!--
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   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
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to