使用 XYPlot 时如何解决问题 'Binary XML file line #8: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot'
How to get rid of issue 'Binary XML file line #8: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot' when working with XYPlot
我正在尝试使用 android studio 3.5 熟悉 android XYPlot。
我首先测试了几个示例,但最终出现了同样的错误 -
Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
然后应用程序崩溃。
如果有任何解决此问题的建议,我将不胜感激。谢谢!
我做了什么:
下面显示了我尝试过的其中一个示例 (this) 的 logcat 输出。我用 XYPlot 库更新了 Gradle,而且正如我在搜索时注意到的那样,我也想更新 ProGuard。最后还提到了更新的 ProGuard。
main_activity.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
androidplot.gridPadding="4dp|4dp|4dp|4dp"
androidplot.ticksPerDomainLabel="2"
androidplot.ticksPerRangeLabel="4"
andsroidplot.title="A Simple XYPlot Example"
android:layout_width="fill_parent"
android:layout_height="527dp"
android:layout_marginLeft="10px"
android:layout_marginTop="10px"
android:layout_marginRight="10px" />
</LinearLayout>
主要Activity
package com.example.plot_testmy2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.androidplot.xy.LineAndPointFormatter;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYPlot;
import com.androidplot.xy.XYSeries;
import java.util.Arrays;
public class MainActivity extends AppCompatActivity {
private XYPlot plot;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// initialize our XYPlot reference:
plot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
// add a new series
XYSeries mySeries = new SimpleXYSeries(
Arrays.asList(0, 25, 55, 2, 80, 30, 99, 0, 44, 6),
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "series1");
plot.addSeries(mySeries, new LineAndPointFormatter(
getApplicationContext(), R.xml.f1));
/*commented
// reposition the domain label to look a little cleaner:
plot.position(plot.getDomainLabelWidget(), // the widget to position
45, // x position value, in this case 45 pixels
XLayoutStyle.ABSOLUTE_FROM_LEFT, // how the x position value is applied, in this case from the left
0, // y position value
YLayoutStyle.ABSOLUTE_FROM_BOTTOM, // how the y position is applied, in this case from the bottom
AnchorPosition.LEFT_BOTTOM); // point to use as the origin of the widget being positioned
*/
plot.centerOnRangeOrigin(60);
plot.centerOnDomainOrigin(5);
}
}
Logcat 输出:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.plot_testmy2, PID: 29804
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.plot_testmy2/com.example.plot_testmy2.MainActivity}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.plot_testmy2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.RuntimeException: com.halfhp.fig.FigException: Error while parsing key: ticksPerDomainLabel value: 2
at com.androidplot.Plot.loadAttrs(Plot.java:563)
at com.androidplot.Plot.init(Plot.java:403)
at com.androidplot.Plot.<init>(Plot.java:324)
at com.androidplot.xy.XYPlot.<init>(XYPlot.java:143)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.plot_testmy2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: com.halfhp.fig.FigException: Error while parsing key: ticksPerDomainLabel value: 2
at com.halfhp.fig.Fig.configure(Fig.java:300)
at com.halfhp.fig.Fig.configure(Fig.java:208)
at com.androidplot.Plot.loadAttrs(Plot.java:561)
at com.androidplot.Plot.init(Plot.java:403)
at com.androidplot.Plot.<init>(Plot.java:324)
at com.androidplot.xy.XYPlot.<init>(XYPlot.java:143)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.plot_testmy2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NoSuchMethodException: No such public method (case insensitive): setticksPerDomainLabel in class com.androidplot.xy.XYPlot
at com.halfhp.fig.Fig.getMethodByName(Fig.java:110)
at com.halfhp.fig.Fig.getSetter(Fig.java:116)
at com.halfhp.fig.Fig.configure(Fig.java:274)
at com.halfhp.fig.Fig.configure(Fig.java:208)
at com.androidplot.Plot.loadAttrs(Plot.java:561)
at com.androidplot.Plot.init(Plot.java:403)
at com.androidplot.Plot.<init>(Plot.java:324)
at com.androidplot.xy.XYPlot.<init>(XYPlot.java:143)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.plot_testmy2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.plot_testmy2"
minSdkVersion 22
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "com.androidplot:androidplot-core:1.5.7"
}
混淆器:
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.androidplot.**{*;}
原因:java.lang.RuntimeException:com.halfhp.fig.FigException:解析键时出错:ticksPerDomainLabel 值:2
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
androidplot.gridPadding="4dp|4dp|4dp|4dp"
androidplot.ticksPerDomainLabel="2" <--- this line is causing the problem
androidplot.ticksPerRangeLabel="4"
andsroidplot.title="A Simple XYPlot Example"
android:layout_width="fill_parent"
android:layout_height="527dp"
android:layout_marginLeft="10px"
android:layout_marginTop="10px"
android:layout_marginRight="10px" />
删除这些:
androidplot.gridPadding="4dp|4dp|4dp|4dp"
androidplot.ticksPerDomainLabel="2" <--- this line is causing the problem
androidplot.ticksPerRangeLabel="4"
andsroidplot.title="A Simple XYPlot Example"
它应该可以工作。
我从未在 XML 属性上看到过点属性,它应该是下划线 (_) 或什么都不是
这些是该观点接受的所有可能Attributes。
None上面列出的那些都写在那里,它们只是不存在。
class 引用 R.layout.activity_main 而 XML 被命名为 main_activity.xml 这样正确吗?
加上没有andsroidplot.***属性,请改用ap:
例子
ap:title="A Simple XY Plot"
别忘了添加
xmlns:ap="http://schemas.android.com/apk/res-auto"
到布局的根标记(android studio 会通过 yellow/red 弹出窗口为您完成)
最后请参阅此页面以获取有关依赖项的更多信息
https://github.com/halfhp/androidplot/blob/master/docs/quickstart.md
祝你好运
我正在尝试使用 android studio 3.5 熟悉 android XYPlot。
我首先测试了几个示例,但最终出现了同样的错误 -
Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
然后应用程序崩溃。
如果有任何解决此问题的建议,我将不胜感激。谢谢!
我做了什么: 下面显示了我尝试过的其中一个示例 (this) 的 logcat 输出。我用 XYPlot 库更新了 Gradle,而且正如我在搜索时注意到的那样,我也想更新 ProGuard。最后还提到了更新的 ProGuard。
main_activity.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
androidplot.gridPadding="4dp|4dp|4dp|4dp"
androidplot.ticksPerDomainLabel="2"
androidplot.ticksPerRangeLabel="4"
andsroidplot.title="A Simple XYPlot Example"
android:layout_width="fill_parent"
android:layout_height="527dp"
android:layout_marginLeft="10px"
android:layout_marginTop="10px"
android:layout_marginRight="10px" />
</LinearLayout>
主要Activity
package com.example.plot_testmy2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.androidplot.xy.LineAndPointFormatter;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYPlot;
import com.androidplot.xy.XYSeries;
import java.util.Arrays;
public class MainActivity extends AppCompatActivity {
private XYPlot plot;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// initialize our XYPlot reference:
plot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
// add a new series
XYSeries mySeries = new SimpleXYSeries(
Arrays.asList(0, 25, 55, 2, 80, 30, 99, 0, 44, 6),
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "series1");
plot.addSeries(mySeries, new LineAndPointFormatter(
getApplicationContext(), R.xml.f1));
/*commented
// reposition the domain label to look a little cleaner:
plot.position(plot.getDomainLabelWidget(), // the widget to position
45, // x position value, in this case 45 pixels
XLayoutStyle.ABSOLUTE_FROM_LEFT, // how the x position value is applied, in this case from the left
0, // y position value
YLayoutStyle.ABSOLUTE_FROM_BOTTOM, // how the y position is applied, in this case from the bottom
AnchorPosition.LEFT_BOTTOM); // point to use as the origin of the widget being positioned
*/
plot.centerOnRangeOrigin(60);
plot.centerOnDomainOrigin(5);
}
}
Logcat 输出:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.plot_testmy2, PID: 29804
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.plot_testmy2/com.example.plot_testmy2.MainActivity}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.androidplot.xy.XYPlot
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.plot_testmy2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.RuntimeException: com.halfhp.fig.FigException: Error while parsing key: ticksPerDomainLabel value: 2
at com.androidplot.Plot.loadAttrs(Plot.java:563)
at com.androidplot.Plot.init(Plot.java:403)
at com.androidplot.Plot.<init>(Plot.java:324)
at com.androidplot.xy.XYPlot.<init>(XYPlot.java:143)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.plot_testmy2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: com.halfhp.fig.FigException: Error while parsing key: ticksPerDomainLabel value: 2
at com.halfhp.fig.Fig.configure(Fig.java:300)
at com.halfhp.fig.Fig.configure(Fig.java:208)
at com.androidplot.Plot.loadAttrs(Plot.java:561)
at com.androidplot.Plot.init(Plot.java:403)
at com.androidplot.Plot.<init>(Plot.java:324)
at com.androidplot.xy.XYPlot.<init>(XYPlot.java:143)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.plot_testmy2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NoSuchMethodException: No such public method (case insensitive): setticksPerDomainLabel in class com.androidplot.xy.XYPlot
at com.halfhp.fig.Fig.getMethodByName(Fig.java:110)
at com.halfhp.fig.Fig.getSetter(Fig.java:116)
at com.halfhp.fig.Fig.configure(Fig.java:274)
at com.halfhp.fig.Fig.configure(Fig.java:208)
at com.androidplot.Plot.loadAttrs(Plot.java:561)
at com.androidplot.Plot.init(Plot.java:403)
at com.androidplot.Plot.<init>(Plot.java:324)
at com.androidplot.xy.XYPlot.<init>(XYPlot.java:143)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.plot_testmy2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.plot_testmy2"
minSdkVersion 22
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "com.androidplot:androidplot-core:1.5.7"
}
混淆器:
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.androidplot.**{*;}
原因:java.lang.RuntimeException:com.halfhp.fig.FigException:解析键时出错:ticksPerDomainLabel 值:2
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
androidplot.gridPadding="4dp|4dp|4dp|4dp"
androidplot.ticksPerDomainLabel="2" <--- this line is causing the problem
androidplot.ticksPerRangeLabel="4"
andsroidplot.title="A Simple XYPlot Example"
android:layout_width="fill_parent"
android:layout_height="527dp"
android:layout_marginLeft="10px"
android:layout_marginTop="10px"
android:layout_marginRight="10px" />
删除这些:
androidplot.gridPadding="4dp|4dp|4dp|4dp"
androidplot.ticksPerDomainLabel="2" <--- this line is causing the problem
androidplot.ticksPerRangeLabel="4"
andsroidplot.title="A Simple XYPlot Example"
它应该可以工作。
我从未在 XML 属性上看到过点属性,它应该是下划线 (_) 或什么都不是
这些是该观点接受的所有可能Attributes。
None上面列出的那些都写在那里,它们只是不存在。
class 引用 R.layout.activity_main 而 XML 被命名为 main_activity.xml 这样正确吗?
加上没有andsroidplot.***属性,请改用ap: 例子
ap:title="A Simple XY Plot"
别忘了添加
xmlns:ap="http://schemas.android.com/apk/res-auto"
到布局的根标记(android studio 会通过 yellow/red 弹出窗口为您完成)
最后请参阅此页面以获取有关依赖项的更多信息
https://github.com/halfhp/androidplot/blob/master/docs/quickstart.md
祝你好运