二进制XML文件行#1 - 错误膨胀类片段

时间:2016-05-31 17:11:12

标签: java android xml android-fragments

我正在按照以下教程获取活动中的地图:

https://developers.google.com/maps/documentation/android-api/start#step_5_hello_map_take_a_look_at_the_code

public class MapActivity extends FragmentActivity implements OnMapReadyCallback {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);

    }

    @Override
    public void onMapReady(GoogleMap map) {
        // Add a marker in Sydney, Australia, and move the camera.
        LatLng sydney = new LatLng(-34, 151);
        map.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
        map.moveCamera(CameraUpdateFactory.newLatLng(sydney));

    }
}

XML:

<fragment 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"
android:id="@+id/map"
tools:context="com.example.app.app.fragments.travel.MapActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />

ERROR:

FATAL EXCEPTION: main
Process: com.example.app.app, PID: 7265
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.app/com.example.app.app.fragments.travel.MapActivity}: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class fragment
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5422)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 Caused by: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class fragment
    at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
    at android.app.Activity.setContentView(Activity.java:2172)
    at com.example.app.app.fragments.travel.MapActivity.onCreate(MapActivity.java:19)
    at android.app.Activity.performCreate(Activity.java:6251)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5422) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
 Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
    at android.app.Activity.setContentView(Activity.java:2172) 
    at com.example.app.app.fragments.travel.MapActivity.onCreate(MapActivity.java:19) 
    at android.app.Activity.performCreate(Activity.java:6251) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5422) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
 Caused by: java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
    at maps.z.k.a(Unknown Source)
    at maps.x.c.a(Unknown Source)
    at com.google.android.gms.maps.internal.CreatorImpl.b(Unknown Source)
    at com.google.android.gms.maps.internal.CreatorImpl.newMapFragmentDelegate(Unknown Source)
    at uw.onTransact(:com.google.android.gms.DynamiteModulesB:62)
    at android.os.Binder.transact(Binder.java:387)
    at rde.newMapFragmentDelegate(SourceFile:179)
    at com.google.android.gms.maps.internal.CreatorImpl.newMapFragmentDelegate(SourceFile:101)
    at rdd.onTransact(SourceFile:62)
    at android.os.Binder.transact(Binder.java:387)
    at com.google.android.gms.maps.internal.zzc$zza$zza.zzs(Unknown Source)
    at com.google.android.gms.maps.SupportMapFragment$zzb.zzzW(Unknown Source)
    at com.google.android.gms.maps.SupportMapFragment$zzb.zza(Unknown Source)
    at com.google.android.gms.dynamic.zza.zza(Unknown Source)
    at com.google.android.gms.dynamic.zza.onInflate(Unknown Source)
    at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
    at android.support.v4.app.Fragment.onInflate(Fragment.java:1142)
    at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2287)
    at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
    at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:357)
    at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:31)
    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:80)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:754)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
    at android.app.Activity.setContentView(Activity.java:2172) 
    at com.example.app.app.fragments.travel.MapActivity.onCreate(MapActivity.java:19) 
    at android.app.Activity.performCreate(Activity.java:6251) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5422) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app.app"
android:versionCode="37"
android:versionName="1.2">

<uses-sdk
    android:minSdkVersion="13"
    android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<!-- To retrieve the account name (email) as part of sign-in: -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<permission
    android:name="com.example.app.app.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<permission
    android:name="com.example.app.app.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.app.app.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />

<!-- Allow you to get LOGCAT information when a crash occurs. -->
<uses-permission android:name="android.permission.READ_LOGS" />
<!-- Allow you to see which activity was active when a crash occurs. -->
<uses-permission android:name="android.permission.GET_TASKS" />
<!-- Allows location to be tracked -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<android:uses-permission
    android:name="android.permission.READ_EXTERNAL_STORAGE"
    android:maxSdkVersion="18" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.MyTheme">
    <activity
        android:name=".LoginSlider"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateVisible" />
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.NewRecipientActivity"
        android:label="@string/new_recipient"
        android:parentActivityName=".MainActivity"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.app.app.MainActivity" />
    </activity>

    <!--
        <meta-data
        android:name="com.google.android.gms.version"
        android:value="32424234" />
    -->

    <activity
        android:name=".Activities.Register"
        android:label="@string/title_activity_register"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.EditProfileActivity"
        android:label="Edit Profile"
        android:parentActivityName=".MainActivity"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.app.app.MainActivity" />
    </activity>
    <activity
        android:name=".Activities.ReviewTransactionActivity"
        android:label="Review Transaction"
        android:parentActivityName=".MainActivity"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.app.app.MainActivity" />
    </activity>
    <activity
        android:name=".Activities.EditBeneficiaryActivity"
        android:label="Edit Beneficiary"
        android:parentActivityName=".Activities.ReviewTransactionActivity"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.app.app.Activities.ReviewTransactionActivity" />
    </activity>
    <activity
        android:name=".Activities.TransDetailActivity"
        android:label="Transaction Details"
        android:parentActivityName=".Activities.ReviewTransactionActivity"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.app.app.Activities.ReviewTransactionActivity" />
    </activity>
    <activity
        android:name=".Activities.PayActivity"
        android:label="Pay Transaction"
        android:parentActivityName=".Activities.ReviewTransactionActivity"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.app.app.Activities.ReviewTransactionActivity" />
    </activity>
    <activity
        android:name=".Activities.CommentsActivity"
        android:label="Transaction Comments"
        android:parentActivityName=".Activities.TransDetailActivity"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.app.app.Activities.TransDetailActivity" />
    </activity>
    <activity
        android:name=".Activities.AddRecievingMethodActivity"
        android:label="Add New Recieving Method"
        android:parentActivityName=".Activities.EditBeneficiaryActivity"
        android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.app.app.Activities.EditBeneficiaryActivity" />
    </activity>
    <activity
        android:name=".Activities.ViewPDF"
        android:label="@string/title_activity_view_pdf"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.ChangePasswordActivity"
        android:label="Change Password"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.PayWalletActivity"
        android:label="Wallet Pay"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.AddCompanyActivity"
        android:label="Add Company"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.CompanyActivity"
        android:label="Associated Companies"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.EditCompanyActivity"
        android:label="Company Details"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.PayWebViewActivity"
        android:label="Interac Payment"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.WebViewActivity"
        android:label="Overseas Receipt"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.IdDetailsActivity"
        android:label="Verification Required"
        android:screenOrientation="portrait" />

    <receiver
        android:name="com.google.android.gcm.GCMBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>

            <!-- Receives the actual messages. -->
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <!-- Receives the registration id. -->
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="com.example.app.app" />
        </intent-filter>
    </receiver>

    <service android:name=".GCMIntentService" />

    <activity
        android:name=".Activities.NoBackTrack"
        android:label="@string/title_activity_no_back_track" />

    <meta-data
        android:name="io.fabric.ApiKey"
        android:value="27346gfd823tr87gf837g7368gf3f63" />

    <activity
        android:name=".SplashScreen"
        android:label="@string/app_name"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Activities.PayWebViewDebitActivity"
        android:label="@string/title_activity_pay_web_view_debit"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.BankStatement"
        android:label="@string/title_activity_bank_statement"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.NewBeneficiaryActivity"
        android:label="@string/title_activity_new_beneficiary" />
    <activity
        android:name=".Activities.EditBeneficiaryActivityNew"
        android:label="@string/title_activity_edit_beneficiary_activity_new"
        android:screenOrientation="portrait" />
    <activity
        android:name=".MyService"
        android:label="@string/title_activity_my_service" />
    <activity
        android:name=".Activities.UploadId"
        android:label="@string/title_activity_upload_id"
        android:screenOrientation="portrait" />
    <activity
        android:name=".Activities.UserVerification"
        android:label="User Verification"
        android:screenOrientation="portrait" />
    <activity
        android:name=".fragments.travel.TravelAmountActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".fragments.travel.MapActivity"
        android:label="@string/title_activity_map"
        android:theme="@style/Theme.MyTheme.NoActionBar"></activity>


    <meta-data android:name="com.google.android.geo.API_KEY" android:value="my_key"/>
</application>
</manifest>

0 个答案:

没有答案