gpt4 book ai didi

android - Estimote/iBeacon 不是 Android 中的 Region 类

转载 作者:行者123 更新时间:2023-11-29 21:13:42 26 4
gpt4 key购买 nike

我正在尝试做一个简单的应用程序来控制信标,但是当我启动该应用程序时它停止了。我想我使用“添加外部 jar”正确导入了 sdk。

sdk imported

我更改了 android list 以执行蓝牙权限和其他操作...

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
...
<service android:name="com.estimote.sdk.service.BeaconService" android:exported="false"/>

这是错误日志:

02-25 13:25:45.431: E/dalvikvm(9326): Could not find class 'com.estimote.sdk.Region', referenced from method com.example.beacons.MainActivity.<clinit>
02-25 13:25:45.431: W/dalvikvm(9326): VFY: unable to resolve new-instance 710 (Lcom/estimote/sdk/Region;) in Lcom/example/beacons/MainActivity;
02-25 13:25:45.431: D/dalvikvm(9326): VFY: replacing opcode 0x22 at 0x0001
02-25 13:25:45.431: D/dalvikvm(9326): DexOpt: unable to opt direct call 0x13b3 at 0x07 in Lcom/example/beacons/MainActivity;.<clinit>
02-25 13:25:45.431: W/dalvikvm(9326): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/example/beacons/MainActivity;
02-25 13:25:45.431: W/dalvikvm(9326): Class init failed in newInstance call (Lcom/example/beacons/MainActivity;)
02-25 13:25:45.431: D/AndroidRuntime(9326): Shutting down VM
02-25 13:25:45.431: W/dalvikvm(9326): threadid=1: thread exiting with uncaught exception (group=0x41599ba8)
02-25 13:25:45.431: E/AndroidRuntime(9326): FATAL EXCEPTION: main
02-25 13:25:45.431: E/AndroidRuntime(9326): Process: com.example.beacons, PID: 9326
02-25 13:25:45.431: E/AndroidRuntime(9326): java.lang.NoClassDefFoundError: com.estimote.sdk.Region
02-25 13:25:45.431: E/AndroidRuntime(9326): at com.example.beacons.MainActivity.<clinit>(MainActivity.java:18)
02-25 13:25:45.431: E/AndroidRuntime(9326): at java.lang.Class.newInstanceImpl(Native Method)
02-25 13:25:45.431: E/AndroidRuntime(9326): at java.lang.Class.newInstance(Class.java:1208)
02-25 13:25:45.431: E/AndroidRuntime(9326): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
02-25 13:25:45.431: E/AndroidRuntime(9326): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
02-25 13:25:45.431: E/AndroidRuntime(9326): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-25 13:25:45.431: E/AndroidRuntime(9326): at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-25 13:25:45.431: E/AndroidRuntime(9326): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-25 13:25:45.431: E/AndroidRuntime(9326): at android.os.Handler.dispatchMessage(Handler.java:102)
02-25 13:25:45.431: E/AndroidRuntime(9326): at android.os.Looper.loop(Looper.java:136)
02-25 13:25:45.431: E/AndroidRuntime(9326): at android.app.ActivityThread.main(ActivityThread.java:5017)
02-25 13:25:45.431: E/AndroidRuntime(9326): at java.lang.reflect.Method.invokeNative(Native Method)
02-25 13:25:45.431: E/AndroidRuntime(9326): at java.lang.reflect.Method.invoke(Method.java:515)
02-25 13:25:45.431: E/AndroidRuntime(9326): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-25 13:25:45.431: E/AndroidRuntime(9326): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-25 13:25:45.431: E/AndroidRuntime(9326): at dalvik.system.NativeStart.main(Native Method)
02-25 13:30:45.704: I/Process(9326): Sending signal. PID: 9326 SIG: 9

我不知道为什么它说找不到类'com.estimote.sdk.Region'...

这是主要 Activity

package com.example.beacons;

import java.util.List;

import com.estimote.sdk.Beacon;
import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region;

import android.os.Bundle;
import android.os.RemoteException;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends Activity {
private static final String ESTIMOTE_PROXIMITY_UUID = "B9407F30-F5F8-466E-AFF9-25556B57FE6D";
private static final Region ALL_ESTIMOTE_BEACONS = new Region("regionId", ESTIMOTE_PROXIMITY_UUID, null, null);

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

public void bluetoothTest(View view){
Toast.makeText(getBaseContext(),"Listener works", Toast.LENGTH_SHORT).show();
}

}

如果我删除这一行:

private static final Region ALL_ESTIMOTE_BEACONS = new Region("regionId", ESTIMOTE_PROXIMITY_UUID, null, null);

一切正常,触摸屏幕上的 1 个按钮时我可以看到 toast 。

最佳答案

关于android - Estimote/iBeacon 不是 Android 中的 Region 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22014435/

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