Android事物运行时异常:
java.lang.NoClassDefFoundError:解析失败:Lcom / google / android / things / pio / PeripheralManager;
清单文件:
[batch_size, num_rows, num_cols]
错误logcat:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidthings.simplepio">
<application android:allowBackup="true" android:icon="@android:drawable/sym_def_app_icon"
android:name="android.support.multidex.MultiDexApplication"
android:label="@string/app_name">
<uses-library android:name="com.google.android.things"/>
<activity android:name=".BlinkActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Launch activity automatically on boot -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.IOT_LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
这是我的代码,我从这个Link 得到了这个,我只是克隆它没有改变。
01-01 00:00:53.293 1326-1326/com.example.androidthings.simplepio E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androidthings.simplepio, PID: 1326
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/things/pio/PeripheralManager;
at com.example.androidthings.simplepio.BlinkActivity.onCreate(BlinkActivity.java:51)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Activity.performCreate(Activity.java:6991)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.things.pio.PeripheralManager" on path: DexPathList[[zip file "/system/framework/com.google.android.things.jar", zip file "/data/app/com.example.androidthings.simplepio-y-kMOBHPpOQbWFdWf4QeXw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.androidthings.simplepio-y-kMOBHPpOQbWFdWf4QeXw==/lib/arm, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.example.androidthings.simplepio.BlinkActivity.onCreate(BlinkActivity.java:51)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Activity.performCreate(Activity.java:6991)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteIncode,807)
01-01 00:00:53.446 1326-1326/com.example.androidthings.simplepio I/Process: Sending signal. PID: 1326 SIG: 9
如果有任何解决这个问题,请帮助我。
答案 0 :(得分:6)
我通过更新我的Android Things解决了这个问题。我使用新的设置工具来刷新Android内容:https://partner.android.com/things/console/u/1/#/tools
答案 1 :(得分:0)
我不知道这是否有所帮助,但我通过在我的build.gradle com.google.android.things:androidthings:+
中确定只将其设置为编译(compileOnly
)的依赖关系来解决它而不是重新分配。
我通过在implementation 'com.google.android.things:androidthings:+'
中更改它来修复它。