在Android中使用Highcharts。

huangapple go评论98阅读模式
英文:

Use Highcharts in Android

问题

我尝试在我的Android Java应用程序中使用Highcharts。
我找到了两个官方教程来使用它,但是它们都不起作用,并且出现了以下错误:

第一个教程

E/AndroidRuntime: 致命异常: main
    进程: ir.azonik.testtest, PID: 5160
    java.lang.RuntimeException: 无法实例化活动ComponentInfo{aa.bb.cc/aa.bb.cc.MainActivity}: java.lang.NullPointerException: 尝试调用虚拟方法 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' 时发生空对象引用
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3365)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
                      ... 

第二个

E/AndroidRuntime: 致命异常: main
    进程: ir.azonik.testazs, PID: 18746
    java.lang.RuntimeException: 无法实例化活动ComponentInfo{aa.bb.cc/aa.bb.cc.MainActivity}: java.lang.ClassNotFoundException: 在路径上找不到类 "aa.bb.cc.MainActivity":DexPathList[[zip文件 "/data/app/aa.bb.cc-2mYWDS_pyscw6wLB3r-FKg==/base.apk"],nativeLibraryDirectories=[/data/app/aa.bb.cc-2mYWDS_pyscw6wLB3r-FKg==/lib/arm, /system/lib, /system/vendor/lib]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2841)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
       
        		...
英文:

I try to use Highcharts in my android java application.
i find two official tutorial for use that, but both of them not works and got those error:

first tutorial.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ir.azonik.testtest, PID: 5160
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{aa.bb.cc/aa.bb.cc.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3365)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
                      ... 

Second

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ir.azonik.testazs, PID: 18746
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{aa.bb.cc/aa.bb.cc.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "aa.bb.cc.MainActivity" on path: DexPathList[[zip file "/data/app/aa.bb.cc-2mYWDS_pyscw6wLB3r-FKg==/base.apk"],nativeLibraryDirectories=[/data/app/aa.bb.cc-2mYWDS_pyscw6wLB3r-FKg==/lib/arm, /system/lib, /system/vendor/lib]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2841)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
       
        		...

答案1

得分: 1

我最近遇到了这个问题,并发现它只能在 API 级别 27(Android 8.1)及更高版本的设备上运行。您可能在较低级别上成功进行 Gradle 构建,但这并不意味着应用程序会启动。此外,在导入 Highcharts aar 文件并更新 Gradle 文件之前,请确保您的应用程序能够成功运行。这样,您就可以确定是 Highcharts 导致了错误。

以下是我测试过的设备的屏幕截图:
在Android中使用Highcharts。

在 API 26(Android 8.0)上运行的设备无法启动,但其他设备能够成功运行。此外,请确保在您的应用程序的 build.gradle 文件中将 "minSdkVersion" 设置为 27。

英文:

I recently ran into this problem, and found that the it could only run on devices at API level 27 (Android 8.1) and higher. You can have a successful Gradle build at lower levels, but that does not mean that the app will start. Also, make sure that your app was able to run successfully before you imported the Highcharts aar file and updated your Gradle files.
That way, you can pinpoint if Highcharts is what is causing the errors.

Here is a screenshot of the devices I tested my app on:
在Android中使用Highcharts。

The devices running on API 26 (Android 8.0) were unable to start, but the rest were able to run successfully. Also, make sure to set the "minSdkVersion" to 27 in your app's build.gradle file.

huangapple
  • 本文由 发表于 2020年8月17日 20:23:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/63450747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定