我正在尝试在我的应用程序中使用iBeacon代码,当没有信标时,应用程序只是继续搜索它们,但是当我的应用程序找到一个信标它崩溃时。我是android开发的新手并没有多少调试经验。感谢所有的帮助。提前致谢。这是错误代码:
11-20 11:23:34.529 15407-15407/com.example.marik.pinafly W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x418acda0)
11-20 11:23:34.529 15407-15419/com.example.marik.pinafly D/BluetoothAdapter﹕ onScanResult() - Device=61:78:1A:F3:10:97 RSSI=-93
11-20 11:23:34.549 15407-15407/com.example.marik.pinafly E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.marik.pinafly, PID: 15407
android.view.InflateException: Binary XML file line #8: Error inflating class com.estimote.examples.demos.DistanceBackgroundView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.example.marik.pinafly.LeDeviceListAdapter.inflateIfRequired(LeDeviceListAdapter.java:72)
at com.example.marik.pinafly.LeDeviceListAdapter.getView(LeDeviceListAdapter.java:56)
at android.widget.AbsListView.obtainView(AbsListView.java:2738)
at android.widget.ListView.makeAndAddView(ListView.java:1811)
at android.widget.ListView.fillDown(ListView.java:697)
at android.widget.ListView.fillFromTop(ListView.java:763)
at android.widget.ListView.layoutChildren(ListView.java:1627)
at android.widget.AbsListView.onLayout(AbsListView.java:2563)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:459)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2356)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2069)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6637)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:814)
at android.view.Choreographer.doCallbacks(Choreographer.java:614)
at android.view.Choreographer.doFrame(Choreographer.java:584)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:800)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.estimote.examples.demos.DistanceBackgroundView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.marik.pinafly-6.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.marik.pinafly-6, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.view.LayoutInflater.createView(LayoutInflater.java:565)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.example.marik.pinafly.LeDeviceListAdapter.inflateIfRequired(LeDeviceListAdapter.java:72)
at com.example.marik.pinafly.LeDeviceListAdapter.getView(LeDeviceListAdapter.java:56)
at android.widget.AbsListView.obtainView(AbsListView.java:2738)
at android.widget.ListView.makeAndAddView(ListView.java:1811)
at android.widget.ListView.fillDown(ListView.java:697)
at android.widget.ListView.fillFromTop(ListView.java:763)
at android.widget.ListView.layoutChildren(ListView.java:1627)
at android.widget.AbsListView.onLayout(AbsListView.java:2563)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:459)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15762)
at android.view.ViewGroup.layout(ViewGroup.java:4880)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2356)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2069)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6637)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:814)
at android.view.Choreographer.doCallbacks(Choreographer.java:614)
at android.view.Choreographer.doFrame(Choreographer.java:584)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:800)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
DistanceBackgroundView.java文件
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
/**
* Draws distance background that is stretched to parent's height, keeps aspect ration
* and centers the image.
*
* @author wiktor@estimote.com (Wiktor Gworek)
*/
public class DistanceBackgroundView extends View {
private final Drawable drawable;
public DistanceBackgroundView(Context context, AttributeSet attrs) {
super(context, attrs);
drawable = context.getResources().getDrawable(R.drawable.bg_distance);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = drawable.getIntrinsicWidth() * canvas.getHeight() / drawable.getIntrinsicHeight();
int deltaX = (width - canvas.getWidth()) / 2;
drawable.setBounds(-deltaX, 0, width - deltaX, canvas.getHeight());
drawable.draw(canvas);
}
}
清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.marik.pinafly">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="HIDDEN" />
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".LoginActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".BluetoothActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
<activity
android:name=".MapActivity"
android:label="@string/title_activity_map">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.pinafly.LoginActivity" />
</activity>
<activity
android:name=".Activity2"
android:label="App Activities" />
<activity
android:name=".ImagePickActivity"
android:label="@string/title_activity_image_pick_avtivity" />
<activity
android:name=".AllDemosActivity"
android:label="Demos"/>
<activity
android:name=".ListBeaconsActivity"
android:label="Select Beacon" />
<activity
android:name=".DistanceBeaconActivity"
android:label="Distance Demo" />
<activity
android:name=".NotifyDemoActivity"
android:label="Notify Demo" />
<activity
android:name=".CharacteristicsDemoActivity"
android:label="Characteristics Demo" />
<!-- Estimote service responsible for scanning beacons. -->
<service
android:name="com.estimote.sdk.service.BeaconService"
android:exported="false" />
</application>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="19" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="permission_name" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="com.example.mapdemoapiv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- Declaration that this app is usable on phones with Bluetooth Low Energy. -->
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<service
android:name="com.estimote.sdk.service.BeaconService"
android:exported="false" />
</manifest>
答案 0 :(得分:0)
因为com.estimote.examples.demos.DistanceBackgroundView
是演示项目路径。您只需更改路径:
yourProjectPath.DistanceBackgroundView