android folder=> android features are missing
src/main/java/<org id>/plugin.javaimport android.support.v4.app.NotificationCompat;MainActivity class containing NotificationCompat.Builder builder;result.success... containing NotificationCompat.Builder builder;=> still complains that it can't resolve the NotificationCompat symbol
If you try the same steps in a regular Android project, it works fine.
cc @jakobr-google you had some theory for the cause of this?
I thinks it's the same problem as issue #966. See my comment there, and the reply to it.
cc @stevemessick. This makes it very, very hard to implement android plugins.
For clarity: I'm using Android Studio 3.0. I don't recall it being this broken in Android 2.3, but not entirely sure.
When Android Studio generates a project (using default values for everything) it's build.gradle has a dependencies section that looks like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
The second entry is key here. If we add an entry for appcompat to the build.gradle of an Android module generated by Flutter, and open that module as a top-level project in Android Studio, then everything works as expected. All the menu entries are enabled because it is just an Android Studio project (more-or-less). More precisely, it is a JAVA-MODULE with a java-gradle facet, and it has a sub-module with an android-gradle facet.
Our top-level Flutter project is a WEB-MODULE and it has no facets. I'm investigating how to change the top-level project to look more like an Android Studio project, but so far all I get are lots of errors. In addition to many differences in the Build menu, a "real" Android Studio project has a hammer icon next to the run configuration list that triggers a Gradle build. We should have that, too.
The additional Build menu items and the tool bar icon show up after the top-level project is converted to a java-gradle project. We have to add two files:
The module definition (project.iml) needs to be edited:
type to JAVA_MODULEexternal.system.id="GRADLE" to the <module> tagThat is not enough to make everything work, but the menu items will appear.
The Flutter project foo and its Android module foo/androd are completely separate IntelliJ/Android Studio projects. Each must be opened as top-level projects for full editing support. See:
https://github.com/flutter/flutter-intellij/blob/master/docs/android.md
Confirmed that the following now works:
flutter create foobarfoobar/android (the android part is important!)MainActivity.java and add import android.support.v4.app.NotificationCompat;=> will now see the error mentioned at the top of this bug. That is by-design; we need to tell gradle where it's located
build.gradle (Module: app)compile 'com.android.support:support-v4:+' under dependencies at the bottom=> import should resolve
Most helpful comment
Confirmed that the following now works:
flutter create foobarfoobar/android(theandroidpart is important!)MainActivity.javaand addimport android.support.v4.app.NotificationCompat;=> will now see the error mentioned at the top of this bug. That is by-design; we need to tell gradle where it's located
build.gradle (Module: app)compile 'com.android.support:support-v4:+'underdependenciesat the bottom=> import should resolve