작성
·
1.6K
0
답변 10
0
0
네 윈도우 사용합니다.
강사님이 말씀하신대로 JDK와 gradle 파일에서 오류가 있었더라고요.
아예 안드로이드 스튜디오 완전 삭제 후 최신 버젼으로 재 설치해서 잘 사용중입니다! 감사합니다 :)
0
0
컴파일 옵션을 1.7로 바꾸면 다른 오류가 뜨더라고요
일단 코드엔 이상 없으니 재설치나 다른 설정 건드려서 해결해봐야겠네요 감사합니다!
> Task :app:mergeExtDexDebug FAILED
AGPBI: {"kind":"error","text":"Invoke-customs are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): Landroidx/core/internal/view/SupportMenuItem;setTooltipText(Ljava/lang/CharSequence;)Landroid/view/MenuItem;","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"Static interface methods are only supported starting with Android N (--min-api 24): Landroidx/constraintlayout/core/motion/utils/TypedValues$Attributes;getId(Ljava/lang/String;)I","sources":[{}],"tool":"D8"}
Invoke-customs are only supported starting with Android O (--min-api 26)
Default interface methods are only supported starting with Android N (--min-api 24): Landroidx/core/internal/view/SupportMenuItem;setTooltipText(Ljava/lang/CharSequence;)Landroid/view/MenuItem;
Static interface methods are only supported starting with Android N (--min-api 24): Landroidx/constraintlayout/core/motion/utils/TypedValues$Attributes;getId(Ljava/lang/String;)I
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform constraintlayout-2.1.1.aar (androidx.constraintlayout:constraintlayout:2.1.1) to match attributes {artifactType=android-dex, dexing-enable-desugaring=false, dexing-incremental-transform=false, dexing-is-debuggable=true, dexing-min-sdk=16, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingNoClasspathTransform: C:\Users\H\.gradle\caches\transforms-2\files-2.1\c4d871516e96305937f335519db771b4\constraintlayout-2.1.1-runtime.jar.
> Error while dexing.
The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
See https://developer.android.com/studio/write/java8-support.html for details. Alternatively, increase the minSdkVersion to 26 or above.
0
그대로 돌려봤는데 잘 되네요~ 설정 문제인듯 합니다.
아래 부분 참고해보시겠어요?
https://stackoverflow.com/questions/48162522/android-studio-an-exception-has-occurred-in-the-compiler-1-8-0-152-release
0
package com.h.databinding_ex
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import com.h.databinding_ex.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
private lateinit var binding : ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
// 1번 방식 findViewById
// val btn = findViewById<Button>(R.id.testBtnID)
// btn.setOnClickListener {
// Toast.makeText(this,"click", Toast.LENGTH_SHORT).show()
// }
// 2번 방식 - Databinding
binding.testBtnID.setOnClickListener {
Toast.makeText(this, "click", Toast.LENGTH_LONG).show()
}
}
}
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.h.databinding_ex"
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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'
}
buildFeatures{
dataBinding = true
}
// dataBinding{
// enabled true
// }
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
<?xml version="1.0" encoding="utf-8"?>
<layout>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/testBtnID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
늦게 확인했네요;-; 여깄습니다!
0
0
0
0