Package does not exist on build but importing without errors? - java

My project was building fine until I added Kryo dependency to my project. I can use both Netty and Kryo without syntax errors in my IDE but it won't build. All I did was adding Kryo to my common module and started implementing Kryo in my code, when I wanted to run Gradle it returned a big list of errors about none existent Netty and Kryo packages.
My gradle is very simple, client and server module both depend on common which atm has 2 custom classes and implement Kryo and Netty.
project(":common") {
apply plugin:'java'
dependencies {
// https://mvnrepository.com/artifact/io.netty/netty-all
implementation group: 'io.netty', name: 'netty-all', version: '4.1.33.Final'
// https://mvnrepository.com/artifact/com.esotericsoftware.kryo/kryo
implementation group: 'com.esotericsoftware.kryo', name: 'kryo', version: '2.24.0'
}
}
project(":server") {
apply plugin:'java'
dependencies {
implementation project(":common")
// https://mvnrepository.com/artifact/org.mongodb.morphia/morphia
compile group: 'org.mongodb.morphia', name: 'morphia', version: '1.3.2'
}
}
project(":client") {
apply plugin:'java'
dependencies {
implementation project(":common")
}
}
In client and server (both just java applications atm) I am using Kryo and Netty without syntax errors but when I run or build I get the following list for each class that imports Netty or Kryo.
error: package io.netty.channel does not exist
error: package io.netty.channel does not exist
error: package io.netty.channel does not exist
error: package io.netty.channel.group does not exist
error: cannot find symbol class ChannelInboundHandlerAdapter
error: cannot find symbol class ChannelGroup
error: cannot find symbol class ChannelHandlerContext
error: cannot find symbol class ChannelGroup
error: cannot find symbol class ChannelHandlerContext
error: cannot find symbol class ChannelHandlerContext
error: method does not override or implement a method from a supertype
error: method does not override or implement a method from a supertype
I tried the most obvious invalidate cache / restart, cleaning, rebuilding without success. Apart from that I tried fiddling with the plugin, setting it to java-library and back. The only thing I did differently then usual is that I tried to exclude Kryo for the other 2 modules but I gave up on that after a few attempts for the time being and erased those exclude lines. It's probably just something I overlooked but I can't put my finger on it.

Related

Unable to resolve symbol 'TapTargetView'

I am trying to implement the TapTargetView library from https://github.com/KeepSafe/TapTargetView
I have included this dependency in my build.gradle (Module:app)
dependencies {
...
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
}
But upon implementing the code, I keep getting this error
Unable to resolve symbol TapTargetView
Why is that? I've tried using these other dependencies too:
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.12.0'
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.0'
I still get the same error.
There was a mismatch in the version, the following implementation works for now:
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.3'

Websocket dependency runtime error, could not find an implementation class

I'm faced with an interesting problem. I have an intellij plugin which creates an intellij tool window which, as part of its functionality, uses a websocket. In my build.gradle, I have compile group: 'org.glassfish.tyrus.bundles', name: 'tyrus-standalone-client', version: '1.15'. When I run my java code as an application and trigger the methods programmatically, or using JFrame guis, the websocket runs as it should. However, when using the same compile line in my plugin tool window, I get the following error.
java.lang.RuntimeException: java.lang.RuntimeException: Could not find an
implementation class.
at ElasticsearchClientEndpoint.<init>(ElasticsearchClientEndpoint.java:19)
Caused by: java.lang.RuntimeException: Could not find an implementation class.
at javax.websocket.ContainerProvider.getWebSocketContainer(ContainerProvider.java:73)
at ElasticsearchClientEndpoint.<init>(ElasticsearchClientEndpoint.java:16)
I've tried running the plugin from a project which has the same dependency but I still get this error. I can't work out why I'm getting this error, any help would be excellent.

Android studio 3.1 not recognizing jar annotation processing

I'm trying to implement my own annotation processor in my android studio project. All is working well and compiling until I add this simple line to build.gradle dependencies block:
dependencies {
.
.
.
annotationProcessor(':processor')
}
At that point I get this error when compiling:
Could not find :processor:. Required by:
project :app Search in build.gradle files
I've followed endless tutorials and nothing seems to help. I've just recently upgraded to AS 3.1 and thinking maybe it relates?
Here is the project structure: (mind you - here I add the annotation processor as a jar file. I've also attached an image trying to do it as a different module and same result)
Here is a different I'm trying to add it - creating the annotation processor in the same project with a different module and still no go:
Some extra info in pics...
Project structure:
app.build:
processor.build:
annotation:
MainActivity:
Processor implementation:
If you have everything inside the same artifact, — annotation processor, it's annotations and library classes, used by processor users, Android Gradle plugin requires you to declare two dependencies on the same artifact:
annotationProcessor project(':processor')
compile project(':processor')
or
annotationProcessor files('libs/processor.jar')
compile files('libs/processor.jar')
Note, that such setup might become unsupported in future. It is advisable to split your processor in separate module and make it depend on the rest of code. After doing so you will be able to declare dependencies like this:
annotationProcessor project(':processor') // processor-only jar
compile project(':processor-api') // annotations and classes for user code

How to resolve unknown class and can not resolve symbol in Android Studio java library module

Using Android Studio and creating a java library module as part of a sub project I get an error on the following java statement:
javaFile.writeTo(System.out);
and it complains of can not resolve symbol 'writeTo' and unknown class 'System.out'.
Here's the gist of the source code class
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeSpec;
import javax.lang.model.element.Modifier;
public class MyClass {
...
JavaFile javaFile = JavaFile.builder("com.foobar.helloworld", helloWorld)
.build();
javaFile.writeTo(System.out);
}
A bit hard to say without knowing exactly what your exception was, but I had something similar pop up when I was testing out a sub-module annotation processor. When linking the processor to my main module, I was getting a java.lang.NoClassDefFoundError: com/squareup/javapoet/MethodSpec. I was using android-apt to get the annotation processor working, so in my build.config my dependencies had the apt configuration definition:
dependencies {
...
apt 'com.squareup:javapoet:1.7.0' // <- Note that since my Processor used javapoet, I had to include Javapoet in the main module's apt dependency as well as my processor jar
apt files('../processor/build/libs/processor.jar')
}
Once i included the above noted dependency, then all worked fine. Not sure if this applies to your situation without more details, but this got me back on track.

Using AppEngine's DatastoreService in Android Studio

I'm trying to make a simple Android app that writes, for example, an entity with a key called "Example" and a value of "Hello World". Following the tutorial here I've created and uploaded a backend and got the basic functionality detailed there to work using the Java Servlet module, but it wouldn't save any entity on the datastore (but rather just make a toast on the client app) so it was useless for my purposes.
So now I'm trying to import the DatastoreService and Entity classes so I could use the method DatastoreService.put(Entity). However, conflicting resources on the internet and myself being unable to find a coherent guide about this process caused multiple compile errors:
Adding the following dependencies to build.gradle (app):
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.1'
compile 'com.google.appengine:appengine-endpoints:1.9.1'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.1'
compile 'javax.servlet:servlet-api:2.5'
Raises the error:
Gradle DSL method not found: 'appengineSdk()'
Adding the following dependency to build.gradle (project):
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.3'
And applying the plugin in the same file:
apply plugin: 'appengine'
Raises:
Error: Task with name 'assemble' not found in root project
I'm looking for clear instructions on how to properly implement the appropriate classes and handle the process as I'm very new to this aspect of Android Studio and it seems I've gone off-track. Thanks for your support.

Categories

Resources