Skip to content

Commit 42b0360

Browse files
committed
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
1 parent 3618590 commit 42b0360

8 files changed

Lines changed: 36 additions & 33 deletions

File tree

Camera2Basic/app/build.gradle

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17-
apply plugin: 'com.android.application'
17+
apply plugin: 'android'
1818
apply plugin: 'kotlin-android'
1919
apply plugin: 'kotlin-kapt'
2020
apply plugin: "androidx.navigation.safeargs"
2121

2222
android {
23-
compileSdkVersion 29
23+
namespace "com.example.android.camera2.basic"
24+
compileSdk 34
2425
defaultConfig {
2526
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2627
applicationId "com.android.example.camera2.basic"
2728
minSdkVersion 21
28-
targetSdkVersion 29
29+
targetSdk 34
2930
versionCode 1
3031
versionName "1.0.0"
3132
}
@@ -48,40 +49,41 @@ android {
4849

4950
buildFeatures {
5051
viewBinding true
52+
dataBinding true
5153
}
5254
}
5355

5456
dependencies {
5557
implementation project(':utils')
5658

5759
// Kotlin lang
58-
implementation 'androidx.core:core-ktx:1.2.0'
60+
implementation 'androidx.core:core-ktx:1.13.1'
5961
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
60-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4'
62+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
6163

6264
// App compat and UI things
63-
implementation 'androidx.appcompat:appcompat:1.1.0'
64-
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
65-
implementation "androidx.viewpager2:viewpager2:1.0.0"
66-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
65+
implementation 'androidx.appcompat:appcompat:1.7.0'
66+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.3'
67+
implementation "androidx.viewpager2:viewpager2:1.1.0"
68+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
6769

6870
// Navigation library
69-
def nav_version = '2.2.2'
71+
def nav_version = '2.7.7'
7072
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
7173
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
7274

7375
// EXIF Interface
74-
implementation 'androidx.exifinterface:exifinterface:1.2.0'
76+
implementation 'androidx.exifinterface:exifinterface:1.3.7'
7577

7678
// Glide
7779
implementation 'com.github.bumptech.glide:glide:4.11.0'
7880
kapt 'com.github.bumptech.glide:compiler:4.11.0'
7981

8082
// Unit testing
81-
testImplementation 'androidx.test.ext:junit:1.1.1'
82-
testImplementation 'androidx.test:rules:1.2.0'
83-
testImplementation 'androidx.test:runner:1.2.0'
84-
testImplementation 'androidx.test.espresso:espresso-core:3.2.0'
83+
testImplementation 'androidx.test.ext:junit:1.2.1'
84+
testImplementation 'androidx.test:rules:1.6.1'
85+
testImplementation 'androidx.test:runner:1.6.1'
86+
testImplementation 'androidx.test.espresso:espresso-core:3.6.1'
8587
testImplementation 'org.robolectric:robolectric:4.3.1'
8688

8789
// Instrumented testing

Camera2Basic/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
~ limitations under the License.
1616
-->
1717
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18-
xmlns:tools="http://schemas.android.com/tools"
19-
package="com.example.android.camera2.basic">
18+
xmlns:tools="http://schemas.android.com/tools">
2019

2120
<!-- Permission declarations -->
2221
<uses-permission android:name="android.permission.CAMERA" />
@@ -35,7 +34,8 @@
3534
<activity
3635
android:name="com.example.android.camera2.basic.CameraActivity"
3736
android:clearTaskOnLaunch="true"
38-
android:theme="@style/AppTheme">
37+
android:theme="@style/AppTheme"
38+
android:exported="true">
3939

4040
<!-- Main app intent filter -->
4141
<intent-filter>

Camera2Basic/app/src/main/res/layout-land/fragment_camera.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
android:layout_height="96dp"
3737
android:layout_gravity="center|right"
3838
android:scaleType="fitCenter"
39-
android:background="@drawable/ic_shutter"
39+
android:background="@drawable/ic_photo"
4040
android:contentDescription="@string/capture" />
4141

4242
</FrameLayout>

Camera2Basic/app/src/main/res/layout/fragment_camera.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
android:layout_height="96dp"
3737
android:layout_gravity="bottom|center"
3838
android:scaleType="fitCenter"
39-
android:background="@drawable/ic_shutter"
39+
android:background="@drawable/ic_photo"
4040
android:contentDescription="@string/capture" />
4141

4242
</FrameLayout>

Camera2Basic/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818

1919
buildscript {
2020
// Top-level variables used for versioning
21-
ext.kotlin_version = '1.5.21'
21+
ext.kotlin_version = '1.9.20'
2222
ext.java_version = JavaVersion.VERSION_1_8
2323

2424
repositories {
2525
google()
2626
mavenCentral()
2727
}
2828
dependencies {
29-
classpath 'com.android.tools.build:gradle:4.2.2'
29+
classpath 'com.android.tools.build:gradle:8.5.0'
3030
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
31-
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.4"
31+
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.7"
3232

3333
// NOTE: Do not place your application dependencies here; they belong
3434
// in the individual module build.gradle files
@@ -42,6 +42,6 @@ allprojects {
4242
}
4343
}
4444

45-
task clean(type: Delete) {
45+
tasks.register('clean', Delete) {
4646
delete rootProject.buildDir
4747
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Mar 31 20:44:51 PDT 2021
1+
#Thu Jul 11 22:18:48 CEST 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip

Camera2Basic/utils/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ apply plugin: 'com.android.library'
1818
apply plugin: 'kotlin-android'
1919

2020
android {
21-
compileSdkVersion 29
21+
namespace "com.android.example.camera.utils"
22+
compileSdk 35
2223

2324
defaultConfig {
2425
minSdkVersion 21
25-
targetSdkVersion 29
26+
targetSdk 35
2627
versionCode 1
2728
versionName "1.0"
2829

@@ -51,14 +52,14 @@ dependencies {
5152

5253
// Kotlin lang
5354
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
54-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4'
55+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
5556

5657
// App compat and UI things
57-
implementation 'androidx.appcompat:appcompat:1.1.0'
58-
implementation 'androidx.recyclerview:recyclerview:1.1.0'
58+
implementation 'androidx.appcompat:appcompat:1.7.0'
59+
implementation 'androidx.recyclerview:recyclerview:1.3.2'
5960

6061
// EXIF Interface
61-
implementation 'androidx.exifinterface:exifinterface:1.2.0'
62+
implementation 'androidx.exifinterface:exifinterface:1.3.7'
6263

6364
// Unit testing
6465
testImplementation 'androidx.test.ext:junit:1.1.1'

Camera2Basic/utils/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
~ See the License for the specific language governing permissions and
1515
~ limitations under the License.
1616
-->
17-
<manifest package="com.example.android.camera.utils" />
17+
<manifest/>

0 commit comments

Comments
 (0)