The app I have created loads fine, but every time I try to open the map activity from within, it crashes.. Can anyone see where I am going wrong? I am relatively new to Android and still trying to get my head around activities and intents...
07-28 16:18:37.042 189-22520/? E/ACDB-LOADER﹕ Error: ACDB AudProc vol returned = -19
07-28 16:18:38.601 189-22597/? E/ACDB-LOADER﹕ Error: ACDB AudProc vol returned = -19
07-28 16:18:39.061 724-841/? E/WifiStateMachine﹕ cancelDelayedScan -> 2691
07-28 16:18:39.062 724-841/? E/native﹕ do suspend true
07-28 16:18:39.797 1839-1840/? E/ANDR-PERF-LOCK﹕ Failed to apply optimization for resource: 4 level: 0
07-28 16:21:24.404 22719-22751/? E/SQLiteLog﹕ (1) no such table: mmsconfig
07-28 16:21:24.409 22719-22751/? E/Babel﹕ canonicalizeMccMnc: invalid mccmnc nullnull
07-28 16:26:45.488 724-841/? E/WifiStateMachine﹕ cancelDelayedScan -> 2692
07-28 16:26:45.489 724-841/? E/native﹕ do suspend false
07-28 16:26:45.628 1839-1840/? E/ANDR-PERF-LOCK﹕ Failed to reset optimization for resource: 4 level: 0
07-28 16:26:55.605 724-841/? E/WifiStateMachine﹕ cancelDelayedScan -> 2693
07-28 16:26:55.606 724-841/? E/native﹕ do suspend true
07-28 16:26:56.338 1839-1840/? E/ANDR-PERF-LOCK﹕ Failed to apply optimization for resource: 4 level: 0
07-28 16:29:08.282 724-841/? E/WifiStateMachine﹕ cancelDelayedScan -> 2694
07-28 16:29:08.288 724-841/? E/native﹕ do suspend false
07-28 16:40:07.390 1321-1321/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
07-28 16:40:07.390 1321-1321/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
07-28 16:40:07.967 24924-24924/? E/SysUtils﹕ ApplicationContext is null in ApplicationStatus
07-28 16:40:08.680 25040-25085/? E/ActivityThread﹕ Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
07-28 16:40:08.859 1704-2415/? E/MDM﹕ [151] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}
07-28 16:40:09.894 24793-24793/ribbit.khackett.com.ribbit E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: ribbit.khackett.com.ribbit, PID: 24793
java.lang.RuntimeException: Unable to start activity ComponentInfo{ribbit.khackett.com.ribbit/ribbit.khackett.com.ribbit.MapPolylineActivity}: android.view.InflateException: Binary XML file line #43: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #43: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
at android.app.Activity.setContentView(Activity.java:2145)
at ribbit.khackett.com.ribbit.MapPolylineActivity.onCreate(MapPolylineActivity.java:50)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
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 com.google.maps.api.android.lib6.d.fk.a(Unknown Source)
at com.google.maps.api.android.lib6.a.g.a(Unknown Source)
at com.google.android.gms.maps.internal.CreatorImpl.b(Unknown Source)
at com.google.android.gms.maps.internal.CreatorImpl.b(Unknown Source)
at com.google.android.gms.maps.internal.i.onTransact(SourceFile:62)
at android.os.Binder.transact(Binder.java:380)
at com.google.android.gms.maps.internal.zzc$zza$zza.zzr(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$zzb.zzvu(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.FragmentManagerImpl.onCreateView(FragmentManager.java:2169)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
at android.app.Activity.setContentView(Activity.java:2145)
at ribbit.khackett.com.ribbit.MapPolylineActivity.onCreate(MapPolylineActivity.java:50)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
07-28 16:40:19.002 724-832/? E/InputDispatcher﹕ channel '378b103b ribbit.khackett.com.ribbit/ribbit.khackett.com.ribbit.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
07-28 16:40:19.020 189-25259/? E/ACDB-LOADER﹕ Error: ACDB AudProc vol returned = -19
07-28 16:40:20.497 189-25333/? E/ACDB-LOADER﹕ Error: ACDB AudProc vol returned = -19
07-28 16:40:20.785 724-841/? E/WifiStateMachine﹕ cancelDelayedScan -> 2705
07-28 16:40:20.786 724-841/? E/native﹕ do suspend true
07-28 16:40:21.635 1839-1840/? E/ANDR-PERF-LOCK﹕ Failed to apply optimization for resource: 4 level: 0
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="ribbit.khackett.com.ribbit"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera" android:required="true"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:name=".RibbitApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/google_maps_key" />
<!-- android:theme="@style/AppTheme" -->
<activity
android:name=".MainActivity"
android:label="@string/title_activity_maps"
android:parentActivityName=".MainActivity"
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=".MapPolylineActivity"
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=".LoginActivity"
android:label="@string/title_activity_login"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".SignUpActivity"
android:label="@string/title_activity_sign_up"
android:parentActivityName=".LoginActivity"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".EditFriendsActivity"
android:label="@string/title_activity_edit_friends"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ribbit.khackett.com.ribbit.MainActivity"/>
</activity>
</application>
</manifest>
Layout file:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="@+id/TFAddress"
android:layout_width="231dp"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/Bsearch"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:onClick="onSearch"
android:text="Search"/>
<Button
android:id="@+id/Btype"
style="?android:attr/buttonStyleSmall"
android:layout_width="74dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:onClick="changeType"
android:text="Type"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="349dp"
android:layout_height="469dp"
tools:context=".MapPolylineActivity"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</LinearLayout>
Also, line 50 of is MapPolylineActivity is: setContentView(R.layout.activity_maps);
答案 0 :(得分:1)
First register your app in google developer console and then enable required apis for your app, then define below part in your manifest as follows:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_API_KEY" />
For more help, refer to this link:
http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/
答案 1 :(得分:0)
First at all try to check your API Key to solve that error:
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
Use this: https://developers.google.com/maps/documentation/android/signup