-
카테고리
-
세부 분야
모바일 앱 개발
-
해결 여부
미해결
나만의 웹브라우져 01 코딩 후 실행하면 아래와 같은 오류가 뜨네요
23.11.20 07:58 작성 23.11.20 21:02 수정 조회수 751
0
We recommend using a newer Android Gradle plugin to use compileSdk = 34 This Android Gradle plugin (8.0.2) was tested up to compileSdk = 33. You are strongly encouraged to update your project to use a newer Android Gradle plugin that has been tested with compileSdk = 34. If you are already using the latest version of the Android Gradle plugin, you may need to wait until a newer version with support for compileSdk = 34 is available. To suppress this warning, add/update android.suppressUnsupportedCompileSdk=34 to this project's gradle.properties.
안드로이드 스튜디오버젼이 강사님과 달라 아직 헤메고 있습니다
MainActivity.kt
import android.os.Bundle
import android.webkit.WebView
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowForward
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
HomeScreen()
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeScreen() {
Scaffold (
topBar = {
TopAppBar(
title = { Text("")},
actions = {
IconButton(onClick = {
}){
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = "back",
tint = Color.White
)
}
IconButton(onClick = {
}){
Icon(
imageVector = Icons.Default.ArrowForward,
contentDescription = "forward",
tint = Color.White
)
}
}
)
}
) { paddingValues ->
OutlinedTextField(
value = "",
onValueChange = {},
label = { Text("https://")},
modifier = Modifier
.padding(paddingValues)
.fillMaxWidth(),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
keyboardActions = KeyboardActions(onSearch = {}),
)
Spacer(modifier = Modifier.height(16.dp))
MyWebView()
}
}
@Composable
fun MyWebView() {
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = {
WebView(it).apply {
loadUrl("https://google.com")
}
},
update = {},
)
}
build.gradle(Project)
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}
build.gradle(Module :app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.dongguntech.compose_mywebbrowser'
compileSdk 34
defaultConfig {
applicationId "com.dongguntech.compose_mywebbrowser"
minSdk 26
targetSdk 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8.10'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.3'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
var lifecycle_version = "2.5.1" // 2.6.2 버젼은 오류가 남
var arch_version = "2.1.0"
// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
// ViewModel utilities for Compose
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version")
// LiveData
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version")
// Lifecycles only (without ViewModel or LiveData)
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version")
// Saved state module for ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version")
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
// optional - helpers for implementing LifecycleOwner in a Service
implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version")
// optional - ProcessLifecycleOwner provides a lifecycle for the whole application process
implementation("androidx.lifecycle:lifecycle-process:$lifecycle_version")
// optional - ReactiveStreams support for LiveData
implementation("androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version")
// optional - Test helpers for LiveData
testImplementation("androidx.arch.core:core-testing:2.2.0:78")
// optional - Test helpers for Lifecycle runtime
testImplementation ("androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version")
implementation "androidx.compose.animation:animation:1.5.4"
implementation "androidx.compose.foundation:foundation:1.5.4"
implementation "androidx.compose.material:material:1.5.4"
implementation "androidx.compose.material3:material3:1.1.2"
implementation "androidx.compose.runtime:runtime:1.5.4"
implementation "androidx.compose.ui:ui:1.5.4"
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.core:core-ktx:1.12.0'
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation 'androidx.activity:activity-compose:1.8.1'
implementation "androidx.wear.compose:compose-foundation:1.2.1"
implementation "androidx.wear.compose:compose-material:1.2.1"
implementation "androidx.wear.compose:compose-navigation:1.2.1"
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
implementation platform('androidx.compose:compose-bom:2022.10.00')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
}
참고로 제가 사용중인 안드로이드 스튜디오버젼은
Android Studio Flamingo | 2022.2.1 Patch 2
입니다
답변을 작성해보세요.
1
shafeel2
질문자2023.11.20
말씀주신대로 안드로이드스튜디오를 업데이트 하니
오류가 사라졌습니다
다시한번 강사님의 노고에 감사드리고
늘 건강하시고 부자되세요
Android Studio Giraffe | 2022.3.1 Patch 4
0
오준석
지식공유자2023.11.20
에러 메시지만 보면 build.gradle(Module :app) 에서 complieSdk=33, targetSdk=33 으로 고치면 될 것 같습니다.
참고로 안드로이드 스튜디오를 최신으로 업데이트 하면 compileSdk=34로도 잘 되는 것을 확인했습니다.
현재 제 버전은 Giraffe, 2022.3.1 Patch 4 입니다.
https://github.com/junsuk5/android-compose/tree/master/examples/MyWebBrowser
답변 2