簡體   English   中英

google-play-services不會在Eclipse的Android Maps HelloWorld項目中內置

[英]google-play-services won't build into Android Maps HelloWorld project in Eclipse

更新:一個UI錯誤阻止我導入google-play-services_lib。 我必須立即單擊SDK列表下方的內容,才能滾動查看“庫”框。 有關更多信息,請參見接受的答案中的圖像

我正在使用Android IDE來獲取Hello World地圖應用程序,該應用程序名為Intactless2。 這些文件都正確命名,在/ libs中為android-support-v4.jar,我具有有效的API密鑰,等等。

我遵循Google的Android地圖指南,逐字復制並粘貼Java和activity_main.xml:

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

我正確地將所有內容添加到清單中。 我在<meta-data android:name="com.google.android.gms.version" ...的值中出現錯誤,因此我從version.xml文件中對整數進行了硬編碼,使其成為android:value="4030500" 否則我的清單不變。

我嘗試了Google熱門歌曲中的所有解決方案,以獲取我收到的錯誤消息,但仍然無法運行。 通常,這表示我從未考慮過的特有錯誤,甚至可能與Google Play服務無關,但我完全按照Google指南的建議對其進行了重新構建,並重新編寫了這些帖子中的所有建議,但仍然無法使用Google播放服務。

我正在運行一個4.4模擬器,而4.4是我的項目要構建的最低版本。 我已經嘗試了以下方法,以便能夠在我的應用中使用google-play-services / google-play-services_lib:

1)為Google Play服務創建一個Eclipse項目,並將其添加到我的項目中。 右鍵單擊我的項目->屬性-> Java構建路徑->項目添加-> google-play-services_lib。 a)在訂單和導出中選中了google-play-services_lib b)在訂單和導出中選中了oogle-play-services_lib 2)從以下位置復制粘貼了google-play-services,google-play-services_lib和google-play-services.properties我的Android SDK目錄到我項目中的/ libs目錄。

1)屬性-> Android->目標構建路徑-> Android 4.4 2)屬性-> Android->目標構建路徑-> Google API(“ Android 4.4”正下方)

這是很多組合,包括StackOverflow上的人們建議的解決方案。

另外,如果我在清單中添加<uses-library android:name="com.google.android.gms.maps" /> (或刪除某些指南建議的gms),則會收到此LogCat錯誤:

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

將google-play-services / google-play-services_lib導入為Eclipse項目:

google-play-services_lib Eclipse項目的屏幕截圖: http : //postimg.org/image/ukbqjk9lp/

我在Package Explorer中的hello world Maps項目的屏幕快照: http : //postimg.org/image/589t2137h/

控制台輸出:

...
[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)
...

將google-play-services.jar,google-play-services_lib.jar和google-play-services.jar.properties直接放入我項目的/ libs目錄中

我在Package Explorer中的hello world Maps項目的屏幕快照: http : //postimg.org/image/l68z4crl7/

控制台輸出:

...
[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)

先感謝您! 任何幫助表示贊賞。 :)

您提到您正在使用4.4模擬器-您需要使用Google APIs (Google Inc.) - API Level 19模擬器來測試Google Play服務。

我認為您的XML文件中有錯誤,因為在log-cat中,

 Binary XML file line #2: Error inflating class fragment first you try to rectify it

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM