我正在开发一个应用程序,我在其中使用Estimote SDK for Beacons。我已成功将Jars添加到我的项目中,并使用BeaconManager类来检查设备蓝牙的状态。现在每当我启动我的应用程序时,它每次都会崩溃。
以下是我在应用程序崩溃时获取的logcat的代码: -
Toast.makeText(this, "Checking Bluetooth Status", Toast.LENGTH_LONG).show();
if (!beaconManager.hasBluetooth()) {
Toast.makeText(this, "Device does not have Bluetooth Low Energy", Toast.LENGTH_LONG).show();
return;
}
// If Bluetooth is not enabled, let user enable it.
if (!beaconManager.isBluetoothEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
} else {
//connectToService();
Toast.makeText(mContext, " "+"Start Searching for Beacons", 0).show();
}
并且Logcat是: -
01-23 12:54:15.629: E/dalvikvm(24896): Could not find class 'com.estimote.sdk.BeaconManager', referenced from method com.example.beaconproject.HomeScreen.onCreate
01-23 12:54:15.769: E/AndroidRuntime(24896): FATAL EXCEPTION: main
01-23 12:54:15.769: E/AndroidRuntime(24896): java.lang.NoClassDefFoundError: com.estimote.sdk.BeaconManager
01-23 12:54:15.769: E/AndroidRuntime(24896): at com.example.beaconproject.HomeScreen.onCreate(HomeScreen.java:24)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.app.Activity.performCreate(Activity.java:5372)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.app.ActivityThread.access$700(ActivityThread.java:159)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.os.Handler.dispatchMessage(Handler.java:99)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.os.Looper.loop(Looper.java:176)
01-23 12:54:15.769: E/AndroidRuntime(24896): at android.app.ActivityThread.main(ActivityThread.java:5419)
01-23 12:54:15.769: E/AndroidRuntime(24896): at java.lang.reflect.Method.invokeNative(Native Method)
01-23 12:54:15.769: E/AndroidRuntime(24896): at java.lang.reflect.Method.invoke(Method.java:525)
01-23 12:54:15.769: E/AndroidRuntime(24896): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
01-23 12:54:15.769: E/AndroidRuntime(24896): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
01-23 12:54:15.769: E/AndroidRuntime(24896): at dalvik.system.NativeStart.main(Native Method)
我的清单文件如下: -
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="21" />
<!-- Needed permissions in order to scan for beacons. -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- Declaration that this app is usable on phones with Bluetooth Low Energy. -->
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".HomeScreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.estimote.sdk.service.BeaconService"
android:exported="false" />
任何人都可以帮我解决这个问题。任何帮助都会很明显。 感谢。