简体   繁体   中英

Running Geofence app on android emulator

Is there a way to run the sample Geofence app provided on the Android emulator: http://developer.android.com/training/location/geofencing.html

The app shuts down on initiation and I get these error messages on LogCat:

05-28 11:54:35.397: E/AndroidRuntime(847): FATAL EXCEPTION: main
05-28 11:54:35.397: E/AndroidRuntime(847): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.geofence/com.example.android.geofence.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.android.geofence.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.geofence-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.geofence-2, /system/lib]]
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.os.Looper.loop(Looper.java:137)
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.app.ActivityThread.main(ActivityThread.java:5103)
05-28 11:54:35.397: E/AndroidRuntime(847):  at java.lang.reflect.Method.invokeNative(Native Method)
05-28 11:54:35.397: E/AndroidRuntime(847):  at java.lang.reflect.Method.invoke(Method.java:525)
05-28 11:54:35.397: E/AndroidRuntime(847):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-28 11:54:35.397: E/AndroidRuntime(847):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-28 11:54:35.397: E/AndroidRuntime(847):  at dalvik.system.NativeStart.main(Native Method)
05-28 11:54:35.397: E/AndroidRuntime(847): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.geofence.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.android.geofence-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.geofence-2, /system/lib]]
05-28 11:54:35.397: E/AndroidRuntime(847):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
05-28 11:54:35.397: E/AndroidRuntime(847):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-28 11:54:35.397: E/AndroidRuntime(847):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
05-28 11:54:35.397: E/AndroidRuntime(847):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
05-28 11:54:35.397: E/AndroidRuntime(847):  ... 11 more

Seems like your MainActivity can't be found. Maybe you do not have it mentioned in your Manifest.xml file?

Besides that: there is actually no point in getting the geofencing App to run in the emulator. Androids Geofencing API is heavily based on network positioning and the emulator just supports GPS. So even though you could make the App run on the emulator creating geofences would fail with other exceptions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM