Android - Invalid Package javax.servlet.MultipartConfigElement - android

My Android app has a Java library added via a Gradle dependency. When trying to perform ./gradlew build, I get the following error:
InvalidPackage: Package not included in Android
../../../../../../../../../.gradle/caches/modules-2/files-2.1/javax.servlet/javax.servlet-api/3.0.1/6bf0ebb7efd993e222fc1112377b5e92a13b38dd/javax.servlet-api-3.0.1.jar: Invalid package reference in library; not included in Android: javax.servlet.annotation. Referenced from javax.servlet.MultipartConfigElement.
I have control over the Java library so I can make changes. The error isn't really telling me where the reference to that is in my library and I can't seem to find an alternative for it.
Any ideas?
Update
I added the following to my Gradle:
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
But I still get the same error when doing ./gradlew build.

As per our discussion in comment . This error can be ignored by using the following code in gradle
lintOptions {
disable 'InvalidPackage'
}

Related

Override java dependency in react native library

I need to use a react native library called #ihealth/ihealthlibrary-react-native
I added it to my project, but on build I get an error Could not find no.nordicsemi.android:dfu:1.6.1
This package version seems to be no longer available, so I would like to override the version in my react native app.
I added the following in MyProject/android/app/build.gradle
dependencies {
implementation("com.ihealth.ihealthlibrary:iHealthLibrary:1.5.1") {
exclude group:'no.nordicsemi.android:dfu:1.6.1'
}
implementation("no.nordicsemi.android:dfu:1.8.0")
}
I then get this error: Could not find com.ihealth.ihealthlibrary:iHealthLibrary:1.5.1.
Basically I can't figure out what's the correct package name and version to put in my config.
Where can I find this ?
This lib is really outdated. Go into the libraries build.gradle file and replace this implementation 'no.nordicsemi.android:dfu:1.6.1'
with: implementation 'no.nordicsemi.android:dfu:1.8.0'
then create a patch: yarn patch-package #ihealth/ihealthlibrary-react-native

Release build fails on Room generated classes: javax.annotation does not exist

I have a java project that builds fine in Android Studio and on the CI server.
Building a release version with gradle on the terminal fails though.
I get the following output:
Database_Impl.java:42: error: package javax.annotation does not exist
Database_Impl.java:44: error: cannot find symbol
#Generated("androidx.room.RoomProcessor")
Some similar issues with Dagger suggests that this is a problem with the Java version of the build system.
I'm using a Mac and my javac version is: 10.0.2
I had the same issue and adding implementation "javax.annotation:jsr250-api:1.0" to build.gradle dependencies helped.
This seems to be related to the Java version that is active on your machine.
There is a similar bug ticket with Dagger: https://github.com/google/dagger/issues/1449
The result of the discussion is that this is a bug in KAPT: https://youtrack.jetbrains.com/issue/KT-32804
The workaround is to put
if (project.hasProperty('kapt')) {
// Reference for 'kapt' DSL: https://kotlinlang.org/docs/reference/kapt.html#java-compiler-options
kapt {
// we expect this closure to run over a org.jetbrains.kotlin.gradle.plugin.KaptExtension
javacOptions {
option("-source", "8")
option("-target", "8")
}
}
}
at the end of the build file of the affected module.

itextpdf - itextg Android lint error

I'm trying to use itextg but I'm getting some gradle errors. Any idea? I tried version 5.5.9 and 5.5.10.
Execution failed for task ':app:lint'.
Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
The first 3 errors (out of 482) were:
/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.itextpdf/itextg/5.5.10/247811bfc4d8f4e99c909236eadf4dfc6dfa1615/itextg-5.5.10.jar: Error: Invalid package reference in library; not included in Android: javax.xml.crypto.dom. Referenced from com.itextpdf.text.pdf.security.MakeXmlSignature. [InvalidPackage]
/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.itextpdf/itextg/5.5.10/247811bfc4d8f4e99c909236eadf4dfc6dfa1615/itextg-5.5.10.jar: Error: Invalid package reference in library; not included in Android: javax.xml.crypto.dsig.dom. Referenced from com.itextpdf.text.pdf.security.MakeXmlSignature. [InvalidPackage]
/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.itextpdf/itextg/5.5.10/247811bfc4d8f4e99c909236eadf4dfc6dfa1615/itextg-5.5.10.jar: Error: Invalid package reference in library; not included in Android: javax.xml.crypto.dsig.keyinfo. Referenced from com.itextpdf.text.pdf.security.MakeXmlSignature. [InvalidPackage]
As far I understood, Android doesn't contain the following packages.
javax.xml.crypto.dom
javax.xml.crypto.dsig
That's why itextpdf lib can't find references to them. To fix it, add the following dependency.
implementation group: 'javax.xml.crypto', name: 'jsr105-api', version: '1.0.1'
Sounds like transitive libraries missing. Try using { transitives = true} on that dependency and see if it helps. Also it looks like they might be using straight Java modules for security underneath the hood, so you may have to make sure you specify the right JAVA_VERSION to use in your build.gradle as well.
Also confirm that you can expand the project view, to the itextg area and see the following JARs have been pulled in.
itextpdf-x.y.z.jar
itext-xtra-x.y.z.jar
itext-pdfa-x.y.z.jar
xmlworker-x.y.z.jar
If you don't see them, then you may need to download them and include them manually. I'm not familiar with itext enough to know how they include their transitive dependencies, but they do call it out on GitHub that they are used in this, so confirm they are there.

Cannot access inherited library

In my android library I am using ceddl4j library but when I build my library and try to add it's aar file in another Application, it is throwing error
Error:(75, 44) error: cannot access DigitalData
class file for nl.mirabeau.ceddl4j.DigitalData not found
Adding ceddl4j into my library with
compile group: 'nl.mirabeau', name: 'ceddl4j', version: '1.0.0'
I am surely missing something in build configuration of my library, can someone please guide.
Thanks to Grabriele for providing the information that aar file does not contain the nested dependencies, hence the option left is maven repo (public or private).

Unresolved dependencies error in IntelliJ IDEA

So i just started working with IntelliJ and created my first project, but i get this error in the Messages make
and this in the Event log
this is the content of my my build.gradle file
Can someone please help?
Try this in your Gradle build file:
dependencies {
compile 'com.android.support:appcompat-v7:18.0.+'
}
Your one dependency (of the form groupId:artifactId:version) is not quite right. You have the version listed as just +. Instead, it needs to be 18.0.+, which specifies a release version of 18.0.0 or greater.
See here for details.

Categories

Resources