简体   繁体   English

为什么我在 Flutter 中的原生 android 代码显示错误?

[英]Why is my native android code in Flutter showing errors?

I am testing platform specific coding with Flutter.我正在使用 Flutter 测试平台特定的编码。 I opened the android folder in Android Studio, wrote my code and it shows no errors.我在 Android Studio 中打开了 android 文件夹,编写了我的代码,它没有显示任何错误。 I then moved back to Flutter which is underlining in red the Rs in the code below.然后我回到 Flutter,它在下面的代码中用红色下划线 Rs。 However, the app is working fine.但是,该应用程序运行良好。 I am wondering why an error is showing and what I can do to remove these red lines.我想知道为什么会显示错误以及如何删除这些红线。 I would be grateful for pointers.我将不胜感激。

Here is my code:这是我的代码:

public class MyTileService extends TileService {

private final int STATE_ON = 1;
private final int STATE_OFF = 0;
private int toggleState = STATE_ON;


@Override
public void onTileAdded() {
    System.out.println("onTileAdded");
}

@Override
public void onTileRemoved() {
    System.out.println("onTileRemoved");
}

@Override
public void onStartListening() {
    System.out.println("onStartListening");
}

@Override
public void onStopListening() {
    System.out.println("onStopListening");
}

@Override
public void onClick() {
    System.out.println("onClick state = " + Integer.toString(getQsTile().getState()));
    Icon icon;
    if (toggleState == STATE_ON) {
        toggleState = STATE_OFF;
        icon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spa_black_24dp);
        System.out.println("OFF");
    } else {
        toggleState = STATE_ON;
        icon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_star_border_black_24dp);
        System.out.println("ON");
    }
    getQsTile().setIcon(icon);
    getQsTile().updateTile();
}

} }

I tried cleaning the android project, uninstalling and reinstalling Flutter and Dart plugins, checking flutter doctor.我尝试清理android项目,卸载并重新安装Flutter和Dart插件,检查flutter doctor。

Here is an image:这是一张图片:

在此处输入图片说明

Flutter projects are not Gradle-based Android projects so a number of features provided by Android Studio are not available to Flutter programmers. Flutter 项目不是基于 Gradle 的 Android 项目,因此 Android Studio 提供的许多功能对 Flutter 程序员来说是不可用的。

This still is a Flutter Plugin.这仍然是一个 Flutter 插件。

Is documented here:记录在这里:

在此处输入图片说明

And you can track it here:你可以在这里跟踪它:

It seems that the first item is check, so it's only a metter of time to wait this milestone to be released.似乎第一项是检查,所以等待这个里程碑发布只是一米的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么AdMob没有在我的Android应用中显示任何广告(代码中没有错误)? - Why AdMob is not showing any ads in my Android app(there are no errors in the code)? 为什么android studio 没有为我的flutter 代码显示虚拟android 模拟器,而为java android 代码显示它? - Why is android studio not showing virtual android emulator for my flutter code, whereas its showing for java android code? 为什么 Android Studio 在上次更新后“在代码中的任何地方”都显示错误? - Why Android Studio is showing errors "everywhere in code" after last update? Android登录本机代码未显示 - Android logging in native code not showing 为什么我在android studio中的代码中出现错误? - Why am i getting errors in my code in android studio? 如何从 flutter 中的 flutter 代码向 android 本机代码发送数据 - How to send data to the android native code from the flutter code in flutter 为什么在实现facebook sdk之后构建本机响应Android应用程序会给我这些错误? - Why does building my native react android app after implementing facebook sdk gives me these errors? Flutter - 如何调试原生android代码 - Flutter - how to debug the native android code 在 Flutter Native Android 代码中实现 MVVM 架构 - Implement MVVM architecture in Flutter Native Android code 将本机 Android 代码添加到 Flutter 应用程序 - Adding native Android code to a Flutter app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM