Browse Source

Examples: Android+OpenGL3: update Gradle project (#8888, #8878)

scribam 1 week ago
parent
commit
361e370fe0

+ 2 - 0
docs/CHANGELOG.txt

@@ -43,6 +43,8 @@ Breaking Changes:
 
 Other Changes:
 
+- Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam]
+
 
 -----------------------------------------------------------------------
  VERSION 1.92.2b (Released 2025-08-13)

+ 6 - 4
examples/example_android_opengl3/android/.gitignore

@@ -1,12 +1,14 @@
-.cxx
-.externalNativeBuild
 build/
 *.iml
-
-.idea
 .gradle
+.idea
+.DS_Store
+/captures
+.externalNativeBuild
+.cxx
 local.properties
 
 # Android Studio puts a Gradle wrapper here, that we don't want:
 gradle/
+!gradle/libs.versions.toml
 gradlew*

+ 10 - 19
examples/example_android_opengl3/android/app/build.gradle

@@ -1,16 +1,16 @@
-apply plugin: 'com.android.application'
-apply plugin: 'kotlin-android'
+plugins {
+    alias(libs.plugins.android.application)
+    alias(libs.plugins.kotlin.android)
+}
 
 android {
-    compileSdkVersion 33
-    buildToolsVersion "33.0.2"
-    ndkVersion "25.2.9519653"
+    namespace 'imgui.example.android'
+    compileSdk 36
 
     defaultConfig {
         applicationId "imgui.example.android"
-        namespace "imgui.example.android"
-        minSdkVersion 24
-        targetSdkVersion 33
+        minSdk 24
+        targetSdk 36
         versionCode 1
         versionName "1.0"
     }
@@ -21,26 +21,17 @@ android {
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
         }
     }
-
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_11
         targetCompatibility JavaVersion.VERSION_11
     }
-
     kotlinOptions {
-        jvmTarget="11"
+        jvmTarget = '11'
     }
-
     externalNativeBuild {
         cmake {
-            path "../../CMakeLists.txt"
+            path file('../../CMakeLists.txt')
             version '3.22.1'
         }
     }
 }
-repositories {
-    mavenCentral()
-}
-dependencies {
-    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
-}

+ 2 - 1
examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools">
 
     <application
         android:label="ImGuiExample"

+ 4 - 23
examples/example_android_opengl3/android/build.gradle

@@ -1,24 +1,5 @@
-buildscript {
-    ext.kotlin_version = '1.8.0'
-    repositories {
-        google()
-        mavenCentral()
-
-    }
-    dependencies {
-        classpath 'com.android.tools.build:gradle:7.4.1'
-        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
-
-    }
-}
-
-allprojects {
-    repositories {
-        google()
-        mavenCentral()
-    }
-}
-
-task clean(type: Delete) {
-    delete rootProject.buildDir
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+plugins {
+    alias(libs.plugins.android.application) apply false
+    alias(libs.plugins.kotlin.android) apply false
 }

+ 21 - 0
examples/example_android_opengl3/android/settings.gradle

@@ -1 +1,22 @@
+pluginManagement {
+    repositories {
+        google {
+            content {
+                includeGroupByRegex("com\\.android.*")
+                includeGroupByRegex("com\\.google.*")
+                includeGroupByRegex("androidx.*")
+            }
+        }
+        mavenCentral()
+        gradlePluginPortal()
+    }
+}
+dependencyResolutionManagement {
+    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+    repositories {
+        google()
+        mavenCentral()
+    }
+}
+
 include ':app'