有人可以识别此代码中的错误,程序本身的逻辑没有实现,它应该只与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)
答案 0 :(得分:1)
发表评论有点迟了。但是因为我花了很多时间看这个答案,我会在这里发布我的解决方案。我希望遇到这个问题的人现在可以解决它。
如果您使用的是Android工作室,只需将 armeabi 和 armeabi-v7a 复制到 src / main / jniLibs /
答案 1 :(得分:0)
问题仅与导入库有关,只是将所有文件夹内容Sphero-Android-SDK / library / libs复制到项目目标中的libs文件夹。并清理项目。