Problems encountered during Baidu map development (1)

Source: Internet
Author: User

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:

 

  1. 07-27 10:31:59. 501: E/androidruntime (8282): Fatal exception: Main
  2. 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
  3. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 2306)
  4. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. handlelaunchactivity (activitythread. Java: 2358)
  5. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. Access $600 (activitythread. Java: 156)
  6. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread $ H. handlemessage (activitythread. Java: 1340)
  7. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. OS. handler. dispatchmessage (handler. Java: 99)
  8. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. OS. Looper. Loop (Looper. Java: 153)
  9. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. Main (activitythread. Java: 5297)
  10. 07-27 10:31:59. 501: E/androidruntime (8282): At java. Lang. Reflect. method. invokenative (native method)
  11. 07-27 10:31:59. 501: E/androidruntime (8282): At java. Lang. Reflect. method. Invoke (method. Java: 511)
  12. 07-27 10:31:59. 501: E/androidruntime (8282): At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 833)
  13. 07-27 10:31:59. 501: E/androidruntime (8282): At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 600)
  14. 07-27 10:31:59. 501: E/androidruntime (8282): At Dalvik. system. nativestart. Main (native method)
  15. 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
  16. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. createview (layoutinflater. Java: 613)
  17. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. createviewfromtag (layoutinflater. Java: 687)
  18. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. rinflate (layoutinflater. Java: 746)
  19. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. Inflate (layoutinflater. Java: 489)
  20. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. Inflate (layoutinflater. Java: 396)
  21. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. Inflate (layoutinflater. Java: 352)
  22. 07-27 10:31:59. 501: E/androidruntime (8282): At com. Android. Internal. Policy. impl. phonewindow. setcontentview (phonewindow. Java: 274)
  23. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activity. setcontentview (activity. Java: 1881)
  24. 07-27 10:31:59. 501: E/androidruntime (8282): At com. Casper. subui. trans_location.oncreate (trans_location.java: 51)
  25. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activity. Wait mcreate (activity. Java: 5122)
  26. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. instrumentation. callactivityoncreate (instrumentation. Java: 1081)
  27. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. App. activitythread. initialize mlaunchactivity (activitythread. Java: 2270)
  28. 07-27 10:31:59. 501: E/androidruntime (8282):... 11 more
  29. 07-27 10:31:59. 501: E/androidruntime (8282): caused by: Java. Lang. Reflect. invocationtargetexception
  30. 07-27 10:31:59. 501: E/androidruntime (8282): At java. Lang. Reflect. constructor. constructnative (native method)
  31. 07-27 10:31:59. 501: E/androidruntime (8282): At java. Lang. Reflect. constructor. newinstance (constructor. Java: 417)
  32. 07-27 10:31:59. 501: E/androidruntime (8282): at Android. View. layoutinflater. createview (layoutinflater. Java: 587)
  33. 07-27 10:31:59. 501: E/androidruntime (8282):... 22 more
  34. 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.
  35. 07-27 10:31:59. 501: E/androidruntime (8282): At com. Baidu. mapapi. A. B (unknown source)
  36. 07-27 10:31:59. 501: E/androidruntime (8282): At com. Baidu. mapapi. Map. mapview. A (unknown source)
  37. 07-27 10:31:59. 501: E/androidruntime (8282): At com. Baidu. mapapi. Map. mapview. <init> (unknown source)
  38. 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:

 

    1. <Application
    2. Android: Name = "com. Casper. applicationconfig. applicationconfig"
    3. Android: debuggable = "true"
    4. Android: allowbackup = "true"
    5. Android: icon = "@ drawable/ic_launcher"
    6. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.