我的应用程序可以在5+和6+上正常运行,但不能在7+上正常运行。当应用程序尝试登录服务器时,抛出以下异常:

09-01 09:52:53.821 2654-2718/com.pipodi.italiansubsmobileclient E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.pipodi.italiansubsmobileclient, PID: 2654
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.IllegalAccessError: Method 'void org.jdom2.ContentList.sort(java.util.Comparator)' implementing interface method 'void java.util.List.sort(java.util.Comparator)' is not public (declaration of 'org.jdom2.ContentList' appears in /data/data/com.pipodi.italiansubsmobileclient/files/instant-run/dex/slice-jdom-2.0.5_82fed81e6dd7ad54ef864ead3d2cf112380d9d58-classes.dex)
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:299)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:292)
at dalvik.system.DexPathList.findClass(DexPathList.java:418)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
at com.android.tools.fd.runtime.IncrementalClassLoader.findClass(IncrementalClassLoader.java:62)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:367)
at java.lang.ClassLoader.loadClass(ClassLoader.java:367)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.jdom2.Document.<init>(Document.java:83)
at org.jdom2.Document.<init>(Document.java:154)
at org.jdom2.DefaultJDOMFactory.document(DefaultJDOMFactory.java:190)
at org.jdom2.input.sax.SAXHandler.reset(SAXHandler.java:228)
at org.jdom2.input.sax.SAXHandler.<init>(SAXHandler.java:208)
at org.jdom2.input.sax.DefaultSAXHandlerFactory$DefaultSAXHandler.<init>(DefaultSAXHandlerFactory.java:76)
at org.jdom2.input.sax.DefaultSAXHandlerFactory.createSAXHandler(DefaultSAXHandlerFactory.java:82)
at org.jdom2.input.SAXBuilder.buildEngine(SAXBuilder.java:848)
at org.jdom2.input.SAXBuilder.getEngine(SAXBuilder.java:904)
at org.jdom2.input.SAXBuilder.build(SAXBuilder.java:1091)
at com.pipodi.italiansubsmobileclient.connections.Connection.connectToAPIURL(Connection.java:20)
at com.pipodi.italiansubsmobileclient.connections.LoginVariables.getAuthCode(LoginVariables.java:39)
at com.pipodi.italiansubsmobileclient.connections.ItaSALogin.doInBackground(ItaSALogin.java:69)
at com.pipodi.italiansubsmobileclient.connections.ItaSALogin.doInBackground(ItaSALogin.java:38)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761) 


我已经在模拟器上尝试过此操作,但始终在Nougat上崩溃,但在任何以前的Android版本上都没有崩溃。

他们在分子水平上有改变吗?

这是引发异常的类:

public class Connection extends Thread {

public static Document connectToAPIURL(String url, Context context) {
    try {
        Log.i("URLApi", url);
        if (checkInternetConnection(context)) {
            return new SAXBuilder().build(HTTPS.getInstance().connection(url));
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return null;
}

public static boolean checkInternetConnection(Context context) {
    ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {
        return true;
    }
    return false;
}


您能帮我解决问题吗?

谢谢!

最佳答案

我有同样的问题。升级到JDOM 2.0.6,它将解决此问题。

从JDOM发行说明中:“修复了问题129-Java 8在List接口上引入了公共排序方法。这与ContentList上的受保护排序冲突”

09-30 18:17