Fixed
Status Update
Comments
rm...@google.com <rm...@google.com> #2
Thank you for your feedback. Team may reach out for more feedback in reproducing or triaging this issue.
ar...@google.com <ar...@google.com>
em...@google.com <em...@google.com> #3
Thanks for reporting this bug.
Has this ever worked before for you in an earlier version of Android Studio?
First, I verified that the code that populates the "Attach to Android process" and the code that finds the module that corresponds to the selected process has a discrepancy. The former respects "android:process" overrides from the manifest file, yet the latter does not. Therefore, it cannot find the module selected from the list and produces the exception in comment#1 .
Second, the problem is not just related to late-attach. I noticed that deploy+debug does not work with "android:process" override either. This is because the "adb shell run-as" command issued by Android Studio to start LLDB server on the device uses the "android:process" overridden name, whereas it is supposed to be the name of the actual package, as can be seen here:
bash$ adb shell run-as com.example.processname ls
=> run-as: Package 'com.example.differentprocess' is unknown
bash$ adb shell run-as com.example.packagename ls
=> Works
Repro Instructions:
1. Edit AndroidManifest.xml file and add android:process as follows:
<activity android:name=".MainActivity" android:process="com.example.differentprocess">
...
</activity>
2. Deploy and debug the native part of the app.
Expected: Can debug.
Actual: AS gets stuck at LLDB server start step "run-as com.example.processname"
3. Run the app using the run button.
4. Debug using "Run > Attach Debugger to Android Process"
5. Select the "com.example.processname" from the list.
Expected: Can debug
Actual: AS throws the exception in comment#1 .
Has this ever worked before for you in an earlier version of Android Studio?
First, I verified that the code that populates the "Attach to Android process" and the code that finds the module that corresponds to the selected process has a discrepancy. The former respects "android:process" overrides from the manifest file, yet the latter does not. Therefore, it cannot find the module selected from the list and produces the exception in
Second, the problem is not just related to late-attach. I noticed that deploy+debug does not work with "android:process" override either. This is because the "adb shell run-as" command issued by Android Studio to start LLDB server on the device uses the "android:process" overridden name, whereas it is supposed to be the name of the actual package, as can be seen here:
bash$ adb shell run-as com.example.processname ls
=> run-as: Package 'com.example.differentprocess' is unknown
bash$ adb shell run-as com.example.packagename ls
=> Works
Repro Instructions:
1. Edit AndroidManifest.xml file and add android:process as follows:
<activity android:name=".MainActivity" android:process="com.example.differentprocess">
...
</activity>
2. Deploy and debug the native part of the app.
Expected: Can debug.
Actual: AS gets stuck at LLDB server start step "run-as com.example.processname"
3. Run the app using the run button.
4. Debug using "Run > Attach Debugger to Android Process"
5. Select the "com.example.processname" from the list.
Expected: Can debug
Actual: AS throws the exception in
em...@google.com <em...@google.com> #4
My example in
I modified my repro case to be:
<activity android:name=".MainActivity" android:process=":differentprocess">
in which case, run-as works fine.
+++
What kind of android:process statement do you use?
rc...@gmail.com <rc...@gmail.com> #5
I'm attaching my AndroidManifest.xml for you. This is the manifest of the APK I tried to debug. If I debug the activity process, it works great. But if I want to attach to one of the services it has in it after launching the application, it gives me the exception above. In this case, I was trying to attach to `com.ttm.SyncService`, which is the process name, different from the package.
em...@google.com <em...@google.com> #6
In the manifest, the package name is "com.tm.v2.sync", but the service android:process names are like "com.ttm.SyncService". This creates global processes, which Android Studio cannot attach to (I don't think this has ever worked). I assume you use these names because you want different applications to share these services, right?
rc...@gmail.com <rc...@gmail.com> #7
Yes that is right, but we also want them to run independently of the main activity (e.g. if the service crashes, it won't bring down the activity process). What naming convention should I be following? And what rules determine if a process is "global" or not? I am unfamiliar with what you are talking about. I'm willing to make some changes to my manifest if it fixes this. I'm not sure if we're doing something improperly or in an invalid way.
em...@google.com <em...@google.com> #8
This explanation might help:
https://developer.android.com/guide/topics/manifest/service-element#proc
If you need multiple applications to share these services, then I believe what you are doing is the right approach.
If you don't need cross-app sharing, but just want to split them into multiple processes for fault isolation, then using local processes (i.e., give names like ":syncservice", ":msrservice") should serve the purpose (e.g., try killing any process manually from "adb shell" and the other service processes will remain alive, and when you restart your app, existing processes will keep running with same pid).
If you need multiple applications to share these services, then I believe what you are doing is the right approach.
If you don't need cross-app sharing, but just want to split them into multiple processes for fault isolation, then using local processes (i.e., give names like ":syncservice", ":msrservice") should serve the purpose (e.g., try killing any process manually from "adb shell" and the other service processes will remain alive, and when you restart your app, existing processes will keep running with same pid).
em...@google.com <em...@google.com> #9
A fix for debugging global processes is submitted. It is currently planned to be included in AS 3.5 Canary 10.
Description
------- Backtrace:
java.lang.RuntimeException: Cannot find module by package name
at com.android.tools.ndk.run.editor.NativeAndroidDebugger.attachToClient(NativeAndroidDebugger.java:164)
at org.jetbrains.android.actions.AndroidConnectDebuggerAction.closeOldSessionAndRun(AndroidConnectDebuggerAction.java:64)
at org.jetbrains.android.actions.AndroidConnectDebuggerAction.actionPerformed(AndroidConnectDebuggerAction.java:49)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:255)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:272)
at com.intellij.openapi.actionSystem.impl.ActionButton.actionPerformed(ActionButton.java:205)
at com.intellij.openapi.actionSystem.impl.ActionButton.performAction(ActionButton.java:147)
at com.intellij.openapi.actionSystem.impl.ActionButton.processMouseEvent(ActionButton.java:392)
at java.awt.Component.processEvent(Component.java:6313)
at java.awt.Container.processEvent(Container.java:2237)
at java.awt.Component.dispatchEventImpl(Component.java:4903)
at java.awt.Container.dispatchEventImpl(Container.java:2295)
at java.awt.Component.dispatchEvent(Component.java:4725)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
at java.awt.Container.dispatchEventImpl(Container.java:2281)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4725)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.awt.EventQueue$4.run(EventQueue.java:735)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:817)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:754)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:394)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
------- Version information:
Build: 3.3.2, AI-182.5107.16.33.5314842, 201902152344,
AI-182.5107.16.33.5314842, JRE 1.8.0_152-release-1248-b01x64 JetBrains s.r.o, OS Windows 10(amd64) v10.0 , screens 2560x1440, 2560x1440, 1920x1080
Android Gradle Plugin: 3.3.2
Gradle: 4.10.2
NDK: from local.properties: 17.2.4988734; latest from SDK: (not found);
LLDB: LLDB 3.1 (revision: 3.1.4508709)
CMake: from local.properties: (not specified); latest from SDK: (not found); from PATH: (not found);
IMPORTANT: Please read