Cannot resolve symbol 'JsonException' - Json Simple import problem - java

I want to use Json simple in my project, however I can't get it to work. I tried versions 1.1.0, 3.1.0, 3.1.3, 4.0.0 and every time I do import com.github.cliftonlabs.json_simple.JsonException; I have error Cannot resolve symbol 'JsonException' I use InteliJ, every time I tried a version I went to File> Project Structure and added .jar file. Then I add dependecy compile group: 'com.github.cliftonlabs', name: 'json-simple', version: '3.1.0' into my build.gradle. The error repeats every time. How do I fix this?

I managed to fix the issue, I used
implementation 'com.github.cliftonlabs:json-simple:4.0.0' in build.gradle
and refreshed the gradle build

Related

Including javax persistence in a Cordova/Android project

I am trying to incorporate ObjectBox in my hybrid Cordova/Android project. By dint of some trial and error I have managed to figure out two of the steps involved.
The app level build.gradle file has to be modified to include the ObjectBox Gradle plugin classpath "io.objectbox:objectbox-gradle-plugin:2.5.0"
Define a build-extras.gradle file to "apply" the ObjectBox plugin ext.postBuildExtras = {apply plugin: 'io.objectbox'}
The next step according to the ObjectBox docs is to define at least one Entity class
However, the issue here is that I need to import the javax.persistence.* classes into the project. It is not clear to me how I do this. I have run into suggestions along the lines of including
compile group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
in the dependencies section of the app level build.gradle file. However, this causes gradle to complain that it does not know the compile() function. I'd be much obliged to anyone who might be able to tell me how this should be done.
For the benefit of anyone running into this thread - you can download the JAR file for javax.persistence here. Place this line in the folder src/android/libsof your custom plugin and then modify plugin.xmlwith the line
<lib-file src='src/android/libs/name-of-javax-persistence.jar'/>

Gradle dependency NoSuchMethodError 'AnnotationAttributes.getAliasedStringArray'

I'm building a sftp upload and download project with spring integration in intellij and i'm having problems with these methods: ObjectUtils.unwrapOptional, AnnotationAttributes.getAliasedStringArray. When i run the project i get the NoSuchMethodError error for one of the methods mentioned above. I'm not finding a spring-core jar that contains both of them, the current jar i'm using in gradle is: 'compile group: org.springframework', name: 'spring-core', version: '5.0.8.RELEASE' which doesn't contain the getAliasedStringArray method at AnnotationAttributes class. Can somebody help me with the version of the jar which contains both methods? Thanks
AnnotationAttributes.getAliasedStringArray was depreciated as of 4.3.6.RELEASE and was replaced by AnnotationAttributes.getStringArray (check out the specification for 5.0.8.RELEASE).
Essentially, you'll either have to change the implemenation to the new method as the deprecated method is not in the version your using or you'll have to down grade your version.

Dependency issue creating SWRL Rule with SWRL API using gradle

I am trying to add a SWRL rule to my Ontology using SWRLAPI and OWLAPI. I am trying to use OWLAPI's version which is compatible with SWRLAPI. However, I still get errors when creating a rule. It seems to be a problem with the dependency management. I am using gradle as a dependency manager so this should have solved the issue.
The Exception is:
Error creating rule engine Drools. Exception: java.lang.NoClassDefFoundError. Message: org/drools/runtime/rule/AgendaFilter"
My build.gradle dependency file:
dependencies {
compile group: 'net.sourceforge.owlapi', name: 'owlapi-distribution', version: '4.1.3'
compile group: 'net.sourceforge.owlapi', name: 'org.semanticweb.hermit', version: '1.4.1.513'
compile 'edu.stanford.swrl:swrlapi:2.0.5'
compile 'edu.stanford.swrl:swrlapi-drools-engine:2.0.5'
}
The exception happens when executing createSWRLRuleEngine method:
public void addNewSWRLRule(SWRLRuleModel rule) throws SWRLBuiltInException, SWRLParseException {
SWRLRuleEngine swrlRuleEngine = SWRLAPIFactory.createSWRLRuleEngine(ontology);
swrlRuleEngine.infer();
swrlRuleEngine.createSWRLRule(rule.getName(), rule.getRule(), rule.getComment(), true);
}
Is there a dependency that must be added manually to solve this issue?
You're using HermiT 1.4.1.513. That's compatible with owlapi 5, not 4 (the patch number matches the owlapi version). Use HermiT 1.3.8.413.
The problem was that there were 2 maven dependencies from Drools Engine (edu.stanford.swrl:swrlapi-drools-engine:2.0.5) not resolved by gradle.
The missing dependencies were:
org.drools:knowledge-api:6.5.0.Final
org.drools:drools-osgi-integration:6.5.0.Final
I am not sure what is causing these not to be solved by gradle, but I managed to fix the issue in IntelliJ by converting the two missing dependencies to a Repository Library and searching for these in maven following these steps:
File > Project Structure > Libraries
Right button click on the missing library
Convert to Repository Library
Type the dependency name and search in maven repository
Replace

Why does Gradle resolve a package with wrong version number?

I am building a web application and I am using Dropwizard 1.3.0, which has a dependency on jetty-io 9.4.8. This dependency has conflicts with another package (dropwizard-websocket-jee7-bundle 2.0.0), because it seem to fetch the wrong version number.
I looked into tha package, and found the method that has been renamed in 9.4.x - AbstractWebSocketConnection.java from 9.3.x - AbstractWebSocketConnection.java. The issue is that even though in Gradle the dependency tree shows I fetched 9.4.8 (the new one which I need), I still get the older, 9.3.x java file which causes the conflicts. I tried to Invalidate Caches / Restart and rebuild the whole project, but I seem to get the outdated file all the time.
What are the possible solutions for this?
If your bad class are imported by a transitive dependency, try to exclude explicit the transitive dependency.
For example if your required library is 'my.group:requiredLibrary:2.0.0' and there are another version in 'my.group:someDependency:0.1.5' you can do like this:
dependencies{
compile 'my.group:requiredLibrary:2.0.0'
compile ('my.group:someDependency:0.1.5'){
exclude group: 'my.group' module:'requiredLibrary'
}
}
Try forcing a particular version in your build.gradle
Example here: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

What to do as AndroidSlidingUpPanel Library is using some libraries not up to date

I was trying to use AndroidSlidingUpPanel in my app but when I was trying to build the Gradle file is giving me this warning.
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.0.0-alpha1, 23.4.0. Examples include com.android.support:animated-vector-drawable:26.0.0-alpha1 and com.android.support:recyclerview-v7:23.4.0 more...
I have seen the files in GitHub and saw that the file AndroidSlidingUpPanel/library/build.gradle is using a lower version of :
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:support-annotations:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
which should be something like this:
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support:support-annotations:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
When I downloaded the library and imported it as module it was giving error too:
Error:(21, 0) Could not read script
'I:\ANDROID\Android_Studio_Projects\TRYS\Theme3\maven_push.gradle' as it
does not exist.
Open File
Even after copying maven_push.gradle to root it is giving this error:Error:Could not get unknown property 'GROUP' for object of type org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer.
So what to do?
open android studio and get to this page
press this part
it will open a drop-down menu press git and then
press clone and your done
You have two options
Post an issue in the library on GitHub and wait for the creator to update.
Add it to your project manually by pulling​ the project from git and update the libraries your self.
Remove lines referring to maven_push.gradle from the build.gradle on the specified project.
Example:
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
apply from: './mvn-push.gradle'
Just comment them out. I've got this solution after going through this

Categories

Resources