Skip to content

Commit cb89057

Browse files
committed
build(java-version): Decrease to use JDK 11 on Android Studio native project, compatible with Unity 2022.3.x
1 parent d3d18d7 commit cb89057

File tree

6 files changed

+34
-16
lines changed

6 files changed

+34
-16
lines changed

Packages/com.benoitfreslon.vibration/MobileProjects~/Android/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ android {
3232
}
3333

3434
compileOptions {
35-
sourceCompatibility JavaVersion.VERSION_17
36-
targetCompatibility JavaVersion.VERSION_17
35+
sourceCompatibility JavaVersion.VERSION_11
36+
targetCompatibility JavaVersion.VERSION_11
3737
}
3838

3939
kotlinOptions {
40-
jvmTarget = JavaVersion.VERSION_17.toString()
40+
jvmTarget = JavaVersion.VERSION_11.toString()
4141
}
4242
}
4343

Packages/com.benoitfreslon.vibration/MobileProjects~/Android/build.gradle

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,24 @@ buildscript {
2020

2121
}
2222
dependencies {
23-
classpath 'com.android.tools.build:gradle:8.1.1'
23+
/*
24+
* Unity gradle compatibility
25+
*
26+
* | Unity version | Gradle version | Android Gradle plug-in version |
27+
| ------ | ------ | ------ |
28+
* | 2022.3.38f1+ | 7.5.1 | 7.4.2 |
29+
*
30+
* If you wish use a new JDK + Gradle plugin versions on Android Studio, on
31+
* this Android project, try to use the values below:
32+
*
33+
* | Gradle plugin | JDK version (on .gradle files) |
34+
* | ------ | ------ |
35+
* | 8.1.1 (ow newest) | JavaVersion.VERSION_17 (ow newest) |
36+
*
37+
* References:
38+
* - https://docs.unity3d.com/2022.3/Documentation/Manual/android-gradle-overview.html
39+
*/
40+
classpath 'com.android.tools.build:gradle:7.4.2'
2441
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2542

2643
// NOTE: Do not place your application dependencies here; they belong
@@ -35,6 +52,6 @@ allprojects {
3552
}
3653
}
3754

38-
task clean(type: Delete) {
39-
delete rootProject.buildDir
55+
tasks.register('clean', Delete) {
56+
delete rootProject.layout.buildDirectory
4057
}

Packages/com.benoitfreslon.vibration/MobileProjects~/Android/lib/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ android {
3333
}
3434

3535
compileOptions {
36-
sourceCompatibility JavaVersion.VERSION_17
37-
targetCompatibility JavaVersion.VERSION_17
36+
sourceCompatibility JavaVersion.VERSION_11
37+
targetCompatibility JavaVersion.VERSION_11
3838
}
3939

4040
kotlinOptions {
41-
jvmTarget = JavaVersion.VERSION_17.toString()
41+
jvmTarget = JavaVersion.VERSION_11.toString()
4242
}
4343
}
4444

Packages/com.benoitfreslon.vibration/Runtime/Plugins/Android/java/com/benoitfreslon/unity/vibrations/lib/Vibration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ open class Vibration @JvmOverloads constructor(
3838
context?.let {
3939
if (vibrator == null) {
4040
@Suppress("DEPRECATION")
41-
vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
41+
vibrator = it.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
4242

4343
HapticData.vibrator = vibrator
4444
}

Packages/com.benoitfreslon.vibration/package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.benoitfreslon.vibration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "Vibration",
55
"description": "Native free plugin for Unity for Android, iOS and WebGL. Use custom vibrations/haptics on mobile.",
66
"unity": "2019.3",
7-
"version": "0.1.10",
7+
"version": "0.1.11",
88
"keywords": [],
99
"devDependencies": {
1010
"cross-var": "^1.1.0",

0 commit comments

Comments
 (0)