@ryouemura40

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

Android Studio上でAndroid NDKが更新できません。

解決したいこと

Android Studio上で、Android NDKを26.3.11579264から、27.0.12077973に変更しろというエラーが出る。
指示通り、build.gradle.ktsに「ndkVersion = "27.0.12077973"」を追加しても何度トライしても、
flutter runという指示を与えると、毎回同様のエラーが発生する。
その解決策を教えてください。

例)
Ruby on RailsでQiitaのようなWebアプリをつくっています。
記事を投稿する機能の実装中にエラーが発生しました。
解決方法を教えて下さい。

発生している問題・エラー

出ているエラーメッセージを入力

Your project is configured with Android NDK 26.3.11579264, but the following plugin(s) depend on a different Android NDK version:

  • flutter_plugin_android_lifecycle requires Android NDK 27.0.12077973
  • geolocator_android requires Android NDK 27.0.12077973
  • google_maps_flutter_android requires Android NDK 27.0.12077973
    Fix this issue by using the highest Android NDK version (they are backward compatible).
    Add the following to C:~\AndroidStudioProjects\TestApplication\app\myapp\android\app\build.gradle.kts:

例)

NameError (uninitialized constant World)


または、問題・エラーが起きている画像をここにドラッグアンドドロップ

### 該当するソースコード
```Android Studio
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
}

android {
    ndkVersion = "27.0.12077973"
    namespace = "com.example.testapplication"
    compileSdk = 36

    defaultConfig {
        applicationId = "com.example.testapplication"
        minSdk = 24
        targetSdk = 36
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = "11"
    }
}

dependencies {

    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.material)
    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.androidx.espresso.core)
}

例)

def greet
  puts Hello World
end

自分で試したこと

上記の通り、build.gradle.ktsに「ndkVersion = "27.0.12077973"」を追加して何度か試しております。
また、SDK Toolsから「26.3.11579264」を何度アンインストールしてもFlutter Runを押すと復活します。

0 likes

1Answer

windows copilotに聞いてみました。
方法①は、既に試されている内容だったので、転載を割愛します。


方法②: gradle.properties に設定する
gradle.properties ファイルに以下を追加

android.ndkVersion=27.0.12077973

そして build.gradle 側で:

android {
    ndkVersion = android.ndkVersion
}

方法③: Android Studio で NDK をインストール・変更する

  1. Android Studio のメニューから
    Tools > SDK Manager > SDK Tools を開く
  2. 「Show Package Details」にチェックを入れる
  3. 必要な NDK バージョン(例: 27.0.12077973)をインストール
  4. local.properties に NDK のパスを指定することも可能:
ndk.dir=/Users/yourname/Library/Android/sdk/ndk/27.0.12077973

もしプロジェクトが Flutter ベースであれば、Flutter の flutter.groovy ファイルを編集する方法もありますが、これは非推奨とされています。


だそうです

0Like

Your answer might help someone💌