Android Lombok IntelliJ integration - android

I'm trying to include lombok in my android project, I'm using IntelliJ IDEA as my IDE.
The project is built with maven. I've added the lombok dependency and compiling the project with maven succeeds.
In IntelliJ I've installed the lombok plugin which also works - I see the generated getters/setters.
Hovewer, when I try to make the project in IntelliJ, the build fails:
error: cannot find symbol method setName(String)
In a standard Java environment, adding lombok to the classpath would be sufficient for the project to compile. What in the android environment is causing the compilation to fail?
EDIT: I've created an issue on the IntelliJ Bugtracker: http://youtrack.jetbrains.com/issue/IDEA-94749

I've filed a bug and they fixed it in IntelliJ IDEA 12.1:
http://youtrack.jetbrains.com/issue/IDEA-94749

have your tried to Enable annotation processing ?
go under Settings->Compiler->Annotation Processors. and make sure 'Enable annotation processing' is enabled.

Related

Migrating Android project with proguard to R8, missing rt.java file, Android Studio 4.2

I update my Android Studio version from 4.1 to 4.2 and the project is not compiling because the Proguard version was very old (4.7) and it was not compatible with Java 10, however I decided to migrate my project from proguard to R8, but the project is not compiling because of this error:
File not found: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/lib/rt.jar
Then I set R8 to false and use Proguard adding this line to my build.gradle in order to update my Proguard to a higher version:
classpath 'net.sf.proguard:proguard-gradle:6.1.1'
But still, I got the same error and not the first one that was telling me to update a newer version of Proguard.
So how I can fix that rt.jar? Maybe some directory change from one AS version and the other?, If I downgrade my android studio to 4.1 and revert all the changes that I did, the project works fine, but I want to upgrade Android Studio.
Starting from JDK 9 there rt.jar is not longer part of the JDK, see Removed rt.jar and tools.jar in JDK 9 for details.
In most cases if rt.jar was required for compilation before an rt.jar from JDK 8 should work.
However, what is the reason for using rt.jar on an Android project? Normally the android.jar supplied by Android Studio/AGP when shrinking should work.
removing -libraryjars <java.home>/lib/rt.jar from proguard.txt should be the right way to go
mentioned by #sgjesse as a comment , that should be marked in answer.
applicable only after java version 8.
There was a clause like this in the Proguard configuration, removing this solves the issue
-libraryjars <java.home>/lib/rt.jar(java/**,javax/**)

Crystax usage with IntelliJ IDEA

I have tried the Crystax sample on IDEA, and I have compiled it successfully, got it to run on my phone.
However, when I try to modify the project, IDEA throws an error about Gradle version:
Error:The project is using an incompatible version of the Android Gradle "experimental" plugin.
Please update your project to use version 0.9.0.
Then I updated it and met new problems:
Gradle version 3.3 is required. Current version is 4.1.
Please fix the project's Gradle settings.
I choose to Fix Gradle wrapper and re-import project
Then the next error appears:
Cannot set readonly property: proguardFiles for class: com.android.build.gradle.managed.BuildType
Please, is there anyone who knows how to use Crystax on IDEA IDE?
I found an alternative way, which does not relies on AS to build.
Just set your system PATH to Crystax-ndk folder, set up your Application.mk and Android.mk, and run command:
ndk-build
then you will get the result lib or executable file, then, link it to your Android project.

Import a project to Android studio faced problems

I want reading an open source project so I select k9mail for start. The recommendation was run and reading this code in Android Studio. I import k9mail project to AS 1.2.1.1 version. I download gradle 2.4 version and added this in environment variable. When I want to run this application, but I receive some errors that I describe below:
1) When I click Run (Alt+Shift+F10), select Android Application, select my module (there is k9mail) and select USB Device, then I see a warning:
No JDK specified for module 'k-9-master'.
2) When I click on Run (Shift+F10), I faced this error in messages tab:
Gradle DSL method not found: 'android()'
Possible causes:
A)The project 'k-9-master' may be using a version of Gradle that does not contain the method.Open Gradle wrapper file
B)The build file may be missing a Gradle plugin. Apply Gradle plugin
When I updated gradle to 2.4, I changed classpath 'com.android.tools.build:gradle:1.2.3' to 'classpath 'com.android.tools.build:gradle:2.4'' from build.gradle of k9mail, but my problems were not solved.
I googled but I can't find solutions for my problems.
No jdk specified for the module.
For that you have to specify the jdk path through Project Structure.
You may also verify by looking at local.properties
For gradle related issues you just kindly update your gradle build and SDKs to latest versions.
This will minimize your gradle issues.

How to include RxAndroid in project?

I'm using Android Studio. How can I include RxAndroid in my project as a subproject? I want to build it from the sourcecode.
What I've tried:
-Include it as a git submodule.
-included it in my projects settings.gradle file, "include ':rxandroid', ':app'"
Then I get: Error:Unable to find module with Gradle path ':rxandroid'.
Edit
My folder structure is as follows.
Project
-app
-rxandroid
Edit 2
I changed the folder name from rxandroid to RxAndroid. I also changed the name in the projects settings.gradle, but I still get the same error.
According to http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Multi-project-setup it should simply work by changing settings.gradle to:
include ':app', ':RxAndroid'
And it does work for me. My setup is
Android Studio 0.8.13
RxAndroid cloned from https://github.com/ReactiveX/RxAndroid
My project is using com.android.tools.build:gradle:0.12.+
EDIT:
I should mention that I'm still running Gradle 1.12. I created a new blank project in Android Studio, added RxAndroid to settings.gradle, and a build error appeared:
Error:Cause: startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/path/spock-core/0.7-groovy-1.8/3a677d19e8d3acf3bd296c4023356256d55da5a3/spock-core-0.7-groovy-1.8.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 0.7.0-groovy-1.8 is not compatible with Groovy 2.3.6. For more information, see http://versioninfo.spockframework.org
Spock location: file:/path/spock-core-0.7-groovy-1.8.jar
Groovy location: file:/path/gradle-2.1/lib/groovy-all-2.3.6.jar
It seems RxAndroid depends on Spock 0.7-groovy-1.8 which won't work with Groovy 2.3.6 of Gradle 2.1. And the latest com.android.tools.build (0.13.x) requires Gradle 2.1.
So I did the following:
in the top level build.gradle (not the app one) change the project's dependency on com.android.tools.build back to 0.12.+
change the Gradle version in gradle-wrapper.properties back to 1.12
Now the project built successfully.

Error when importing a Gradle project into Android Studio

I am trying to import a Gradle project into Android Studio and get the following error:
This project does indeed compile when I run Gradle from the command line. I can also Open the project in Android Studio (vs Import) but then it tries to build using the Eclipse build script.
The gradle build was created by hand and not via the Eclipse export function.
My problem can be resolved in one of two ways:
1) Tell me how to force Android Studio to use Gradle instead of using the Eclipse build.
2) Help me find the reason for the Gradle import error.
I am using
Android Studio 0.2.2
Gradle 1.6 via gradlew
I finally found out why this didn't work.
There are two ways to include a project from within the settings.gradle file:
include ':..:source:compA-api'
and
include "source:compA-api"
project(':source:compA-api').projectDir = new File(settingsDir, 'source/compA/api')
I had used the second form and apparently Android Studio didn't like that :)

Categories

Resources