You can use the Baidu map SDK to run the demo, but you may encounter problems when using your own program:
The following error is reported:
- 07-27 10:31:59. 501: E/androidruntime (8282): Fatal exception: Main
- 10:31:59-27. 501: E/androidruntime (8282): Java. lang. runtimeexception: unable to start activity componentinfo {COM. casper. UI/COM. casper. subui. trans_location}: Android. view. inflateexception: Binary XML file line #6: Error inflating class COM. baidu. mapapi. map. mapview
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 2306)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. handlelaunchactivity (activitythread. Java: 2358)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. Access $600 (activitythread. Java: 156)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread $ H. handlemessage (activitythread. Java: 1340)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. OS. handler. dispatchmessage (handler. Java: 99)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. OS. Looper. Loop (Looper. Java: 153)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. Main (activitythread. Java: 5297)
- 07-27 10:31:59. 501: E/androidruntime (8282): At java. Lang. Reflect. method. invokenative (native method)
- 07-27 10:31:59. 501: E/androidruntime (8282): At java. Lang. Reflect. method. Invoke (method. Java: 511)
- 07-27 10:31:59. 501: E/androidruntime (8282): At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 833)
- 07-27 10:31:59. 501: E/androidruntime (8282): At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 600)
- 07-27 10:31:59. 501: E/androidruntime (8282): At Dalvik. system. nativestart. Main (native method)
- 10:31:59-27. 501: E/androidruntime (8282): caused by: Android. view. inflateexception: Binary XML file line #6: Error inflating class COM. baidu. mapapi. map. mapview
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. createview (layoutinflater. Java: 613)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. createviewfromtag (layoutinflater. Java: 687)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. rinflate (layoutinflater. Java: 746)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. Inflate (layoutinflater. Java: 489)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. Inflate (layoutinflater. Java: 396)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. Inflate (layoutinflater. Java: 352)
- 07-27 10:31:59. 501: E/androidruntime (8282): At com. Android. Internal. Policy. impl. phonewindow. setcontentview (phonewindow. Java: 274)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activity. setcontentview (activity. Java: 1881)
- 07-27 10:31:59. 501: E/androidruntime (8282): At com. Casper. subui. trans_location.oncreate (trans_location.java: 51)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activity. Wait mcreate (activity. Java: 5122)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. instrumentation. callactivityoncreate (instrumentation. Java: 1081)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 2270)
- 07-27 10:31:59. 501: E/androidruntime (8282):... 11 more
- 07-27 10:31:59. 501: E/androidruntime (8282): caused by: Java. Lang. Reflect. invocationtargetexception
- 07-27 10:31:59. 501: E/androidruntime (8282): At java. Lang. Reflect. constructor. constructnative (native method)
- 07-27 10:31:59. 501: E/androidruntime (8282): At java. Lang. Reflect. constructor. newinstance (constructor. Java: 417)
- 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. createview (layoutinflater. Java: 587)
- 07-27 10:31:59. 501: E/androidruntime (8282):... 22 more
- 10:31:59-27. 501: E/androidruntime (8282): caused by: Java. lang. illegalstateexception: You have not supplyed the global app context info from sdkinitializer. initialize (context) function.
- 07-27 10:31:59. 501: E/androidruntime (8282): At com. Baidu. mapapi. A. B (unknown source)
- 07-27 10:31:59. 501: E/androidruntime (8282): At com. Baidu. mapapi. Map. mapview. A (unknown source)
- 07-27 10:31:59. 501: E/androidruntime (8282): At com. Baidu. mapapi. Map. mapview. <init> (unknown source)
- 07-27 10:31:59. 501: E/androidruntime (8282):... 25 more
I checked it online for one day and couldn't solve it.
There are many reasons for such errors on the Internet:
1. Baidu's. jar package imported, because the Baidu map used is a third-party, you need to write it to a self-created libs folder, and put it in. the OS file is also placed below.
2. Use Android. Support. v4.app. fragmentactivity instead of Android. App. fragmentactivity to inherit fragmentactivity.
3. Because the compilation is not successful, you may need to clean the project.
4. It is impossible to put the applied Baidu map key in the manifest. xml file.
However, none of my errors are the above problems. In Baidu map demo, there is an application class, which is a class for configuring the entire application. You must define this class when using it, at the same time, we need to put this class in manifest. description in the XML file:
- <Application
- Android: Name = "com. Casper. applicationconfig. applicationconfig"
- Android: debuggable = "true"
- Android: allowbackup = "true"
- Android: icon = "@ drawable/ic_launcher"
- Android: Label = "@ string/app_name"
Android: theme = "@ style/apptheme">
Encountered the same problem and this reprinted over: http://blog.csdn.net/u010428517/article/details/38168219? Reload
Problems encountered during Baidu map development (1)