当前位置: 首页 > 知识库问答 >
问题:

无法实例化com.google.android.gms.maps.MapsFragment

姚昊焱
2023-03-14

我在MapFragment的布局文件中出现了这个错误

我试过了

>

  • 安装Google Play服务,但仍有错误

    - com.google.android.gms.maps.MapFragment(开放类,显示异常,清除缓存)

    提示:在自定义视图中使用view.isinEditMode()跳过代码或在IDE中显示示例数据。

    如果这是一个意外错误,您也可以尝试构建项目,然后手动刷新布局。

    异常详细信息

      null
    <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="layout.ContactFragment">
    
    
        <com.google.android.gms.maps.MapFragment
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/mapFragment"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true" />
    </RelativeLayout>
    
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.ng.anthony.mininavigationdrawer" >
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
        <permission
            android:name="com.example.permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>
        <uses-permission android:name="com.example.permission.MAPS_RECEIVE"/>
    
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/AppTheme"
            android:screenOrientation="portrait">
            <activity
                android:name="com.th.ac.sd.MainActivity"
                android:label="@string/app_name"
                android:theme="@style/AppTheme.NoActionBar" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    
    </manifest>
    

    build.gradle(应用程序)

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 25
        buildToolsVersion "23.0.2"
        0
        defaultConfig {
            applicationId "com.th.ac.sd"
            minSdkVersion 21
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:25.2.0'
        compile 'com.android.support:design:25.2.0'
        compile 'com.android.support:support-v4:25.2.0'
        testCompile 'junit:junit:4.12'
        compile 'com.google.android.gms:play-services-maps:10.2.0'
    }
    

    已安装的SDK工具

  • 共有1个答案

    刘凡
    2023-03-14
    tools:context="layout.ContactFragment">
    
        <com.google.android.gms.maps.MapFragment
    

    你有一个碎片中的一个碎片。

    Android并不喜欢这样,所以无论您在哪里放置 (假设您这样做了),都可以用Google Map片段替换它,因为在这个contactfragment中唯一的视图就是Map片段。

    否则,您可以使用FrameLayout并像任何其他片段一样动态加载新的SupportMapFragment

     类似资料:
    • 我试图使用Postgis 2.2和Postgreql 9.5与JPA,Postgis 9.5方言。我已经在pom.xml的要求,按这里http://www.hibernatespatial.org/documentation/documentation/和类型导入正确,但是当我试图运行程序使用几何类型我得到这个错误: 我显然遗漏了一些配置,有人能指出是什么吗?

    • 我正在将一个Java EE应用程序部署到Bluemix,当第一个请求到达时,我得到了这个错误: 2015-05-20T23:11:58.51+0200[app/0]OUT[INFO]FFDC1015I:已创建FFDC事件:“java.util.ServiceConfigurationError:javax.servlet.ServletContainerInitializer:Provider o

    • 我正在尝试将H2设置为内存数据库。我已将其配置为: 然而,当我尝试运行它时,我会遇到这个错误 我不确定它为什么不接受jdbc url,我的confg格式有什么问题吗?

    • 我想使用我的本地代码通过spark-sql连接到远程配置单元。这是我的代码: 请帮帮我.

    • 我试图在Angular2应用程序中实例化一个对象,以便在我正在开发的组件中使用。 这个代码段在RC5中运行良好。现在我正在尝试升级到Angular2最终版本,并在运行<code>ng serve</code>或<code>ng build</code>时出现此错误, 如何解决此问题?是否有另一种实例化管道的方法?或者Angular是否停止支持组件内部管道的实例化?