From 42b0360cb2b121a67b528aef958ea2809771bcba Mon Sep 17 00:00:00 2001 From: Vadim Caen Date: Fri, 12 Jul 2024 15:32:35 +0200 Subject: [PATCH] Update Camera2Sample to work on the latest AndroidStudio versions Update the gradle files and dependencies for the Camera2Basic project to properly compile and run on Android Studio Koala and Gradle plugin 8.5 --- Camera2Basic/app/build.gradle | 32 ++++++++++--------- Camera2Basic/app/src/main/AndroidManifest.xml | 6 ++-- .../main/res/layout-land/fragment_camera.xml | 2 +- .../src/main/res/layout/fragment_camera.xml | 2 +- Camera2Basic/build.gradle | 8 ++--- .../gradle/wrapper/gradle-wrapper.properties | 4 +-- Camera2Basic/utils/build.gradle | 13 ++++---- .../utils/src/main/AndroidManifest.xml | 2 +- 8 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Camera2Basic/app/build.gradle b/Camera2Basic/app/build.gradle index 49498c95..5c90a4a0 100644 --- a/Camera2Basic/app/build.gradle +++ b/Camera2Basic/app/build.gradle @@ -14,18 +14,19 @@ * limitations under the License. */ -apply plugin: 'com.android.application' +apply plugin: 'android' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: "androidx.navigation.safeargs" android { - compileSdkVersion 29 + namespace "com.example.android.camera2.basic" + compileSdk 34 defaultConfig { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" applicationId "com.android.example.camera2.basic" minSdkVersion 21 - targetSdkVersion 29 + targetSdk 34 versionCode 1 versionName "1.0.0" } @@ -48,6 +49,7 @@ android { buildFeatures { viewBinding true + dataBinding true } } @@ -55,33 +57,33 @@ dependencies { implementation project(':utils') // Kotlin lang - implementation 'androidx.core:core-ktx:1.2.0' + implementation 'androidx.core:core-ktx:1.13.1' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3' // App compat and UI things - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0' - implementation "androidx.viewpager2:viewpager2:1.0.0" - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.3' + implementation "androidx.viewpager2:viewpager2:1.1.0" + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // Navigation library - def nav_version = '2.2.2' + def nav_version = '2.7.7' implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" // EXIF Interface - implementation 'androidx.exifinterface:exifinterface:1.2.0' + implementation 'androidx.exifinterface:exifinterface:1.3.7' // Glide implementation 'com.github.bumptech.glide:glide:4.11.0' kapt 'com.github.bumptech.glide:compiler:4.11.0' // Unit testing - testImplementation 'androidx.test.ext:junit:1.1.1' - testImplementation 'androidx.test:rules:1.2.0' - testImplementation 'androidx.test:runner:1.2.0' - testImplementation 'androidx.test.espresso:espresso-core:3.2.0' + testImplementation 'androidx.test.ext:junit:1.2.1' + testImplementation 'androidx.test:rules:1.6.1' + testImplementation 'androidx.test:runner:1.6.1' + testImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation 'org.robolectric:robolectric:4.3.1' // Instrumented testing diff --git a/Camera2Basic/app/src/main/AndroidManifest.xml b/Camera2Basic/app/src/main/AndroidManifest.xml index 40820b53..e27bcac8 100644 --- a/Camera2Basic/app/src/main/AndroidManifest.xml +++ b/Camera2Basic/app/src/main/AndroidManifest.xml @@ -15,8 +15,7 @@ ~ limitations under the License. --> + xmlns:tools="http://schemas.android.com/tools"> @@ -35,7 +34,8 @@ + android:theme="@style/AppTheme" + android:exported="true"> diff --git a/Camera2Basic/app/src/main/res/layout-land/fragment_camera.xml b/Camera2Basic/app/src/main/res/layout-land/fragment_camera.xml index 1656daf7..343a7fb4 100644 --- a/Camera2Basic/app/src/main/res/layout-land/fragment_camera.xml +++ b/Camera2Basic/app/src/main/res/layout-land/fragment_camera.xml @@ -36,7 +36,7 @@ android:layout_height="96dp" android:layout_gravity="center|right" android:scaleType="fitCenter" - android:background="@drawable/ic_shutter" + android:background="@drawable/ic_photo" android:contentDescription="@string/capture" /> \ No newline at end of file diff --git a/Camera2Basic/app/src/main/res/layout/fragment_camera.xml b/Camera2Basic/app/src/main/res/layout/fragment_camera.xml index a3adc3e8..ba50a0ca 100644 --- a/Camera2Basic/app/src/main/res/layout/fragment_camera.xml +++ b/Camera2Basic/app/src/main/res/layout/fragment_camera.xml @@ -36,7 +36,7 @@ android:layout_height="96dp" android:layout_gravity="bottom|center" android:scaleType="fitCenter" - android:background="@drawable/ic_shutter" + android:background="@drawable/ic_photo" android:contentDescription="@string/capture" /> \ No newline at end of file diff --git a/Camera2Basic/build.gradle b/Camera2Basic/build.gradle index 60be841e..903b2713 100644 --- a/Camera2Basic/build.gradle +++ b/Camera2Basic/build.gradle @@ -18,7 +18,7 @@ buildscript { // Top-level variables used for versioning - ext.kotlin_version = '1.5.21' + ext.kotlin_version = '1.9.20' ext.java_version = JavaVersion.VERSION_1_8 repositories { @@ -26,9 +26,9 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.android.tools.build:gradle:8.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.4" + classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.7" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -42,6 +42,6 @@ allprojects { } } -task clean(type: Delete) { +tasks.register('clean', Delete) { delete rootProject.buildDir } diff --git a/Camera2Basic/gradle/wrapper/gradle-wrapper.properties b/Camera2Basic/gradle/wrapper/gradle-wrapper.properties index 50e5e9cb..c2bd16ee 100644 --- a/Camera2Basic/gradle/wrapper/gradle-wrapper.properties +++ b/Camera2Basic/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Mar 31 20:44:51 PDT 2021 +#Thu Jul 11 22:18:48 CEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip diff --git a/Camera2Basic/utils/build.gradle b/Camera2Basic/utils/build.gradle index 1ef65fa3..86fcd555 100644 --- a/Camera2Basic/utils/build.gradle +++ b/Camera2Basic/utils/build.gradle @@ -18,11 +18,12 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 29 + namespace "com.android.example.camera.utils" + compileSdk 35 defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdk 35 versionCode 1 versionName "1.0" @@ -51,14 +52,14 @@ dependencies { // Kotlin lang implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' // App compat and UI things - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'androidx.recyclerview:recyclerview:1.3.2' // EXIF Interface - implementation 'androidx.exifinterface:exifinterface:1.2.0' + implementation 'androidx.exifinterface:exifinterface:1.3.7' // Unit testing testImplementation 'androidx.test.ext:junit:1.1.1' diff --git a/Camera2Basic/utils/src/main/AndroidManifest.xml b/Camera2Basic/utils/src/main/AndroidManifest.xml index 2e13c37a..f0e666a5 100644 --- a/Camera2Basic/utils/src/main/AndroidManifest.xml +++ b/Camera2Basic/utils/src/main/AndroidManifest.xml @@ -14,4 +14,4 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - +