【问题标题】:android.view.InflateException: Binary XML file line #9: Error inflating class com.jjoe64.graphview.helper.GraphViewXMLandroid.view.InflateException:二进制 XML 文件第 9 行:膨胀类 com.jjoe64.graphview.helper.GraphViewXML 时出错
【发布时间】:2015-05-04 07:52:08
【问题描述】:

我无法在 Android 模拟器上启动我的图形应用程序。 “不幸的是,图表停止了”不断弹出。有人可以帮我解决这个问题吗?

这是 Java 文件:

package graphs.com.graphs;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivityG extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_activity_g);
    }


     @Override
      public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main_activity_g, menu);
        return true;
    }

    @Override
     public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

这是我的 XML 文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/lib/graphs.com.graphs"
    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=".MainActivityG">

    <com.jjoe64.graphview.helper.GraphViewXML
        android:layout_width="match_parent"
        android:layout_height="100dip"
        app:seriesData="0=5;2=5;3=0;4=2" />

</RelativeLayout>

【问题讨论】:

  • 在你的项目“properties”>“java build path”>“order and export”中,你的库的jar文件是否“勾选”了?
  • 你是如何在 Android Studio 中做到这一点的?
  • 我在这里看了stackoverflow.com/questions/16608135/…。您是否“确保 'compile files('libs/gson-2.2.4.jar')' 在您的 build.gradle 文件中”。 gson-2.2.4.jar 应该替换为您的 graphview 库
  • 我已经这样做了,但仍然没有任何改变。模拟器仍然抛出“不幸的是图表停止了”
  • 你能在 logcat 中看到任何异常/堆栈跟踪吗?您应该看到能够打开 DDMS 并查看。 developer.android.com/tools/debugging/debugging-studio.html

标签: java android xml android-layout


【解决方案1】:

你有没有尝试替换

xmlns:app="http://schemas.android.com/apk/lib/graphs.com.graphs"

xmlns:app="http://schemas.android.com/apk/res-auto"

不知道能不能解决

【讨论】:

猜你喜欢
  • 2018-03-04
  • 1970-01-01
  • 1970-01-01
  • 2015-09-21
  • 1970-01-01
  • 2016-11-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多