How to combine java native within the XML android

2019-07-29 10:16发布

问题:

I've been searching for tutorial that relates to combine native android and dart, so far this is the best https://proandroiddev.com/communication-between-flutter-and-native-modules-9b52c6a72dd2 but it wrote in kotlin, i also try to write the code on java, but when i try to call XML file and the widget using "R" are getting error, it said "cannot resolve symbol", a lot of people said that R problem are solved by clean project or rebuild, but i'm using flutter in android studio which is feature to sync, clean, or rebuild are unavailable. If you guys know the solutions i'm so glad if you wanna help

Here's my code enter image description here

回答1:

Open Android Studio, click on File > Open and choose the android folder of your flutter app project, it should be in the root directory of your app project.

That's it.



回答2:

In your_project folder you have 3 packages - lib, android and ios. If you want to work with your activity - you have to open project, which located on your_project/android. After that this problem with R have have to disappear