【问题标题】:java.lang.NoSuchMethodError in Android ApplicationAndroid 应用程序中的 java.lang.NoSuchMethodError
【发布时间】:2015-02-16 21:41:18
【问题描述】:

我正在尝试通过 Android 应用程序(使用 Android Studio)使用 Java JDBC 驱动程序连接到我的 Neo4j 服务器。它在 Eclipse 中运行良好,但是在这里我收到一个错误:java.lang.NoSuchMethodError。我已经添加了 JDBC jar 文件,我正在搜索并且似乎 Android 正在使用过时的 HttpClient 版本。我从:https://code.google.com/p/httpclientandroidlib/ 下载了文件并添加了 jar,但错误并没有消失。这是我的代码和堆栈跟踪:

Class.forName("org.neo4j.jdbc.Driver");

        Connection con = null;

        con = DriverManager.getConnection("jdbc:neo4j://xxx.xxx:7474"); --> This is where error is (name of server hidden for security)


        // Querying
        try(Statement stmt = con.createStatement()) {
            ResultSet rs = stmt.executeQuery("MATCH (n:Manager) RETURN n.Email");
            while (rs.next()) {
                Toast.makeText(this, rs.getString("n.Email"), Toast.LENGTH_SHORT).show();
                // System.out.println(rs.getString("n.Email"));
            }
        }

堆栈跟踪:

 java.lang.IllegalStateException: Could not execute method of the activity
            at android.view.View$1.onClick(View.java:3855)
            at android.view.View.performClick(View.java:4470)
            at android.view.View$PerformClick.run(View.java:18593)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5867)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at android.view.View$1.onClick(View.java:3850)
            at android.view.View.performClick(View.java:4470)
            at android.view.View$PerformClick.run(View.java:18593)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5867)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLSocketFactory.<init>
            at org.restlet.ext.httpclient.HttpClientHelper.configure(HttpClientHelper.java:275)
            at org.restlet.ext.httpclient.HttpClientHelper.start(HttpClientHelper.java:478)
            at org.restlet.Client.start(Client.java:217)
            at org.restlet.Restlet.handle(Restlet.java:315)
            at org.restlet.Client.handle(Client.java:177)
            at org.restlet.resource.ClientResource.handle(ClientResource.java:1136)
            at org.restlet.resource.ClientResource.handleOutbound(ClientResource.java:1225)
            at org.restlet.resource.ClientResource.handle(ClientResource.java:1068)
            at org.restlet.resource.ClientResource.handle(ClientResource.java:1044)
            at org.restlet.resource.ClientResource.handle(ClientResource.java:950)
            at org.restlet.resource.ClientResource.get(ClientResource.java:658)
            at org.neo4j.jdbc.rest.Resources$DiscoveryClientResource.readInformation(Resources.java:131)
            at org.neo4j.jdbc.rest.Resources.getDiscoveryResource(Resources.java:65)
            at org.neo4j.jdbc.rest.Resources.getDiscoveryResource(Resources.java:60)
            at org.neo4j.jdbc.Neo4jConnection.getDiscoveryResource(Neo4jConnection.java:80)
            at org.neo4j.jdbc.Neo4jConnection.createExecutor(Neo4jConnection.java:69)
            at org.neo4j.jdbc.Neo4jConnection.<init>(Neo4jConnection.java:61)
            at org.neo4j.jdbc.Connections$4.doCreate(Connections.java:51)
            at org.neo4j.jdbc.Connections.create(Connections.java:62)
            at org.neo4j.jdbc.Driver.connect(Driver.java:64)
            at org.neo4j.jdbc.Driver.connect(Driver.java:36)
            at java.sql.DriverManager.getConnection(DriverManager.java:179)
            at java.sql.DriverManager.getConnection(DriverManager.java:144)
            at computing.gmit.ie.scorerapp.Login.btnLoginClick(Login.java:45)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at android.view.View$1.onClick(View.java:3850)
            at android.view.View.performClick(View.java:4470)
            at android.view.View$PerformClick.run(View.java:18593)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5867)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
            at dalvik.system.NativeStart.main(Native Method)

【问题讨论】:

    标签: java android jdbc neo4j nosuchmethoderror


    【解决方案1】:

    我猜这与您在运行时动态加载该类的方式有关。如果您正在运行 pro-guard 并且您的代码被混淆了,这很可能是问题所在。

    尝试将库添加到您的项目并像往常一样导入类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 2019-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多