Форум для тех, кто программирует под Android
Anonymous
Получение ошибки из-за добавления зависимостей java.lang.NullPointerException: невозможно вызвать «String.length()», пос
Сообщение
Anonymous » 03 июл 2024, 12:23
Ошибка ниже при добавлении новых зависимостей
Код: Выделить всё
java.lang.NullPointerException: Cannot invoke "String.length()" because "
" is null
Код: Выделить всё
plugins {
id ("com.android.application")
id ("org.jetbrains.kotlin.android")
id ("dagger.hilt.android.plugin")
id ("kotlin-kapt")
alias(libs.plugins.google.gms.google.services)
}
android {
compileSdk = 34
defaultConfig {
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
multiDexEnabled = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
isMinifyEnabled = 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 {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.2.0"
}
configurations.all {
resolutionStrategy {
force("androidx.core:core-ktx:1.9.0")
}
}
}
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
implementation ("androidx.activity:activity-compose:1.3.1")
implementation ("androidx.compose.ui:ui:1.2.0")
implementation ("androidx.compose.ui:ui-tooling-preview:1.2.0")
implementation ("androidx.compose.material:material:1.2.0")
implementation(libs.androidx.lifecycle.runtime.compose.android)
testImplementation ("junit:junit:4.13.2")
androidTestImplementation ("androidx.test.ext:junit:1.1.5")
androidTestImplementation ("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation ("androidx.compose.ui:ui-test-junit4:1.20.")
debugImplementation ("androidx.compose.ui:ui-tooling:1.2.0")
debugImplementation ("androidx.compose.ui:ui-test-manifest:1.2.0")
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.test.manifest)
// Coroutine Lifecycle Scopes
implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1")
//Dagger - Hilt
implementation ("com.google.dagger:hilt-android:2.42")
kapt ("com.google.dagger:hilt-android-compiler:2.42")
kapt ("androidx.hilt:hilt-compiler:1.0.0")
implementation ("androidx.hilt:hilt-navigation-compose:1.0.0")
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-test-manifest")
debugImplementation ("androidx.compose.material:material-icons-extended-android:1.6.0-alpha05")
debugImplementation ("com.google.mediapipe:tasks-genai:0.10.14")
implementation("androidx.compose.material3:material3-android:1.2.1")
debugImplementation( platform("androidx.compose:compose-bom:2024.05.00"))
Подробнее здесь:
https://stackoverflow.com/questions/787 ... ion-cannot
1719998614
Anonymous
Ошибка ниже при добавлении новых зависимостей [code]java.lang.NullPointerException: Cannot invoke "String.length()" because " " is null [/code] [code]plugins { id ("com.android.application") id ("org.jetbrains.kotlin.android") id ("dagger.hilt.android.plugin") id ("kotlin-kapt") alias(libs.plugins.google.gms.google.services) } android { compileSdk = 34 defaultConfig { minSdk = 24 targetSdk = 34 versionCode = 1 versionName = "1.0" multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } } buildTypes { release { isMinifyEnabled = 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 { compose = true } composeOptions { kotlinCompilerExtensionVersion = "1.2.0" } configurations.all { resolutionStrategy { force("androidx.core:core-ktx:1.9.0") } } } dependencies { implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.11.0") implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1") implementation ("androidx.activity:activity-compose:1.3.1") implementation ("androidx.compose.ui:ui:1.2.0") implementation ("androidx.compose.ui:ui-tooling-preview:1.2.0") implementation ("androidx.compose.material:material:1.2.0") implementation(libs.androidx.lifecycle.runtime.compose.android) testImplementation ("junit:junit:4.13.2") androidTestImplementation ("androidx.test.ext:junit:1.1.5") androidTestImplementation ("androidx.test.espresso:espresso-core:3.5.1") androidTestImplementation ("androidx.compose.ui:ui-test-junit4:1.20.") debugImplementation ("androidx.compose.ui:ui-tooling:1.2.0") debugImplementation ("androidx.compose.ui:ui-test-manifest:1.2.0") implementation(libs.androidx.lifecycle.runtime.ktx) implementation(libs.androidx.activity.compose) implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.ui) implementation(libs.androidx.ui.graphics) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.ui.test.junit4) debugImplementation(libs.androidx.ui.test.manifest) // Coroutine Lifecycle Scopes implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1") //Dagger - Hilt implementation ("com.google.dagger:hilt-android:2.42") kapt ("com.google.dagger:hilt-android-compiler:2.42") kapt ("androidx.hilt:hilt-compiler:1.0.0") implementation ("androidx.hilt:hilt-navigation-compose:1.0.0") androidTestImplementation("androidx.compose.ui:ui-test-junit4") debugImplementation("androidx.compose.ui:ui-test-manifest") debugImplementation ("androidx.compose.material:material-icons-extended-android:1.6.0-alpha05") debugImplementation ("com.google.mediapipe:tasks-genai:0.10.14") implementation("androidx.compose.material3:material3-android:1.2.1") debugImplementation( platform("androidx.compose:compose-bom:2024.05.00")) [/code] Подробнее здесь: [url]https://stackoverflow.com/questions/78701147/getting-error-due-to-adding-dependencies-java-lang-nullpointerexception-cannot[/url]