Неразрешенные ссылки на все, когда я создаю новый проект создания jetpack

#android-studio #kotlin #android-jetpack-compose

Вопрос:

я нашел здесь какую-то неисправную проблему, это новый проект с образцом кода по умолчанию, я ничего не делал с кодом, тогда моя студия Android выглядит как на изображении

студия android

Я перепробовал много вещей, включая удаление Android studio и повторную установку этой Android studio, но я все равно обнаружил ту же проблему

 plugins {  id 'com.android.application'  id 'kotlin-android' }  android { compileSdk 31  defaultConfig {  applicationId "id.rizki.nidelist"  minSdk 23  targetSdk 31  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'  useIR = true } buildFeatures {  compose true } composeOptions {  kotlinCompilerExtensionVersion compose_version  kotlinCompilerVersion '1.5.21' } packagingOptions {  resources {  excludes  = '/META-INF/{AL2.0,LGPL2.1}'  } } }  dependencies {  implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'com.google.android.material:material:1.4.0' implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.material:material:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0' implementation 'androidx.activity:activity-compose:1.4.0' testImplementation 'junit:junit:4. ' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" }  

Комментарии:

1. Это вызвано старым сломанным sdk. Очистите свой Android sdk перед переустановкой Android studio.

Ответ №1:

Вы используете неверные версии зависимостей. Самое главное, что вы используете неверную версию Kotlin или Java:

В файле оценки вашего проекта используйте это:

 buildscript {  ext {  compose_version = '1.1.0-beta01'  }  repositories {  google()  mavenCentral()  }  dependencies {  classpath 'com.android.tools.build:gradle:7.0.3'  classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31'  }  }  

В файле gradle вашего приложения:

 plugins {  id 'com.android.application'  id 'kotlin-android'  id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.10' }  apply from: 'codeinc.gradle'  android {  compileSdkVersion 31  buildToolsVersion "30.0.3"   defaultConfig {  applicationId "com.example.myapp"  minSdkVersion 21  targetSdkVersion 31  versionName "1.0"   //def yourVersionCode = getIncrementedVersionCode()  versionCode 1   testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"  }  compileOptions {  sourceCompatibility JavaVersion.VERSION_11  targetCompatibility JavaVersion.VERSION_11  }  kotlinOptions {  jvmTarget = '11'  useIR = true  }  composeOptions {  kotlinCompilerExtensionVersion compose_version  kotlinCompilerVersion '1.5.31'  } }  dependencies {   def lifecycle_version = '2.4.0'  def activity_version = '1.4.0'  def retrofit_version = "2.9.0"  def paging_version = '3.1.0-beta01'   implementation 'androidx.core:core-ktx:1.7.0'  implementation 'androidx.appcompat:appcompat:1.4.0-rc01'  implementation 'com.google.android.material:material:1.5.0-alpha05'  implementation "androidx.activity:activity-ktx:$activity_version"  implementation "androidx.activity:activity-compose:$activity_version"  implementation "androidx.compose.ui:ui:$compose_version"  implementation "androidx.compose.material:material:$compose_version"  implementation "androidx.compose.material:material-icons-extended:$compose_version"  implementation "androidx.compose.ui:ui-tooling:$compose_version"  implementation "androidx.compose.runtime:runtime-livedata:$compose_version"  implementation "androidx.compose.foundation:foundation:$compose_version"  implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-rc01"  implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"  implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"  implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0' }