Я могу запустить приложение для тестирования, но не могу создать APKAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Я могу запустить приложение для тестирования, но не могу создать APK

Сообщение Anonymous »

Мое приложение пока не содержит ошибок. Он очень хорошо работает через кнопку «Запустить приложение» на аппаратном устройстве и в эмуляторе.
Я попытался создать приложение с помощью ./gradlew assembleDebug, но получил следующую ошибку:

Код: Выделить всё

FAILURE: Build failed with an exception.

* What went wrong:
BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 67
> Unsupported class file major version 67

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
>  Get more help at https://help.gradle.org.

BUILD FAILED in 274ms
Я нашел на этом сайте и другие подобные ошибки, но ничего из этого не работает.
Это мой gradle.properties:

Код: Выделить всё

#Mon Oct 14 16:52:43 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
Это мое build.gradle:app:

Код: Выделить всё

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.dagger.hilt.android'
id 'com.google.devtools.ksp'
}

android {
namespace 'com.user.project'
compileSdk 34

defaultConfig {
applicationId "com.user.project"
minSdk 28
targetSdk 33
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_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.5.15'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

dependencies {
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.6'
implementation 'androidx.activity:activity-compose:1.9.2'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation 'androidx.compose.material:material:1.7.3'
implementation "com.google.dagger:hilt-android:2.44"
implementation "com.github.bumptech.glide:compose:1.0.0-alpha.1"
implementation "androidx.navigation:navigation-compose:2.8.2"
implementation "androidx.hilt:hilt-navigation-compose:1.2.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.6'
implementation 'com.unboundid:unboundid-ldapsdk:6.0.7'
implementation "androidx.compose.material:material-icons-extended:$compose_ui_version"

implementation fileTree(dir: "libs", include: ['*.aar'])

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"

ksp "com.google.dagger:hilt-android-testing:2.42"
ksp "com.google.dagger:hilt-compiler:2.48"
}
Это проект build.gradle:

Код: Выделить всё

buildscript {
ext {
compose_ui_version = '1.7.3'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.6.1' apply false
id 'com.android.library' version '8.6.1' apply false
id 'org.jetbrains.kotlin.android' version '1.9.25' apply false
id 'com.google.dagger.hilt.android' version '2.48' apply false
id 'com.google.devtools.ksp' version '1.9.25-1.0.20' apply false
}
И settings.gradle:

Код: Выделить всё

pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "MCx Contacts"
include ':app'
Я также пытался очистить проект и перестроить его. Я также удалил папки .idea и .gradle в проекте и папку Cache в папке gradle. Черт возьми, я даже удалил папку ~/.gradle, чтобы посмотреть, повлияет ли это на что-нибудь.
Версия Java установлена ​​на GRADLE_LOCAL_JAVA_HOME, что соответствует среде выполнения JetBrains 17.0.11. aarch84/Applications/Android Studio.app/Contents/jbr/Contents/Home

Подробнее здесь: https://stackoverflow.com/questions/790 ... ild-an-apk
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»