I am using lambda expressions in code for which to support i have added following in the module gradle :
jackOptions {
enabled true
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
But build is taking too much time , more than 10 mins , i tried searching other posts , found this mentioning problems using jack .
So i just wanted to know if anyone's using jackOptions and is able to run/build the project smoothly .
TIA .
Related
I got an error
"Android Gradle plugin requires Java 11 to run. You are currently using
Java 1.8"
I change it in IDE settings and JAVA_HOME environment variable. Errors in the terminal and build disappeared but emulator still doesn't work.
My versions
Error in the emulator
The root cause of the problem
If anyone can, please help
The reason was obvious. I changed emulator, I don't understand why, but my ex emulator stopped working. I reinstall it many times (Nexus 5x), and changed api but it did not helped. Accidentally I installed Nexus 5 and all started work corectly.
I faced this problem in react native "react-native": "0.68.1" in mac-m1 & Java version is 1.8, instead of upgrading to java-11
i resolved error by running a diagnostic check using npx #react-native-community/cli doctor
What is purpose of latest doctor command in React Native
Change your Gradle settings to this :
And keep the Gradle in App directory in v1.8 :
Regards this type of issue we can create a demo to check the configuration.
For an instance, I created a demo with Empty Activity and using Kotlin.
The configuration looks like this:
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.teststackoverflow"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// Please check this
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// Please check this
kotlinOptions {
jvmTarget = '1.8'
}
}
And we also need to check the configuration on the menu of Project Structure I always used the Embedded JDK which is in location of Android Sutido
Of courseļ¼ you can specify other JDK you want to use.
I am getting this error message while building the Cordova Android app.
Error:(159, 66) error: lambda expressions are not supported in -source
1.7 (use -source 8 or higher to enable lambda expressions)
The following compileOptions has been set on my build.gradle (module android) and build.gradle (module CordovaLib) as you can see here:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
How to resolve this problem?
The error stems from your app module. You have to set up Java 8 for each separate module. Go to File > Project Structure and update it from the Properties tab for that module or make sure you have added the compileOptions snippet to the correct build.gradle file of your app module.
If there are further modules, make sure they are set up for Java 8, before using Java 8 functionality.
For full reference, see the official Android Java 8 Support Page.
I am trying to use apache opennlp library for my android project. But build fails. As instructed in some SO posts I have checked my javac version which is 1.8.0. I have also added following compile options
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Then build error asked me to enable jack, which I did. But then I got the error mentioned in title. From a SO post I got to learn that not all Java packages are included in Android. So how do I use opennlp in my android project? Are there any other NLP libraries which are easier to integrate/use in Android?
try following
android{
jackOptions {
enabled true
}
}
add this in gradle project level.
My problem is strictly connected with IDE. I have a custom class generator and its working correctly (Classes are in gen folder after build project). Unfortunately, Android Studio cannot resolve those classes in my project. But the funniest part is: When I hardcode correct import and use this class (even when compilator turns this part to red) and run a project... it works.
I tried clean project / rebuild / reset Android Studio... nothing helped. Any ideas how to solve this?
Solution:
In my build.gradle I had to add this generated directory into source set - in my case:
android {
...
sourceSets {
main.java.srcDirs += 'build/generated/source/apt'
}
}
I hade same problem after editing gradle.build module level,
after many searching i found out that a removed
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
and after re add every thing works fine
When I enable the Jack compiler in Android Studio 2.2 the Dagger 2 component is not generated. Can Dagger 2 be used with Jack? If so, how would I go about configuring my application?
From my application's build.gradle:
jackOptions {
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
I sunk like 2 days into figuring this out. So I'm circling back to posting the findings here in case it saves someone time:
This is caused by a bug in Jack that prevents classpaths from working properly. It has to do with Jack running "in-process" (in the same JVM as the gradle daemon). Setting android.defaultConfig.jackOptions.jackInProcess to false does get beyond the "Preconditions" error but it causes other problems (2 JVMs that hog system resources) & bugs that break the build in other (worse) ways.
For now, the best solution seems to be:
Wait for the 2.3 release of the Android gradle plugin, which already has the fix for this.
Downgrade Dagger to v2.2, in the meantime.
It's the highest version that seems to avoid the Guava conflict with Jack.
EDIT: update 1/14/2017:
I ran into several OTHER problems with Jack and got so tired of it that I switched to retrolambda and kicked myself for not doing this earlier! Right now, Jack simply seems to cause more problems than it solves. Just add the lines with a plus and delete the lines with a minus and you can return to Dagger 2.8 while waiting for Jack to get it's act together!
+plugins {
+ id "me.tatarka.retrolambda" version "3.4.0"
+}
apply plugin: 'com.android.application'
+apply plugin: 'me.tatarka.retrolambda'
- jackOptions {
- enabled true
- }
For even faster retrolambda builds, add org.gradle.jvmargs=-Xmx4608M to your gradle.properties file so that dexing can happen in-process. Now, I'm on Dagger 2.8 and my clean builds are only 12 seconds, GOOD RIDDANCE, JACK!
The documentation page on Jack and Jill has instructions specific to annotation processors "to be applied at compile time but not to be included in your APK", advising the use of the annotationProcessor dependency scope. The example coincidentally mentions Dagger 2:
dependencies {
compile 'com.google.dagger:dagger:2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
}
Jack is now deprecated, see this post.
You have to upgrade your Android Studio to 3.0 preview 1, to be able to use Java 8.
If you can't upgrade it (conflict with other lib), or you want to wait for a release version, you can try this workaround solution :
Add the retrolamba lib, follow instructions here.