import android.support.v4.app.ActivityCompat;

huangapple go评论99阅读模式
英文:

import android.support.v4.app.ActivityCompat;

问题

以下是您添加了“simple_permissions”软件包后出现的错误。我应该如何修复这个问题?我最近升级了Flutter,在升级之前,它的工作非常正常。

/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:9: 错误: 找不到符号
import android.support.v4.app.ActivityCompat;

/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:9: 错误: 找不到符号
import android.support.v4.app.ActivityCompat;

  符号:   类 ActivityCompat
  位置: 包 android.support.v4.app
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:10: 错误: 包 android.support.v4.content 不存在
import android.support.v4.content.ContextCompat;
                                 ^
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:156: 错误: 找不到符号
        ActivityCompat.requestPermissions(activity, perm, 0);
        ^
  符号:   变量 ActivityCompat
  位置: 类 SimplePermissionsPlugin
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:163: 错误: 找不到符号
        return PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(activity, permission);
  符号:   变量 ContextCompat
  位置: 类 SimplePermissionsPlugin
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:171: 错误: 找不到符号
            if (ActivityCompat.shouldShowRequestPermissionRationale(registrar.activity(), permission)) {
                ^
  符号:   变量 ActivityCompat
  位置: 类 SimplePermissionsPlugin
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:175: 错误: 找不到符号
                if (ActivityCompat.checkSelfPermission(registrar.context(), permission) == PackageManager.PERMISSION_GRANTED) {
                    ^
  符号:   变量 ActivityCompat
  位置: 类 SimplePermissionsPlugin
6 个错误

FAILURE: 构建失败。

* 出错原因:
任务执行失败 ':simple_permissions:compileDebugJavaWithJavac'。
> 编译失败; 有关详细信息,请参阅编译器错误输出。
* 尝试:
使用 --stacktrace 选项运行,以获取堆栈跟踪。使用 --info 或 --debug 选项获取更多日志输出。使用 --scan 获取完整洞察力。

* 在 https://help.gradle.org 获取更多帮助

3 秒内构建失败。
构建失败很可能是插件中的AndroidX不兼容性造成的。该工具将尝试使用Jetfier来解决不兼容性问题。
[!] Flutter 尝试创建文件 `android/settings_aar.gradle`,但失败了。
要手动更新 `settings.gradle`,请执行以下步骤:
    1. 将 `settings.gradle` 复制为 `settings_aar.gradle`
    2. 从 `settings_aar.gradle` 中删除以下代码:
        def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
        def properties = new Properties()
        assert localPropertiesFile.exists()
        localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "local.properties 中未设置 flutter.sdk"
        apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
异常: 请创建该文件,然后再次运行此命令。
已退出 (sigterm)
英文:

This is the error i am seeing when i add "simple_permissions" package. How can i fix this? I recently upgraded flutter and it used to work very well before the upgrade.
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:9: error: cannot find symbol
import android.support.v4.app.ActivityCompat;

/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:9: error: cannot find symbol
import android.support.v4.app.ActivityCompat;

  symbol:   class ActivityCompat
  location: package android.support.v4.app
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:10: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
                                 ^
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:156: error: cannot find symbol
        ActivityCompat.requestPermissions(activity, perm, 0);
        ^
  symbol:   variable ActivityCompat
  location: class SimplePermissionsPlugin
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:163: error: cannot find symbol
        return PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(activity, permission);
  symbol:   variable ContextCompat
  location: class SimplePermissionsPlugin
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:171: error: cannot find symbol
            if (ActivityCompat.shouldShowRequestPermissionRationale(registrar.activity(), permission)) {
                ^
  symbol:   variable ActivityCompat
  location: class SimplePermissionsPlugin
/root/flutter/.pub-cache/hosted/pub.dartlang.org/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:175: error: cannot find symbol
                if (ActivityCompat.checkSelfPermission(registrar.context(), permission) == PackageManager.PERMISSION_GRANTED) {
                    ^
  symbol:   variable ActivityCompat
  location: class SimplePermissionsPlugin
6 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':simple_permissions:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
[!] Flutter tried to create the file `android/settings_aar.gradle`, but failed.
To manually update `settings.gradle`, follow these steps:
    1. Copy `settings.gradle` as `settings_aar.gradle`
    2. Remove the following code from `settings_aar.gradle`:
        def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
        def properties = new Properties()
        assert localPropertiesFile.exists()
        localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
Exception: Please create the file and run this command again.
Exited (sigterm)

答案1

得分: 3

我建议在使用之前检查包。

似乎 simple_permissions 已经过时,自 2018 年以来未进行更新,其存储库已从 GitHub 中删除,考虑使用其他包,比如 permission_handler

干杯。

英文:

I suggest you to check the package before using it.

It seems that simple_permissions is outdated and this package hasn't been updated since 2018 and its repository is gone from github, consider using other package like permission_handler.

Cheers.

huangapple
  • 本文由 发表于 2020年5月30日 23:01:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/62104290.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定