I am building an app and am trying to use Aeris weather Api. I followed the tutorial they provided but am getting the same error. Here is the code
fragment_map.xml
<FrameLayout 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="com.example.rohan.weatherapp.MapFragment"> <!-- TODO: Update blank fragment layout --> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:text="@string/hello_blank_fragment" /> <com.hamweather.aeris.maps.AerisMapView android:id="@+id/aerisfragment_map" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </com.hamweather.aeris.maps.AerisMapView> </FrameLayout> activity_map.xml
<?xml version="1.0" encoding="utf-8"?> <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" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.example.rohan.weatherapp.MapActivity"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:id="@+id/MapFrame"></FrameLayout> </RelativeLayout> MapActivity.java
public class MapActivity extends AppCompatActivity implements MapFragment.OnFragmentInteractionListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); AerisEngine.initWithKeys(this.getString(R.string.AerisId), this.getString(R.string.AerisKey), this); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); //add a fragment MapFragment myFragment = new MapFragment(); fragmentTransaction.add(R.id.MapFrame, myFragment); fragmentTransaction.commit(); } public void onFragmentInteraction(Uri uri) { } } MapFragment.java
public class MapFragment extends MapViewFragment implements OnAerisMapLongClickListener,OnAerisMarkerInfoWindowClickListener,AerisCallback { ..... ..... public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment // return inflater.inflate(R.layout.fragment_map, container, false); View view = inflater.inflate(R.layout.fragment_map, container, false); //LINE 112 mapView = (AerisMapView)view.findViewById(R.id.aerisfragment_map); mapView.init(savedInstanceState, AerisMapType.GOOGLE); initMap(); // setHasOptionsMenu(true); return view; } private void initMap() { mapView.moveToLocation(new LatLng(34.7, -86.7), 9); mapView.setOnAerisMapLongClickListener(this); mapView.setOnAerisWindowClickListener(this); } ..... ..... } I have override all the necessary methods and the project builds with no error but when i run it i get exception. Following is the Stack trace. I have read all the blogs but couldn't find anything. I am new to android and learning still. Thanks
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: FATAL EXCEPTION: main 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: Process: com.example.rohan.weatherapp, PID: 4722 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rohan.weatherapp/com.example.rohan.weatherapp.MapActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.hamweather.aeris.maps.AerisMapView 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.hamweather.aeris.maps.AerisMapView 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:539) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at com.example.rohan.weatherapp.MapFragment.onCreateView(MapFragment.java:112) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.Fragment.performCreateView(Fragment.java:2220) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.BackStackRecord.run(BackStackRecord.java:793) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.FragmentController.execPendingActions(FragmentController.java:325) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.Activity.performStart(Activity.java:6252) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417) 11-21 19:25:52.010 4722-4722/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
No comments:
Post a Comment