I am getting this error in view bindings file generated by Android studio. I have added
buildFeatures {
viewBinding true
}
to the app build.gradle file.
In your build.gradle(:app) file,
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Try changing the java version.
I got the same error when using VERSION_11 but the VERSION_1_8 fixed the issue.
Android Studio don' t update Gradle to version 7.
Open project Structure, you can find in File, set in Project:
Android Gradle Plugin Version: 7.0.0
and
Gradle Version: 7.0.2
Compile now and all will work fine.
Updating the android studio to the latest version fixed the issue for me.
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 trying to use Robolectric 4.3.1 for testing
I get the error: java.lang.IllegalArgumentException: failed to configure com.example.loginTest: Package targetSdkVersion=30 > maxSdkVersion=29
So because of that I downloaded JDK 1.9 and changed the JDK location in the "Project Structure" dialog. I also changed my app/build.gradle file:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_9
targetCompatibility JavaVersion.VERSION_1_9
}
...
When I do that, then nothing compiles at all. It's almost as if the Android SDK is not working:
I get errors such as:
class file for android.view.ViewGroup not found
package android.content does not exist
package android.widget does not exist
etc.
I am using opentok version compile 'com.opentok.android:opentok-android-sdk:2.13.0' and i want to upgrade to compile 'com.opentok.android:opentok-android-sdk:2.16.1' but it's said it's necessary to whole project convert into AndroidX.Does it possible it without support AndroidX Please help me on this.
Thanks in Advance
OpenTok 2.16.1 does not require your project to be built with AndroidX support.
What you need to do is to use Java8 by adding this to your project:
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Yesterday I updated Android Studio Version and Kotlin plugin version.
Android Studio Version: 3.1.2
Kotlin Version: 1.2.41
When I create an Android project using this configuration, I get Kotlin Compiler warning saying
w: /home/ganeshtikone/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.2.41/9e7a6f582de73d9cdc6c56ef4e23604a0ee55768/kotlin-stdlib-jre7-1.2.41.jar: kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead
Changed as per suggestion, then I am getting following error
Unexpected inputs: ImmutableJarInput{name=org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.41, file=/home/ganeshtikone/Workspace/May-2018/fhs/app/build/intermediates/transforms/desugar/stage/debug/45.jar, contentTypes=CLASSES, scopes=EXTERNAL_LIBRARIES, status=REMOVED}
Go to Tools > Kotlin > Configure Kotlin Plugin Updates and check for updates
then in your app gradle file replace jre with jdk
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Update
Newer version is jdk8
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Important Update
Must check JDK version before setting config
Kotlin gradle config page has detailed information about this.
First of all check your kotlin version in gradle file.
if (kotlin_version == '1.2.x' ) (Use jdk NOT jre)
First check your jdk version in File > Project Structure.
Or check in build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
if (jdk_version == 1.8)
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
if (jdk_version == 1.7)
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
if (jdk_version is < 1.7)
implementation"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
else if(NO jdk version is set in Project Structure)
if(Android_Studio_Version < 2.2.1){
your_jdk_version = 1.7;
}
else {
your_jdk_version = 1.8;
}
Because Android Studio is bundled with jdk 1.8 since 2.2.1 version.
2. else if ( kotlin_version == '1.1.x') (Use jre NOT jdk)
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" // or jre8
Update Kotlin Version?
You can update Kotlin version from Tools > Kotlin > Configure Kotlin Updates
Something is transitively importing those libraries. Run Gradle task dependencies to figure out what.
In my case, it was io.vertx:vertx-lang-kotlin-coroutines:3.5.1.
If there is no update for the dependency, there is not much you can do about it
After reading Kotlin Gradle Script Topic
I find out that some ponits
If you're targeting JDK 7 or JDK 8, you can use extended versions of the Kotlin standard library which contain additional extension functions for APIs added in new JDK versions. Instead of kotlin-stdlib, use one of the following dependencies:
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
I used implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" in my project. I think it's because of compileOptions set in build.graddle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
You must swap the codes below:
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
Not jre > jdk
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Change SDK7 to Java SDK8
try this:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
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.