gpt4 book ai didi

java - 尝试连接 sphero 时发生错误

转载 作者:行者123 更新时间:2023-12-01 12:44:12 25 4
gpt4 key购买 nike

有人可以找出这段代码中的错误吗,程序本身的逻辑没有实现,它应该只是与 sphero 连接,那么不应该发生任何错误。有谁知道如何解决这个问题

提前谢谢您。

public class MainActivitySimon extends Activity 
{
private SpheroConnectionView mSpheroConnectionView;
private Sphero mRobot = null;

private void updateSpheroPosition(double x, double y)
{
}

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity_simon);

mSpheroConnectionView = (SpheroConnectionView) findViewById(R.id.sphero_connection_view);
mSpheroConnectionView.addConnectionListener(new ConnectionListener()
{

@Override
public void onConnected(Robot robot)
{
//SpheroConnectionView is made invisible on connect by default
mRobot = (Sphero) robot;
}

@Override
public void onConnectionFailed(Robot sphero)
{
// let the SpheroConnectionView handle or hide it and do something here
}

@Override
public void onDisconnected(Robot sphero)
{
mSpheroConnectionView.startDiscovery();
}
});
}

@Override
protected void onResume()
{
super.onResume();
mSpheroConnectionView.startDiscovery();
}
@Override
protected void onPause()
{
super.onPause();
RobotProvider.getDefaultProvider().disconnectControlledRobots();
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_main_activity_simon, menu);
return true;
}
}

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/R"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#262625"
android:paddingBottom="5dp"
tools:context=".MainActivitySimon" >

<Button
android:id="@+id/Green"
android:layout_width="140.0dip"
android:layout_height="160.0dip"
android:layout_alignRight="@+id/Red"
android:layout_alignTop="@+id/Yellow"
android:background="@drawable/customgreen"/>

<Button
android:id="@+id/Yellow"
android:layout_width="140.0dip"
android:layout_height="160.0dip"
android:layout_alignLeft="@+id/Blue"
android:layout_below="@+id/Blue"
android:background="@drawable/customyellow"
android:layout_marginTop = "3dp" />


<TextView
android:id="@+id/Scorebox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/Yellow"
android:layout_below="@+id/Yellow"
android:layout_marginTop="8dp"
android:text="Current Score: "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#cccccc"
android:textColorLink="#262625" />

<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/Scorebox"
android:layout_alignLeft="@+id/Green"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#cccccc" />

<Button
android:id="@+id/Red"
android:layout_width="140.0dip"
android:layout_height="160.0dip"
android:layout_above="@+id/Simon"
android:layout_toLeftOf="@+id/Simon"
android:layout_marginRight = "-50dip"
android:layout_marginBottom = "-30dip"
android:background="@drawable/custombuttons" />

<Button
android:id="@+id/Blue"
android:layout_width="140.0dip"
android:layout_height="160.0dip"
android:layout_alignBaseline="@+id/Red"
android:layout_alignBottom="@+id/Red"
android:layout_toRightOf="@+id/Simon"
android:layout_marginLeft = "-50dip"
android:background="@drawable/customblue" />

<Button
android:id="@+id/Simon"
android:layout_width="100.0dip"
android:layout_height="70.0dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/customsimon"
android:onClick="Simonsays" />

<orbotix.view.connection.SpheroConnectionView
android:id="@+id/sphero_connection_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#D0000000"/>


</RelativeLayout>

07-19 12:03:50.354: E/AndroidRuntime(23914): FATAL EXCEPTION: Thread-9923
07-19 12:03:50.354: E/AndroidRuntime(23914): Process: com.hprc.simongame, PID: 23914
07-19 12:03:50.354: E/AndroidRuntime(23914): java.lang.UnsatisfiedLinkError: Couldn't load achievement_manager from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.hprc.simongame-1.apk"],nativeLibraryDirectories=[/data/app- lib/com.hprc.simongame-1, /vendor/lib, /system/lib]]]: findLibrary returned null
07-19 12:03:50.354: E/AndroidRuntime(23914): at java.lang.Runtime.loadLibrary(Runtime.java:358)
07-19 12:03:50.354: E/AndroidRuntime(23914): at java.lang.System.loadLibrary(System.java:526)
07-19 12:03:50.354: E/AndroidRuntime(23914): at orbotix.achievement.AchievementManager.<clinit>(AchievementManager.java:110)
07-19 12:03:50.354: E/AndroidRuntime(23914): at orbotix.robot.internal.DeviceConnection$DeviceSession$1$1.handleMessage(DeviceConnection.java:765)
07-19 12:03:50.354: E/AndroidRuntime(23914): at android.os.Handler.dispatchMessage(Handler.java:102)
07-19 12:03:50.354: E/AndroidRuntime(23914): at android.os.Looper.loop(Looper.java:136)
07-19 12:03:50.354: E/AndroidRuntime(23914): at orbotix.robot.internal.DeviceConnection$DeviceSession$1.run(DeviceConnection.java:787)
07-19 12:03:50.354: E/AndroidRuntime(23914): at java.lang.Thread.run(Thread.java:841)
07-19 12:03:50.876: E/ActivityThread(23914): Activity com.hprc.simongame.MainActivitySimon has leaked IntentReceiver orbotix.robot.base.RobotProvider$1@41ff37d8 that was originally registered here. Are you missing a call to unregisterReceiver()?
07-19 12:03:50.876: E/ActivityThread(23914): android.app.IntentReceiverLeaked: Activity com.hprc.simongame.MainActivitySimon has leaked IntentReceiver orbotix.robot.base.RobotProvider$1@41ff37d8 that was originally registered here. Are you missing a call to unregisterReceiver()?
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:805)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:606)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1559)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1539)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1533)
07-19 12:03:50.876: E/ActivityThread(23914): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:467)
07-19 12:03:50.876: E/ActivityThread(23914): at orbotix.robot.base.RobotProvider.setBroadcastContext(RobotProvider.java:209)
07-19 12:03:50.876: E/ActivityThread(23914): at orbotix.robot.base.RobotProvider.startDiscovery(RobotProvider.java:236)
07-19 12:03:50.876: E/ActivityThread(23914): at orbotix.view.connection.SpheroConnectionView.setupConnectionView(SpheroConnectionView.java:254)
07-19 12:03:50.876: E/ActivityThread(23914): at orbotix.view.connection.SpheroConnectionView.startDiscovery(SpheroConnectionView.java:247)
07-19 12:03:50.876: E/ActivityThread(23914): at orbotix.view.connection.SpheroConnectionView.<init>(SpheroConnectionView.java:215)
07-19 12:03:50.876: E/ActivityThread(23914): at java.lang.reflect.Constructor.constructNative(Native Method)
07-19 12:03:50.876: E/ActivityThread(23914): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
07-19 12:03:50.876: E/ActivityThread(23914): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
07-19 12:03:50.876: E/ActivityThread(23914): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
07-19 12:03:50.876: E/ActivityThread(23914): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
07-19 12:03:50.876: E/ActivityThread(23914): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
07-19 12:03:50.876: E/ActivityThread(23914): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
07-19 12:03:50.876: E/ActivityThread(23914): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
07-19 12:03:50.876: E/ActivityThread(23914): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.Activity.setContentView(Activity.java:1937)
07-19 12:03:50.876: E/ActivityThread(23914): at com.hprc.simongame.MainActivitySimon.onCreate(MainActivitySimon.java:81)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.Activity.performCreate(Activity.java:5248)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.ActivityThread.access$800(ActivityThread.java:139)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
07-19 12:03:50.876: E/ActivityThread(23914): at android.os.Handler.dispatchMessage(Handler.java:102)
07-19 12:03:50.876: E/ActivityThread(23914): at android.os.Looper.loop(Looper.java:136)
07-19 12:03:50.876: E/ActivityThread(23914): at android.app.ActivityThread.main(ActivityThread.java:5086)
07-19 12:03:50.876: E/ActivityThread(23914): at java.lang.reflect.Method.invokeNative(Native Method)
07-19 12:03:50.876: E/ActivityThread(23914): at java.lang.reflect.Method.invoke(Method.java:515)
07-19 12:03:50.876: E/ActivityThread(23914): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-19 12:03:50.876: E/ActivityThread(23914): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-19 12:03:50.876: E/ActivityThread(23914): at dalvik.system.NativeStart.main(Native Method)

最佳答案

现在发表评论有点晚了。但因为我也花了很多时间寻找这个答案,所以我将在这里发布我的解决方案。我希望遇到这个问题的人现在可以解决它。

如果您使用的是 android studio,只需将 armeabiarmeabi-v7a 复制到 src/main/jniLibs/

关于java - 尝试连接 sphero 时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24842225/

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