java - 仅 adb 出错

标签 java android adb

我正在编写一个由 Activity 和服务构成的非常简单的 Android 应用程序。我通过执行以下操作在 Activity 中加载我的服务

@Override
public void onResume()
{
    super.onResume();

    mServiceIntent = new Intent(this, RemoteIntegerService.class);
    ComponentName name = startService(mServiceIntent);
    TextView mainText = (TextView)findViewById(R.id.mainText);
    mainText.setText(name == null ? "(null)" : name.getClassName());
}

当我在我的 Galaxy Tab 或虚拟设备上运行该应用程序时,一切看起来都很好,并且 mainText 读取了正确的类名。

但是当我在 Eclipse 中使用 adb 的“通过 usb 调试功能”启动应用程序时,我在 Intent 构造函数中出现错误(在真实设备和虚拟设备中)。这是堆栈跟踪:

RemoteInteger [Android Application] 
DalvikVM[localhost:8621]    
    Thread [<1> main] (Class load: RemoteIntegerService)    
        DexFile.defineClass(String, ClassLoader, int, ProtectionDomain) line: not available [native method] 
        DexFile.loadClassBinaryName(String, ClassLoader) line: 207  
        PathClassLoader.findClass(String) line: 211 
        PathClassLoader(ClassLoader).loadClass(String, boolean) line: 540   
        PathClassLoader(ClassLoader).loadClass(String) line: 500    
        RemoteIntegerActivity.onResume() line: 28   
        Instrumentation.callActivityOnResume(Activity) line: 1153   
        RemoteIntegerActivity(Activity).performResume() line: 4428  
        ActivityThread.performResumeActivity(IBinder, boolean) line: 2217   
        ActivityThread.handleResumeActivity(IBinder, boolean, boolean) line: 2255   
        ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1769 
        ActivityThread.access$1500(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 122   
        ActivityThread$H.handleMessage(Message) line: 1002  
        ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
        Looper.loop() line: 132 
        ActivityThread.main(String[]) line: 4025    
        Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
        Method.invoke(Object, Object...) line: 491  
        ZygoteInit$MethodAndArgsCaller.run() line: 841  
        ZygoteInit.main(String[]) line: 599 
        NativeStart.main(String[]) line: not available [native method]  
    Thread [<8> Binder Thread #2] (Running) 
    Thread [<7> Binder Thread #1] (Running) 

编辑

  • 复制了完整的堆栈轨迹

  • MyService -> RemoteIntegerService(真实名称,与堆栈跟踪一致)

编辑 2 - 子问题

我找不到有关该错误的任何信息。程序刚刚停止,我看到了堆栈跟踪,但没有别的。在 Visual Studio 上,我有一个弹出窗口描述发生的异常。 Eclipse 中有类似的东西吗?

最佳答案

正如 Julien 所指出的,调试器可能会停止并显示以下消息:

defineClass(String, ClassLoader, int, ProtectionDomain) line: not available [native method]

因为在一个类上设置了断点。删除断点解决了这个问题。

关于java - 仅 adb 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9620667/

相关文章:

android - 使用 ADB 命令获取 IMEI 号 Android 12

android - 如何连接 Kindle Fire HDX 以使用 ADB 通过 USB 进行调试

java - Runtime.exec 无法在 JDK 7u25 上运行

java - 使用 ArrayList 时整数不会增加

java - gwt-maven-plugin 无法编译,因为 "No source code is available for type org.hibernate.validator.constraints.impl.SizeValidatorForString;"

android - editText 未填充 gridLayout 中的整个列

android - ListView.setSelection 不工作

java - 如何在 Java 中使用 XPath 查询选择元素的属性值并将其放入字符串中?

android在应用程序购买中重置

java - 直接在android应用程序中执行ADB命令