I'm trying to work with Java 1.7 in IntelliJ (Android Studio enough) and I believe I already have Java 1.7 selected, but somehow it insists that my Java version is 1.6 for (API 22). Here are some screenshots:
I have the following in build.gradle:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
I can use 1.7 features, but the dialog box keeps showing 1.6 which makes me feel very uneasy. Am I missing something?
Thanks
Make sure File|Project Structure|SDK Location|JDK Location points to the correct Java
Related
In many android projects, I observed this kotin stdlib dependency being added in the Gradle files. I also observed kotlin and kotlin-android plugin also adds it by default.
I am assuming adding it manually can be avoided? Or is there a downside to it?
org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}
Also, I believe
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
compileOptions can be safely dropped from 100% kotlin application.
Using kotlinOptions.jvmTarget="11" is there a downside to it, in terms of byte-code generation and byte-code compatibility with other jdk versions.
I am assuming adding it manually can be avoided? Or is there a
downside to it?
https://kotlinlang.org/docs/gradle.html#dependency-on-the-standard-library
There's no downside to it, if you want to add it manually and donot want it to be downloaded by the plugin - set this plugin kotlin.stdlib.default.dependency=false property false in gradle.properties file.
Using kotlinOptions.jvmTarget="11" is there a downside to it, in terms
of byte-code generation and byte-code compatibility with other jdk
versions.
It require AGP 7.0+ to desugar apps for API levels 29 and earlier, while targeting jvmVersion to 8 only requires AGP 3.0+.
Otherwise, byte-code is same.
compileOptions can be safely dropped from 100% kotlin application.
Android projects are not 100% Kotlin, there are generated files like BuildConfig.java.
compileOptions should be there, it can be avoided in 100% Kotlin module.
How can I define android's compileOptions within codenameone1 project ?
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Thanks in advance
We don't support that at this time. There's an RFE to add this but I can't seem to find it right now in our issue tracker.
This is a bit problematic as integrating the Android builtin Java 8 support somewhat collides with our builtin Java 8 support. I'm assuming you need this to integrate native Android code, the solution for that is rather simple. Wrap it as an AAR library which is self contained and as such should work regardless of our settings.
The solution that works for me was adding this build hint:
android.xgradle_default_config = compileOptions {sourceCompatibility 1.8; targetCompatibility 1.8}
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
}
If I build my android project using the jack & jill toolchain I can set the minimum SDK version fairly low. When I have jack enabled via:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
jackOptions {
enabled true
}
}
}
I am able to set minimum sdk to:
minSdkVersion 9
Anything lower and I get the error message:
uses-sdk:minSdkVersion 7 cannot be smaller than version 9 declared in library [com.google.android.gms:play-services-location:7.8.0] {project_folder}/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/7.8.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.google.android.gms.location" to force usage
I don't want to go that low. I am just curious if there are any pitfalls in the range of sdks from 14 to 23 that could come from using the jack compiler. Say with a target of 25, and min of 14.
Is there any odd behaviour or issues that would pop up on older versions of android?
Jack only compiles the code. It does not care what your minSdk is, that is more relevant for using android API's etc.
The reason you're getting an error when you set minSdk below 9 is because google play services requires it to be 9 or higher. If you remove the play services dependency it should work. Also see here
I have searched and could not find a solution for this problem.
Error:Buildtools 24.0.2 requires Java 1.8 or above. Current JDK version is 1.7.
My JAVA_HOME variable in path variable is pointing to C:\Program Files\Java\jdk1.8.0_101
I don't know what I am missing and I couldn't find any settings in Android Studio to change the JDK path.
Make sure that you have proper location and version of JDK
Go to File -> Project Structure. You would see this window:
You can also add compileOptions in your app/build.gradle file:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}