Gradle: keyword `cvs` not allowed in java package name - java

I tried to create an Android project with package com.cvs.app and Gradle is crashing during the build. If I remove cvs from the package - works fine.
Note: cvs in the package works fine with Gradle version 3.2 and lower.
Is there a list of prohibited keywords in Gradle?
Can I overcome this limitation somehow?

As #Martheen mentioned in comments - this is a knows issue in Gradle - github.com/gradle/gradle/issues/5321
Seems to be resolved in 4.0.10

Related

The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher

I am trying tog get my React Native app (with expo modules, but not built on expo) deployed to the Google Play Store, and I keep getting this error when I try to build...
The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher.
The following dependencies do not satisfy the required version:
project ':expo' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10
My issue us, the line that it seems to be referencing, project ':expo' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10 doesn't exist anywhere in my code, maybe in the node modules but I have no way of knowing.
I have absolutely no idea what kotlin is and never heard of it before this. I tried looking around for where to upgrade by kotlin-gradle-plugin, but thats nowhere in my app.json or package.json or any other config files. I saw some message boards with similar issues telling me to change this line inside of build.gradle
classpath('com.android.tools.build:gradle:7.3.0')
to make 7.3.0 match the version I need, but I firmly believe 7.3.0 is greater than 1.6.20, so I highly doubt that solution has any actual merits
Apparently, the current version of expo-modules are incompatible with the latest version of React Native (0.70.0) and how it compiles Android Builds. I downgraded react-native to 0.69.5. This ultimately led me to other issues but hopefully this can help somebody else.

not namespaced r class sources [duplicate]

We've got a strange behaviour in an Android project we inherited. The APK builds without error but the IDE keeps complaining about missing R class in imports.
We are using Android Studio 3.3. (wrong ! see edit at bottom)
After a little more digging, we found that the R.java file is actually generated but in build\generated\not_namespaced_r_class_sources rather than the usual build\generated\sources.
Does anyone already got this ? Even better, does anyone know how to fix this ?
Thanks folks!
Edit : I was actually using Android Studio 3.2…
In my case, I have to revert the version of android build tool:
classpath 'com.android.tools.build:gradle:3.2.1' // use this version instead of 3.3.0
In my case R.java always generates in build\generated\not_namespaced_r_class_sources . You can try cleaning and rebuilding the product.
First, thanks for all your support !
After reading #Kingfisher Phuoc response, I finally found that it was an incompatibility between my Android Studio 3.2 and using Android gradle plugin 3.3.
I updated my Android Studio to match the plugin and now it is working !
It looks like the way the R class is generated have been updated in the 3.3 version (source: release notes, look for "Faster R class generation for library projects")

Javax.json.bind with Android issues

Hi all I am trying to use javax.json-b with Android and getting errors. So I include the library in gradle using this line:
implementation group: 'javax.json.bind', name: 'javax.json.bind-api', version: '1.0'
Then import it the usual way:
import javax.json.bind.annotation.JsonbProperty
Compiles fine but when I run it on any device it gives me this:
../../../home/.gradle/caches/modules-2/files-2.1/javax.json.bind/javax.json.bind-api/1.0/10332203cb05f4ab2e8bf058bfd7d99648c5ca68/javax.json.bind-api-1.0.jar
Illegal class file: Class module-info is missing a super type.
So I cleared the gradle cache incase it was a bad version, same happened, I removed the import implementation line from the build.gradle file and downloaded the jar from the maven repository but I got a similar issue.
I thought initially that this means the Java version on the Android phone is incompatible with the version the jar was compiled for. But I am less convinced of that now I think it is something else. Can anyone shed some light on this for me please?
Damien
The module-info is used only with Java 9 and up for the new "Jigsaw" module feature added with Java 9:
https://www.oracle.com/corporate/features/understanding-java-9-modules.html
AFAIK Android does not yet support Java 9, but does support most, if not all, of Java 8.
Does Android Studio 3 support Java 9 for Android development? If so, what features of Java 9 are supported?
You can delete the compiled file module-info.class, it doesn't need to be there when not using modules. You will find it inside the jar file javax.json.bind-api-1.0.jar, and you can remove it using any zip file or jar tool like winzip, winrar, gzip, zip, or jar.

Android Studio Java Module does not find dependencies

I always get problems in my Android Studio Projects when I accidentally update parts of the IDE.
Usually it is always grade which complains it can´t find build tools anymore what so ever. If anyone could give me a hint how to avoid it ( I really don't got to have the latest versions, I'd rather stick to one and avoid updates and broken projects) it would be very much appreciated.
But currently a even stranger problem occurred.
The Gradle build works but when running the code this error is thrown:
Error:(62, 22) Gradle: error: package com.apple.eawt does not exist
My build.gradle file is this.
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
My JDK versions in library/Java/JavaVirtualMachines are
1.6.0 , 1.7.0 and 1.8.0
in 1.6.0 the ui.jar ist included but as soon as I change the JDK in the project structure it tells me I must use java 1.8
Any help is appreciated!
EDIT: I managed to solve it by adding jar dependency into my build path.
I had to add the UI.jar which includes the eawt classes.
Now my application is complaining that it can´t find audio resources and images. They are in the resource folder, they worked before....
Does anybody got an idea what the source of these problems is? It's all connected, the missing com.apple.eawt which I had to add again and my resource files. What causes these problems?
Ok I found the solution myself. The jar archive which gets created by gradle was missing. I have no clue why it got lost, but after adding it again:
Module-rightclick-Module Properties-> add jar dependency-> search modulname.jar archive in module directory/build/... and add it, it worked fine again.
In my example as shown in my project folder it would be the javalib folder (module) /build/libs/javalib.jar (modulename.jar)
Here is the official documentation for this archive file:
I guess for newer versions things changed because I can't find those archives anymore in my newer projects. Does anybody know something about this?

#Generated annotation using gradlew + dagger

I'm confronting a weird issue using gradlew(4.10.2) + dagger(2.18).
The problem is when I call:
./gradlew :app:compileDebugAndroidTestKotlin
The build fails with:
Task :Common:compileDebugJavaWithJavac FAILED
/CommonModule_ProvidesGsonFactory.java:6: error: package javax.annotation.processing does not exist
import javax.annotation.processing.Generated;
/CommonModule_ProvidesGsonFactory.java:8: error: cannot find symbol
#Generated(
But if I run the task from Android Studio, the task succeed and the #Generated is not present in the dagger generated class.
Do you have some clue to avoid the #Generated annotation using ./gradlew?
if you have :
javax annotation does not exist
I have this issue on my macOS
this error occures because your jdk is above of 1.8
just add below code on build.gradle of your apps .
//Resolve jdk8+ Generation Annotations - javax annotation does not exist
compileOnly 'com.github.pengrad:jdk9-deps:1.0'
Dagger uses auto-common's GeneratedAnnotations to figure out which #Generated annotation to use. It does this based on the classpath.
What this means is that while the annotation processor is running, javax.annotation.processing.Generated is available and used in the generator, but when the resulting file is compile in another task, it is no longer on the classpath.
Potential causes could be that code was generated using a newer version of the JDK and the incremental build is invalid, requiring a full "clean & rebuild" or there is a problem with java language levels where the annotation processor runs on Java 9+, but android is compiled as Java 8 or lower.
Using ./gradlew compileDebugAndroidTestKotlin -Dorg.gradle.java.home=<Android studio jre path> solved the problem.
I had this problem when I updated my Android Studio to 4.2
The problem was solved when I upgrade the Kotlin version from 1.3.51 to 1.4.31
It seems the problem is reported and solved in this issue:
https://github.com/google/dagger/issues/1449
https://youtrack.jetbrains.com/issue/KT-32804
change to embeded Android studio version and only clean!(not rebuild) Improove #kiskae answer
I also got "package javax.annotation.processing does not exist import javax.annotation.processing.Generated" in Android Studio while trying to build the project with Gradle.
Due to some reasons I cannot upgrade any dependencies in the project. What worked for me in this case:
not only install Java 8 instead of any higher Java versions you have (you can download it from here, for example: https://www.oracle.com/ru/java/technologies/javase/javase-jdk8-downloads.html),
but also check out Project Structure -> SDK location -> JDK location and make sure that this folder really contains jdk. The right option to choose can start with JAVA_HOME, for instance.
My case was that after some update this location was set by default as embedded JDK which did not contain any jdk and as a quite newbie to Android I have spent a couple of beautiful hours trying to figure out what's wrong with my Java 8.
In my case I change "Gradle JDK" and it's work perfectly.
Go to "File ==> project structure ==> SDK Location ==> Gradle settings ==> then change the selected gradle JDK from the drop down menu "
Hope this will help you.

Categories

Resources