无法实例android.gms.maps.SupportMapFragment [英] Unable to instantiate android.gms.maps.SupportMapFragment
问题描述
我有一个Facebook风格的侧栏导航视图。在主视图我想显示我的地图。我按照谷歌的教程完全相同!但我一直运行到错误无法实例android.gms.maps.SupportMapFragment。
I have a view with a facebook style side bar navigation. On the main view I want to display my map. I have followed Google's tutorial exactly! But I keep running into the error Unable to instantiate android.gms.maps.SupportMapFragment.
我还是设法在一个普通的项目运行如下命令,但是当我跟我的主要项目进行合并这个错误弹出:
I did manage to run this on a plain project but when I merge it with my main project this error pops up:
07-25 13:27:53.778: E/AndroidRuntime(24841):
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
我试过下面张贴的答案,但问题仍然存在。
I tried the answers posted below but the problem persists.
<一个href=\"http://stackoverflow.com/questions/14082851/error-inflating-class-fragment-with-google-map\">"Error充气类片段QUOT;与谷歌地图
和也这一个:
<一个href=\"http://stackoverflow.com/questions/16572020/error-java-lang-classnotfoundexception-com-google-android-gms-maps-mapfragment\">Error抛出java.lang.ClassNotFoundException:com.google.android.gms.maps.MapFragment在谷歌地图V2
在项目属性为谷歌SDK中的参考也被设置。
这里是类:
The reference to the google sdk in project properties is also set. Here is the class:
public class SlideAnimationThenCallLayout extends FragmentActivity implements AnimationListener {
View menu;
View app;
boolean menuOut = false;
AnimParams animParams = new AnimParams();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_slide_animation_then_call_layout);
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.menu);
linearLayout.setOnTouchListener(new OnSwipeTouchListener(){
public void onSwipeRight() {
swipeAnimation();
}
});
RelativeLayout listview3 = (RelativeLayout) findViewById(R.id.relativeLayout1);
listview3.setOnTouchListener(new OnSwipeTouchListener(){
public void onSwipeRight() {
swipeAnimation();
}
public void onSwipeLeft() {
swipeAnimation();
}
});
menu = findViewById(R.id.menu);
app = findViewById(R.id.relativeLayout1);
}
XML文件是:
The xml file is:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame_layout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/menu"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView3"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/action_eating">
</ListView>
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/android_homescreen">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
我不知道什么是错在这里了。任何帮助将大大AP preciated。
I don't know what is wrong here now. Any Help would be greatly appreciated.
推荐答案
由你判断错误:
产生的原因:android.support.v4.app.Fragment $ InstantiationException:无法实例片段com.google.android.gms.maps.SupportMapFragment:
确保类名存在,是公开的,有一个空的构造是公共
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
和事实的 SupportManFragment
类的<code>的Google Play服务库,你的问题是surtenly部分在你的方式引用该库或库它的自我。
and the fact the SupportManFragment
class is part of the google-play-services
library, you problem is surtenly in the way you reference this library or the library it self.
我会建议你使用SDK管理器重新下载它,将它移动到它的路径将更短,然后尝试引用它再次使用你这个问题有答案了一个位置:
I would suggest you to re-download it using the SDK-Manager and move it to a location where it path would be shorter and then try to reference it again using the answer you have in this question:
<一个href=\"http://stackoverflow.com/questions/16572020/error-java-lang-classnotfoundexception-com-google-android-gms-maps-mapfragment\">Error抛出java.lang.ClassNotFoundException:com.google.android.gms.maps.MapFragment在谷歌地图V2
这篇关于无法实例android.gms.maps.SupportMapFragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!