Reputation: 141
I'm trying to use Neo4j OGM library 2.0.1 in my android application.
This is my builde.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'org.neo4j:neo4j-ogm-core:2.0.1'
compile 'org.neo4j:neo4j-ogm-http-driver:2.0.1'
}
Then in onCreate() method inside my main activity:
Configuration configuration = Components.configuration();
configuration.driverConfiguration()
.setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver")
.setURI("http://socialphonebook:a24mWoNT0EapsI2CT679@socialphonebook.sb09.stations.graphenedb.com:24789/db/data/");
SessionFactory sessionFactory = new SessionFactory("it.lucaspuerari.entities");
sessionFactory.openSession();
I got this error:
E: FATAL EXCEPTION: main
java.lang.NoSuchMethodError: No static method encodeBase64String([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)
at org.neo4j.ogm.authentication.UsernamePasswordCredentials.<init>(UsernamePasswordCredentials.java:28)
at org.neo4j.ogm.config.DriverConfiguration.setCredentials(DriverConfiguration.java:72)
at org.neo4j.ogm.config.DriverConfiguration.setURI(DriverConfiguration.java:58)
Upvotes: 0
Views: 219
Reputation: 1809
The problem is due to the fact that Android comes with an older versions of org.apache.commons
. From the version 1.4 such method is supported. I faced the same problem and I solved repackaging a new version of org.apache.commons
in android.org.apache.commons
and changing the correspondent import in the UsernamePasswordCredentials
class.
Upvotes: 0
Reputation: 45083
Your problem is you are trying to use OGM on the Android, but team behind the OGM never try it in Android environment and also Android isn't the target platform. As you may know Android Java is different from Oracle Java.
If you want to use OGM on the Android I recommend to you to fork OGM and try to build and run test agains Android Java.
Your problem is with missing encodeBase64String
method, because Android's library is old and you should use android.util.Base64
instead of org.apache.commons.codec.binary.Base64
.
Upvotes: 1