Skip to content

Commit

Permalink
Update Camera2Sample to work on the latest AndroidStudio versions
Browse files Browse the repository at this point in the history
Update the gradle files and dependencies for the Camera2Basic project to
properly compile and run on Android Studio Koala and Gradle plugin 8.5
  • Loading branch information
vcaen committed Jul 12, 2024
1 parent 3618590 commit 42b0360
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 33 deletions.
32 changes: 17 additions & 15 deletions Camera2Basic/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -48,40 +49,41 @@ android {

buildFeatures {
viewBinding true
dataBinding true
}
}

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
Expand Down
6 changes: 3 additions & 3 deletions Camera2Basic/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
~ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.android.camera2.basic">
xmlns:tools="http://schemas.android.com/tools">

<!-- Permission declarations -->
<uses-permission android:name="android.permission.CAMERA" />
Expand All @@ -35,7 +34,8 @@
<activity
android:name="com.example.android.camera2.basic.CameraActivity"
android:clearTaskOnLaunch="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:exported="true">

<!-- Main app intent filter -->
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

</FrameLayout>
2 changes: 1 addition & 1 deletion Camera2Basic/app/src/main/res/layout/fragment_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

</FrameLayout>
8 changes: 4 additions & 4 deletions Camera2Basic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

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 {
google()
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
Expand All @@ -42,6 +42,6 @@ allprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
4 changes: 2 additions & 2 deletions Camera2Basic/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
13 changes: 7 additions & 6 deletions Camera2Basic/utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion Camera2Basic/utils/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<manifest package="com.example.android.camera.utils" />
<manifest/>

0 comments on commit 42b0360

Please sign in to comment.