android.view.InflateException:二进制XML文件行#9错误膨胀类com.hamweather.aeris.maps.AerisMapView

时间:2015-11-22 03:29:31

标签: java android xml android-fragments

我正在构建一个应用程序,我正在尝试使用Aeris天气Api。我按照他们提供的教程,但得到了同样的错误。这是代码

fragment_map.xml

        var sb = new StringBuilder();
        strings.ForEach(s => sb.Append(s));
        var combinedList = sb.ToString();

activity_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>

MapActivity.java

<?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>

MapFragment.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)
    {

    }
}

我已经覆盖了所有必要的方法,项目构建时没有错误,但是当我运行它时,我得到了异常。以下是堆栈跟踪。我已阅读所有博客但无法找到任何内容。我是Android的新手,还在学习。感谢

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);

    }
.....
.....

}

的Manifest.xml

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) 
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: Error inflating class com.hamweather.aeris.maps.AerisMapView
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:645)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
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) 
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: java.lang.reflect.InvocationTargetException
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at java.lang.reflect.Constructor.newInstance(Native Method)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:619)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
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) 
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.content.res.Resources$NotFoundException: Resource ID #0x7f030002
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.content.res.Resources.getValue(Resources.java:1351)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2774)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.content.res.Resources.getLayout(Resources.java:1165)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at com.hamweather.aeris.maps.AerisMapView.<init>(AerisMapView.java:155)
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at java.lang.reflect.Constructor.newInstance(Native Method) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
11-21 19:25:52.010 4722-4722/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
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) 
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.064 4722-4761/? E/EGL_emulation: tid 4761: swapBuffers(324): error 0x3003 (EGL_BAD_ALLOC)
11-21 19:25:52.064 4722-4761/? A/OpenGLRenderer: Encountered EGL error 12291 EGL_BAD_ALLOC during rendering
11-21 19:25:52.064 4722-4761/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 4761 (RenderThread)

依赖关系

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.rohan.weatherapp" >

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity android:name=".MainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".AboutActivity" >
        </activity>
        <activity android:name=".ResultActivity" >
        </activity>
        <activity android:name=".DetailsActivity" >
        </activity>
        <activity
            android:name=".Next24Hours"
            android:theme="@style/AppTheme.NoActionBar" >
        </activity>
        <activity android:name=".Next7Days" >
        </activity>
        <activity android:name=".MapActivity" >
        </activity>
    </application>

</manifest>

1 个答案:

答案 0 :(得分:2)

您遇到的问题是缺少某个资源(可能是字符串),正如映射库中报告的char (*ptr_to_array)[y] = malloc(x * sizeof *ptr_to_array); 所示。您是否在strings.xml文件中正确设置了Resources$NotFoundExceptionaeris_client_id

看起来这个库在Maven Central中可用作AAR,其中包含所有资源,因此您不必担心Jars和依赖项。我建议按照installation instructions底部的说明将其添加到您的项目中。

您可以使用此替换aeris_client_secret文件中的所有Aeris jar内容,这就是您所需要的。

build.gradle