新到Android等。
所以我建议这个演示: http://dj-android.blogspot.in/2013/02/android-google-map-v2-part-1.html
我跟着它的事,但一定是出了问题。
...
- 在工作区中 ,我有我自己的项目:
- 这里面的项目:在“利布斯”我已经加入“Android的支持,v4.jar”
- 这里面的项目:在Android中Depencides我有“Android的支持,v4.jar”
- 这里面的项目:在引用库无我有“的Google Play-services.jar”
- 这里面的项目:在参考图书馆我有“Android的支持,v4.jar”
...
- 在工作区中我有谷歌,播放services_lib作为一个项目:
- 这里面的项目:在“利布斯”我有“的Google Play-services.jar”
- 这里面的项目:在“利布斯”我有“google-play-services.jar.properties”
- 这里面的项目:在“Android的依赖关系”无我有“的Google Play-services.jar”
...
当我运行上面的SGII V4.1.2项目,我得到黑屏,随后crasj如下错误:
03-09 00:28:49.957: E/AndroidRuntime(20309): FATAL EXCEPTION: main
03-09 00:28:49.957: E/AndroidRuntime(20309): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapstest/com.example.mapstest.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.access$700(ActivityThread.java:140)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.os.Looper.loop(Looper.java:137)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.main(ActivityThread.java:4921)
03-09 00:28:49.957: E/AndroidRuntime(20309): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 00:28:49.957: E/AndroidRuntime(20309): at java.lang.reflect.Method.invoke(Method.java:511)
03-09 00:28:49.957: E/AndroidRuntime(20309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
03-09 00:28:49.957: E/AndroidRuntime(20309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
03-09 00:28:49.957: E/AndroidRuntime(20309): at dalvik.system.NativeStart.main(Native Method)
03-09 00:28:49.957: E/AndroidRuntime(20309): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-09 00:28:49.957: E/AndroidRuntime(20309): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.Activity.setContentView(Activity.java:1924)
03-09 00:28:49.957: E/AndroidRuntime(20309): at com.microsystools.mapstest.MainActivity.onCreate(MainActivity.java:17)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.Activity.performCreate(Activity.java:5206)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
03-09 00:28:49.957: E/AndroidRuntime(20309): ... 11 more
03-09 00:28:49.957: E/AndroidRuntime(20309): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
03-09 00:28:49.957: E/AndroidRuntime(20309): ... 21 more
03-09 00:28:49.957: E/AndroidRuntime(20309): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment
03-09 00:28:49.957: E/AndroidRuntime(20309): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-09 00:28:49.957: E/AndroidRuntime(20309): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-09 00:28:49.957: E/AndroidRuntime(20309): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-09 00:28:49.957: E/AndroidRuntime(20309): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
03-09 00:28:49.957: E/AndroidRuntime(20309): ... 24 more
activity_main.xml中:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/fragment1"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
MainActivity.Java
package com.example.mapstest;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle arg0) {
// TODO Auto-generated method stub
super.onCreate(arg0);
setContentView(R.layout.activity_main);
}
}
注1:
请你们相信的也可以是相关的以某种方式API密钥的问题吗? 我用这个作为API密钥:
HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH;com.exampledomain.exampleproject
- 注意结局。 那是对的吗?
- 我不得不编辑从keytool的输出,所以不是100%肯定的API密钥是好的。 请参阅: Android版Google地图版API密钥
笔记2:
我的当前配置的一些截图:
如果你认为我的问题的原因是,谷歌Play服务没有正确安装,我创建了一个单独的SO对于以: 无法安装谷歌播放服务到Eclipse正确(试图让工作图)