Skip to content

Unresolved references when editing flutter android native plugin using Android studio. #115811

Description

@wangmir

I think it's quite old problem, but it still not resolved.

From this link, we can see that Android plugin also can be editable using Android studio.

But, when I open the very initial android platform plugin project using Android studio.
Every reference under io.flutter.* are not resolved properly.

It was always same so I temporally add dependencies on the android build.gradle when implementing Android part of the plugin like,

group 'com.example.ar_sceneview_plugin'
version '1.0-SNAPSHOT'

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'http://download.flutter.io'
            allowInsecureProtocol=true
        }
    }
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        minSdkVersion 16
    }
}

dependencies {
    // temporal dependency, please comment out when building flutter app.
    api "io.flutter:flutter_embedding_debug:1.0.0-f16e757d5d68c164d084b61d84e3b7cd14eacba9"
}

and it works, but I think it's not proper way to handle this problem.
Is there any references to edit android plugin in right way?

Steps to Reproduce

  1. flutter create --platform=android --template=plugin plugin_test
  2. Open android project using Android studio at the path of plugin_test/android/build.gradle

Expected results:
There are no unresolved references.

Actual results:

Every flutter related references (FlutterPlugin, MethodCallHandler, MethodChannel, etc.) are shown as unresolved references.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions