Openrewrite UpgradeToAndroidSDK35 execution fails due to method rewrite() in build.gradle (:app) not found


Running Openrewrite in Android Studio Quail 3 in order to upgrade an old implementation to SDK 35 throws this error:

Build file 'D:\Documents\AndroidStudioProjects\OperationTimeRecord\app\build.gradle' line: 66
A problem occurred evaluating project ':app'.
\> Could not find method rewrite() for arguments [org.openrewrite.recipe:rewrite-android:0.18.4] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

The content of said build.gradle (:app) file:

plugins {  
    id 'com.android.application'  
    id 'org.openrewrite.rewrite' version '7.38.0'  
}  
  
android {  
    compileSdk = 36  
  
    defaultConfig {  
        applicationId "com.richter_china.operationtimerecord"  
        minSdk 35  
        targetSdk 35  
        versionCode 1  
        versionName "1.0"  
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"  
    }  
  
    buildTypes {  
        release {  
            minifyEnabled false  
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'  
        }  
    }  
    dataBinding {  
        enabled = true  
    }  
    compileOptions {  
        sourceCompatibility JavaVersion.VERSION_1_8  
        targetCompatibility JavaVersion.VERSION_1_8  
    }  
    buildFeatures {  
        viewBinding true  
        buildConfig true  
    }  
    namespace 'com.richter_china.operationtimerecord'  
}  
  
dependencies {  
  
    implementation 'androidx.appcompat:appcompat:1.7.1'  
    implementation 'com.google.android.material:material:1.14.0'  
    implementation 'androidx.constraintlayout:constraintlayout:2.2.2'  
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'  
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.11.0'  
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.11.0'  
    implementation 'com.google.firebase:firebase-firestore:26.5.0'  
    testImplementation 'org.testng:testng:7.12.0'  
    androidTestImplementation 'androidx.test.ext:junit:1.3.0'  
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'  
    implementation "androidx.fragment:fragment:1.8.9"  
    def lifecycle_version = "1.1.1"  
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"  
    implementation 'androidx.activity:activity-ktx:1.13.0'  
    implementation 'androidx.fragment:fragment-ktx:1.8.9'  
    implementation 'com.google.code.gson:gson:2.14.0'  
    //implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.22"))  

    testImplementation 'junit:junit:4.13.2:'  
    implementation 'junit:junit:4.13.2'  

    //https://www.youtube.com/watch?v=RplK16\_-6mU  
    configurations.implementation {  
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'  
    }  
  
    rewrite("org.openrewrite.recipe:rewrite-android:0.18.4")  
 }  
  
rewrite {  
    activeRecipe("org.openrewrite.android.UpgradeToAndroidSDK35")  
}

As I understand it, 'org.openrewrite.rewrite' version '7.38.0' is first initialized in plugins, then rewrite("org.openrewrite.recipe:rewrite-android:0.18.4") is listed in the dependencies, and finally rewrite is called as the file's final node?

This is not a multiproject.
Openrewrite version is 7.38.0

1
Aug 10 at 2:00 AM
User Avatarcodingmechanic
#android#gradle#recipe#openrewrite

No answer found for this question yet.