gpt4 book ai didi

iot - Android 东西 : java. lang.NoClassDefFoundError:解析失败:Lcom/google/android/things/pio/PeripheralManager;

转载 作者:行者123 更新时间:2023-12-04 20:09:38 28 4
gpt4 key购买 nike

Android事物运行时异常:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/things/pio/PeripheralManager;



list 文件:
<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>

错误日志:
    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

这是我的代码, 我是从这里得到的 Link ,我只是克隆它没有任何改变。
public class BlinkActivity extends Activity {
private static final String TAG = BlinkActivity.class.getSimpleName();
private static final int INTERVAL_BETWEEN_BLINKS_MS = 1000;

private Handler mHandler = new Handler();
private Gpio mLedGpio;
private boolean mLedState = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "Starting BlinkActivity");

try {
String pinName = BoardDefaults.getGPIOForLED();
mLedGpio = PeripheralManager.getInstance().openGpio(pinName);
mLedGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
Log.i(TAG, "Start blinking LED GPIO pin");
// Post a Runnable that continuously switch the state of the GPIO, blinking the
// corresponding LED
mHandler.post(mBlinkRunnable);
} catch (IOException e) {
Log.e(TAG, "Error on PeripheralIO API", e);
}
}

@Override
protected void onDestroy() {
super.onDestroy();
// Remove pending blink Runnable from the handler.
mHandler.removeCallbacks(mBlinkRunnable);
// Close the Gpio pin.
Log.i(TAG, "Closing LED GPIO pin");
try {
mLedGpio.close();
} catch (IOException e) {
Log.e(TAG, "Error on PeripheralIO API", e);
} finally {
mLedGpio = null;
}
}

private Runnable mBlinkRunnable = new Runnable() {
@Override
public void run() {
// Exit Runnable if the GPIO is already closed
if (mLedGpio == null) {
return;
}
try {
// Toggle the GPIO state
mLedState = !mLedState;
mLedGpio.setValue(mLedState);
Log.d(TAG, "State set to " + mLedState);

// Reschedule the same runnable in {#INTERVAL_BETWEEN_BLINKS_MS} milliseconds
mHandler.postDelayed(mBlinkRunnable, INTERVAL_BETWEEN_BLINKS_MS);
} catch (IOException e) {
Log.e(TAG, "Error on PeripheralIO API", e);
}
}
};
}

如果有人解决了这个问题,请帮助我。

最佳答案

我通过更新我的 Android Things 解决了这个问题。我使用了新的设置实用工具来刷新我的 Android Things:https://partner.android.com/things/console/u/1/#/tools

关于iot - Android 东西 : java. lang.NoClassDefFoundError:解析失败:Lcom/google/android/things/pio/PeripheralManager;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49206052/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com