不幸的是,[Beacon Project name] 已经停止
Unfortunately, [Beacon Project name] has stopped
当我尝试 运行 我的信标查找器项目时出现以下错误:
Unfortunately, Beacon Project has stopped.
这是我的 logcat:
02-06 02:57:39.960 23145-23145/project.rssi.beacon.com.beaconproject W/System: ClassLoader referenced unknown path: /data/app/project.rssi.beacon.com.beaconproject-1/lib/arm64
02-06 02:57:39.995 23145-23145/project.rssi.beacon.com.beaconproject I/HwCust: Constructor found for class android.app.HwCustActivityImpl
02-06 02:57:40.002 23145-23145/project.rssi.beacon.com.beaconproject I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl
02-06 02:57:40.069 23145-23145/project.rssi.beacon.com.beaconproject I/BeaconManager: BeaconManager started up on pid 23145 named 'project.rssi.beacon.com.beaconproject' for application package 'project.rssi.beacon.com.beaconproject'. isMainProcess=true
02-06 02:57:40.072 23145-23145/project.rssi.beacon.com.beaconproject E/AndroidRuntime: FATAL EXCEPTION: main
Process: project.rssi.beacon.com.beaconproject, PID: 23145
java.lang.RuntimeException: Unable to start activity ComponentInfo{project.rssi.beacon.com.beaconproject/project.rssi.beacon.com.beaconproject.MainActivity}: org.altbeacon.beacon.BeaconManager$ServiceNotDeclaredException: The BeaconService is not properly declared in AndroidManifest.xml. If using Eclipse, please verify that your project.properties has manifestmerger.enabled=true
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2793)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6577)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Caused by: org.altbeacon.beacon.BeaconManager$ServiceNotDeclaredException: The BeaconService is not properly declared in AndroidManifest.xml. If using Eclipse, please verify that your project.properties has manifestmerger.enabled=true
at org.altbeacon.beacon.BeaconManager.verifyServiceDeclaration(BeaconManager.java:1213)
at org.altbeacon.beacon.BeaconManager.<init>(BeaconManager.java:321)
at org.altbeacon.beacon.BeaconManager.getInstanceForApplication(BeaconManager.java:310)
at project.rssi.beacon.com.beaconproject.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6910)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6577)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
02-06 02:57:40.081 23145-23145/project.rssi.beacon.com.beaconproject I/Process: Sending signal. PID: 23145 SIG: 9
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="project.rssi.beacon.com.beaconproject">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
</manifest>
代码没有问题,我猜,我认为这是 Android Studio 中的一种错误,但无法弄清楚。
根据治疗
You must create a class that extends Application (shown in the example) and then declare this in your AndroidManifest.xml.
因此创建一个 class 扩展应用程序 class 并将其添加到清单中。android:name="com.example.MyApplicationName"
也将此添加到您的 activity android:launchMode="singleInstance"
应用程序 class 的示例是:
public class MyApplicationName extends Application implements BootstrapNotifier {
private static final String TAG = ".MyApplicationName";
private RegionBootstrap regionBootstrap;
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "App started up");
BeaconManager beaconManager =
BeaconManager.getInstanceForApplication(this);
}
@Override
public void didDetermineStateForRegion(int arg0, Region arg1) {
// Don't care
}
@Override
public void didEnterRegion(Region arg0) {
regionBootstrap.disable();
Intent intent = new Intent(this, MainActivity.class);
// IMPORTANT: in the AndroidManifest.xml definition of this activity, you must set android:launchMode="singleInstance" or you will get two instances
// created when a user launches the activity manually and it gets launched from here.
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
@Override
public void didExitRegion(Region arg0) {
}
}
可以找到更多信息here
当我尝试 运行 我的信标查找器项目时出现以下错误:
Unfortunately, Beacon Project has stopped.
这是我的 logcat:
02-06 02:57:39.960 23145-23145/project.rssi.beacon.com.beaconproject W/System: ClassLoader referenced unknown path: /data/app/project.rssi.beacon.com.beaconproject-1/lib/arm64
02-06 02:57:39.995 23145-23145/project.rssi.beacon.com.beaconproject I/HwCust: Constructor found for class android.app.HwCustActivityImpl
02-06 02:57:40.002 23145-23145/project.rssi.beacon.com.beaconproject I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl
02-06 02:57:40.069 23145-23145/project.rssi.beacon.com.beaconproject I/BeaconManager: BeaconManager started up on pid 23145 named 'project.rssi.beacon.com.beaconproject' for application package 'project.rssi.beacon.com.beaconproject'. isMainProcess=true
02-06 02:57:40.072 23145-23145/project.rssi.beacon.com.beaconproject E/AndroidRuntime: FATAL EXCEPTION: main
Process: project.rssi.beacon.com.beaconproject, PID: 23145
java.lang.RuntimeException: Unable to start activity ComponentInfo{project.rssi.beacon.com.beaconproject/project.rssi.beacon.com.beaconproject.MainActivity}: org.altbeacon.beacon.BeaconManager$ServiceNotDeclaredException: The BeaconService is not properly declared in AndroidManifest.xml. If using Eclipse, please verify that your project.properties has manifestmerger.enabled=true
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2793)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6577)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Caused by: org.altbeacon.beacon.BeaconManager$ServiceNotDeclaredException: The BeaconService is not properly declared in AndroidManifest.xml. If using Eclipse, please verify that your project.properties has manifestmerger.enabled=true
at org.altbeacon.beacon.BeaconManager.verifyServiceDeclaration(BeaconManager.java:1213)
at org.altbeacon.beacon.BeaconManager.<init>(BeaconManager.java:321)
at org.altbeacon.beacon.BeaconManager.getInstanceForApplication(BeaconManager.java:310)
at project.rssi.beacon.com.beaconproject.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6910)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6577)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
02-06 02:57:40.081 23145-23145/project.rssi.beacon.com.beaconproject I/Process: Sending signal. PID: 23145 SIG: 9
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="project.rssi.beacon.com.beaconproject">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
</manifest>
代码没有问题,我猜,我认为这是 Android Studio 中的一种错误,但无法弄清楚。
根据治疗
You must create a class that extends Application (shown in the example) and then declare this in your AndroidManifest.xml.
因此创建一个 class 扩展应用程序 class 并将其添加到清单中。android:name="com.example.MyApplicationName"
也将此添加到您的 activity android:launchMode="singleInstance"
应用程序 class 的示例是:
public class MyApplicationName extends Application implements BootstrapNotifier {
private static final String TAG = ".MyApplicationName";
private RegionBootstrap regionBootstrap;
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "App started up");
BeaconManager beaconManager =
BeaconManager.getInstanceForApplication(this);
}
@Override
public void didDetermineStateForRegion(int arg0, Region arg1) {
// Don't care
}
@Override
public void didEnterRegion(Region arg0) {
regionBootstrap.disable();
Intent intent = new Intent(this, MainActivity.class);
// IMPORTANT: in the AndroidManifest.xml definition of this activity, you must set android:launchMode="singleInstance" or you will get two instances
// created when a user launches the activity manually and it gets launched from here.
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
@Override
public void didExitRegion(Region arg0) {
}
}
可以找到更多信息here