1

UPDATE: A UI bug was preventing me from importing google-play-services_lib. I had to click immediately below the SDK list to be able to scroll to see the Library box. See the image in the accepted answer for more info.

I am using Android IDE to get a Hello World map app, which I have named Intactless2. The files are all named correctly, android-support-v4.jar in /libs, I have a valid API key, etc.

I followed Google's Android Maps guide, copying and pasting the Java and activity_main.xml verbatim:

https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2

I correctly added everything there to my manifest. I got an error on <meta-data android:name="com.google.android.gms.version"... 's value being incorrect, so I hardcoded the integer from the version.xml file so that it's android:value="4030500". Otherwise my manifest is unchanged.

I tried all of the solutions in the top Google hits for the error messages I'm getting and it still won't run. Normally, this would indicate an idiosyncratic bug that I haven't thought about that might even be unrelated to Google Play Services, but I rebuilt it exactly as Google's guide suggests and redid all of the recommendations in those posts and still can't use Google Play Services.

I am running a 4.4 emulator and 4.4 is the minimum version my project will build to. I have tried the following to be able to use google-play-services/google-play-services_lib in my app:

1) Made an Eclipse project for Google Play Services and added it to my project. Right-click on my project -> Properties -> Java Build Path -> Projects Add -> google-play-services_lib. a) Checked google-play-services_lib in Order & Export b) Unchecked oogle-play-services_lib in Order and Export 2) Copy-pasted google-play-services, google-play-services_lib, and google-play-services.properties from my Android SDK directory to my /libs directory in my project.

1) Properties -> Android -> Target Build Path -> Android 4.4 2) Properties -> Android -> Target Build Path -> Google APIs (the one directly below "Android 4.4)

That's a lot of combinations including the solutions people on StackOverflow have suggested.

Also, if I add <uses-library android:name="com.google.android.gms.maps" /> (or remove the gms as some guides advise) to my manifest, I get this LogCat error:

11-13 00:57:18.890: E/PackageManager(938): Package com.example.intactless2 requires unavailable shared library com.google.android.gms.maps; failing!

Importing google-play-services/google-play-services_lib as an Eclipse project:

Screenshot of google-play-services_lib Eclipse project: http://postimg.org/image/ukbqjk9lp/

Screenshot of my hello world Maps project in Package Explorer: http://postimg.org/image/589t2137h/

Console output:

...
[2013-11-12 21:57:13 - Intactless2] Installing Intactless2.apk...
[2013-11-12 21:57:19 - Intactless2] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
[2013-11-12 21:57:19 - Intactless2] Please check logcat output for more details.
[2013-11-12 21:57:19 - Intactless2] Launch canceled!

LogCat:

11-13 01:03:44.870: E/AndroidRuntime(1886): FATAL EXCEPTION: main
11-13 01:03:44.870: E/AndroidRuntime(1886): Process: com.example.intactless2, PID: 1886
11-13 01:03:44.870: E/AndroidRuntime(1886): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.intactless2/com.example.intactless2.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
11-13 01:03:44.870: E/AndroidRuntime(1886):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
11-13 01:03:44.870: E/AndroidRuntime(1886):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
11-13 01:03:44.870: E/AndroidRuntime(1886):     at android.app.ActivityThread.access$700(ActivityThread.java:135)
...

Putting google-play-services.jar, google-play-services_lib.jar, and google-play-services.jar.properties directly into my project's /libs directory

Screenshot of my hello world Maps project in Package Explorer: http://postimg.org/image/l68z4crl7/

Console output:

...
[2013-11-12 22:15:20 - Intactless2] Uploading Intactless2.apk onto device 'emulator-5554'
[2013-11-12 22:15:20 - Intactless2] Installing Intactless2.apk...
[2013-11-12 22:15:37 - Intactless2] Success!
[2013-11-12 22:15:37 - Intactless2] Starting activity com.example.intactless2.MainActivity on device emulator-5554
[2013-11-12 22:15:41 - Intactless2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.intactless2/.MainActivity }

LogCat:

11-13 01:15:43.990: E/AndroidRuntime(1959): FATAL EXCEPTION: main
11-13 01:15:43.990: E/AndroidRuntime(1959): Process: com.example.intactless2, PID: 1959
11-13 01:15:43.990: E/AndroidRuntime(1959): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
11-13 01:15:43.990: E/AndroidRuntime(1959):     at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at android.app.Activity.onCreateView(Activity.java:4784)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at android.app.Activity.setContentView(Activity.java:1928)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at com.example.intactless2.MainActivity.onCreate(MainActivity.java:11)
11-13 01:15:43.990: E/AndroidRuntime(1959):     at android.app.Activity.performCreate(Activity.java:5243)

Thank you in advance! Any help is appreciated. :)

Community
  • 1
  • 1
JaneGoodall
  • 1,478
  • 2
  • 15
  • 22
  • did you reference the library project or add it as jar? – Raghunandan Nov 13 '13 at 06:46
  • I did both and posted the logs for both. Neither worked. – JaneGoodall Nov 13 '13 at 06:48
  • 1
    http://stackoverflow.com/questions/17611017/importing-google-play-service-library-showing-a-red-x-next-to-this-reference-and. check this if it helps – Raghunandan Nov 13 '13 at 06:48
  • @Raghunandan I wasn't copying the google-play-services_lib into my workspace but it didn't work when I did. I ran it twice, once with google-play-services_lib checked in Order and Export and once unchecked. I cleaned my project before each run. My logs (they were the same in both runs) are here: http://pastebin.com/jgP0hxbJ – JaneGoodall Nov 13 '13 at 06:58
  • what is not working? `java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable` usually happens if you do not reference the library project properly – Raghunandan Nov 13 '13 at 06:59
  • I think it's because google-play-services_lib is set up incorrectly too. Can you look at these screenshots? http://postimg.org/image/ukbqjk9lp/ and http://postimg.org/image/589t2137h/ – JaneGoodall Nov 13 '13 at 07:02
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/41073/discussion-between-raghunandan-and-janegoodall) – Raghunandan Nov 13 '13 at 07:03
  • @Raghunandan thanks for all your help. A UI bug was preventing me from importing google-play-services_lib into Intactless2 (my map project) as a library file. I had to click immediately below the SDK list to be able to scroll to see the Library box. – JaneGoodall Nov 13 '13 at 08:24

2 Answers2

0

You mentioned you are using a 4.4 emulator - you need to use the Google APIs (Google Inc.) - API Level 19 emulator to test with Google Play Services.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • i believe this `java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable` usually happens if you don't reference the library project properly – Raghunandan Nov 13 '13 at 06:56
0

I Think You have error in you XML file ,because in log-cat you are getting

 Binary XML file line #2: Error inflating class fragment first you try to rectify it
vinay Maneti
  • 1,447
  • 1
  • 23
  • 31