2017-09-30 17:22:59 dzkdxyx 阅读数 723
  • Android底层技术:Java层系统服务(Android Service)

    为什么我们需要学习撰写系统服务呢? 底层系统服务是Android 框架裡接近Linux/Driver 的部分。为了充分发挥硬件设备的差異化特性,系统服务是让上层Java 应用程序來使用Driver/HW Device 特色的重要管道。于此,先仔细解析Java层系统服务的架构,然后阐述这系统服务的代码开发要点,以及其API设计方法。

    32505 人正在学习 去看看 高煥堂

前提:因为工作电脑卡的不行,所以系统硬盘就切换为固态硬盘,就重装系统了,升级完了之后,觉得焕然一新,轻松+愉快;前几天准备用Android Device Monitor,却发现打不开直接报错了(囧哭)
正好国庆前一天,工作不是很紧张,就把先这个问题解决了,避免影响之后的工作

报错log(在目录sdk/tools/lib/monitor-x86_64/×××.log)

!ENTRY org.eclipse.osgi 4 0 2017-09-30 16:23:09.769
!MESSAGE Application error
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in com.android.ide.eclipse.monitor was unable to load class com.android.ide.eclipse.monitor.MonitorApplication.
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:176)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:191)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter$TerminatingClassNotFoundException: An error occurred while automatically activating bundle com.android.ide.eclipse.monitor (5).
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:122)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:340)
    at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1212)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
    ... 16 more
Caused by: org.osgi.framework.BundleException: The activator com.android.ide.eclipse.monitor.MonitorPlugin for bundle com.android.ide.eclipse.monitor is invalid
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:172)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:679)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440)
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)
    ... 28 more
Caused by: java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocation$AndroidLocationException : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:632)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:607)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:568)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at com.android.ide.eclipse.monitor.MonitorPlugin.<clinit>(MonitorPlugin.java:28)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:383)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:167)
    ... 34 more

根据log google搜索解决方案

先根据下面log关键字搜索

Caused by: java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocation$AndroidLocationException : Unsupported major.minor version 52.0

https://stackoverflow.com/questions/42661578/android-device-monitor-will-not-launch-either-from-android-studio-or-from-termi
给出的解决方式是:安装java8
于是将本地的java7,切换为java8,但是依旧无效;

切换关键字搜索:

org.eclipse.core.runtime.CoreException: Plug-in com.android.ide.eclipse.monitor was unable to load class com.android.ide.eclipse.monitor.MonitorApplication.、

https://issuetracker.google.com/issues/36970884
给出的解决方案是下载SDK之前老的版本,文档里有给出可以老的sdk版本
Currently the only workaround is to download the previous version of SDK separately, and replace the contents of tools/lib/monitor folder with the one from the previous version. You can get the previous version here:

https://dl.google.com/android/android-sdk_r21.1-windows.zip
https://dl.google.com/android/android-sdk_r21.1-macosx.zip
https://dl.google.com/android/android-sdk_r21.1-linux.tgz

亲证,替换sdk/tools文件夹即可成功打开Android Device Monitor

后记

将java8 切换至java7之后,依旧有效,看来这个问题跟java版本没有问题

作为Android新进菜鸟一枚,多谢大神们给出的解决方案,虽只是搬运别人的想法,但整理到自己的博客是为了方便遇到此类问题能够快速找到解决方案

2017-05-04 10:30:40 FengShanChuiChui 阅读数 689
  • Android底层技术:Java层系统服务(Android Service)

    为什么我们需要学习撰写系统服务呢? 底层系统服务是Android 框架裡接近Linux/Driver 的部分。为了充分发挥硬件设备的差異化特性,系统服务是让上层Java 应用程序來使用Driver/HW Device 特色的重要管道。于此,先仔细解析Java层系统服务的架构,然后阐述这系统服务的代码开发要点,以及其API设计方法。

    32505 人正在学习 去看看 高煥堂

今天升级了Android Studio到2.3.1,顺便升级了SDK Tool到26.0.2,再之后从Android Studio中打开ADM(Android Device Monitor)就出错了。图示如下:


这里写图片描述

于是根据提示查看log,找到一些信息如下:

!SESSION 2017-05-04 10:03:49.535 ———————————————–
eclipse.buildId=unknown java.version=1.7.0_121 java.vendor=Oracle
Corporation BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk,
NL=zh_CN Command-line arguments: -os linux -ws gtk -arch x86_64 -data
@noDefault

Root exception:
java.lang.UnsupportedClassVersionError:
com/android/prefs/AndroidLocation$AndroidLocationException : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:632)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:607)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:568)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.android.ide.eclipse.monitor.MonitorPlugin.(MonitorPlugin.java:28)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:383)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:167)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:679)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440)
at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:340)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1212)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:191)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

根据其中的

com/android/prefs/AndroidLocation$AndroidLocationException :
Unsupported major.minor version 52.0

查找到stackoverflow上的一个问答说是需要java8。按此法配置默认java为java 1.8,问题解决。

以此记录!

2017-03-27 16:05:57 junjunguoguo 阅读数 3649
  • Android底层技术:Java层系统服务(Android Service)

    为什么我们需要学习撰写系统服务呢? 底层系统服务是Android 框架裡接近Linux/Driver 的部分。为了充分发挥硬件设备的差異化特性,系统服务是让上层Java 应用程序來使用Driver/HW Device 特色的重要管道。于此,先仔细解析Java层系统服务的架构,然后阐述这系统服务的代码开发要点,以及其API设计方法。

    32505 人正在学习 去看看 高煥堂

解决Android 7.0中 Android Device Monitor(DDMS)的 File Explorer不显示目录树及data目录无法打开的问题

在准备数据存储的课程时,想查看数据库有没有被成功的创建,发现File Explorer中没法查看,里面是空白的,通过查询发现 https://segmentfault.com/a/1190000008416511 这里可以解决目录树不显示问题
通过以上的方式,目录树确实可以显示了,但是双击无法展开/data/目录。上面显示rwxrwx–x。
发现/data的文件权限是drwxrwxrwx这是linux的文件权限

  • 一个代表文件类型d是directory目录
  • 后面三个是创建者的权限r读w写x执行
  • 再后面三个是同组者的权限
  • 最后三个是其他人的权限

我们从DDMS查看的时候就是其他人的权限发现只有执行 因此只需修改权限就可以了,当进行这个操作的时候手机必须要root权限。


C:\Users\fengj>adb shell
generic_x86_64:/ $ su
generic_x86_64:/ # cd /data/data/cn.edu.bzu.storage_litepaldemo/
generic_x86_64:/data/data/cn.edu.bzu.storage_litepaldemo # cd databases
generic_x86_64:/data/data/cn.edu.bzu.storage_litepaldemo/databases #
ls
BookStore.db BookStore.db-journal
generic_x86_64:/data/data/cn.edu.bzu.storage_litepaldemo/databases #
sqlite3 BookStore.db
SQLite version 3.9.2 2015-11-02 18:31:45
Enter “.help” for usage hints.
sqlite> .schema
CREATE TABLE android_metadata (locale TEXT);
CREATE TABLE table_schema (id integer primary key autoincrement,name text, type integer);
CREATE TABLE book (id integer primary key autoincrement,author text, name text, pages integer, price real);
sqlite>

2019-05-02 10:52:59 think_ycx 阅读数 589
  • Android底层技术:Java层系统服务(Android Service)

    为什么我们需要学习撰写系统服务呢? 底层系统服务是Android 框架裡接近Linux/Driver 的部分。为了充分发挥硬件设备的差異化特性,系统服务是让上层Java 应用程序來使用Driver/HW Device 特色的重要管道。于此,先仔细解析Java层系统服务的架构,然后阐述这系统服务的代码开发要点,以及其API设计方法。

    32505 人正在学习 去看看 高煥堂

eclipse的DDMS,在早期的Android Studio的Tools中是有Android Device monitor 的,但是新版本中找不到了。该程序的路径放在了sdk目录下。macOS上的路径是/Users/<username>/Library/Android/sdk/tools ,运行其中的monitor文件即可打开Android Device monitor。

遇到错误:

Android Device monitor 打开后白屏,这时候monitor的日志是:Error Loading DDMS Preferences

解决方案:

1. 解锁手机
2. 重启monitor,耐心等待
3. 效果如下图所示:

 

20190502 更新: 这个完全用不了,非常卡顿。

2019-08-14 17:04:11 ChinaGir 阅读数 39
  • Android底层技术:Java层系统服务(Android Service)

    为什么我们需要学习撰写系统服务呢? 底层系统服务是Android 框架裡接近Linux/Driver 的部分。为了充分发挥硬件设备的差異化特性,系统服务是让上层Java 应用程序來使用Driver/HW Device 特色的重要管道。于此,先仔细解析Java层系统服务的架构,然后阐述这系统服务的代码开发要点,以及其API设计方法。

    32505 人正在学习 去看看 高煥堂

1.问题

在eclipse中,启动AVD后(前提),打开File Explorer空空如也(见下图)。

2.解决方法

step1.下载ddmlib.jar 

ddmlib.jar的下载位置 
文件大小:282KB。

或者,百度云:http://pan.baidu.com/s/1sl4KaOP 提取密码:sygc

step2.在eclipse下搜索ddmlib.jar 

          我的路径:D:\Java\eclipse-SDK-4.2.2-win32-x86_64\configuration\org.eclipse.osgi\bundles\241\1\.cp\libs

step3.替换ddmlib.jar

     先关闭AVD,关闭Eclipse。

     用刚刚下载的ddmlib.jar 替换刚刚step2中搜索到的ddmlib.jar 的路径。

     再次启动Eclipse和AVD,奇迹出现了。

   

 

3.参考:

https://blog.csdn.net/u013553529/article/details/54292956

没有更多推荐了,返回首页