简体   繁体   English

权限在 flutter 版本 apk 中不起作用

[英]Permissions not working in flutter release apk

I'm new in flutter.我是 flutter 的新手。 i am creating an simple app in which i get the data from Web api and also access camera for scan QR code.我正在创建一个简单的应用程序,在其中我从 Web api 获取数据,并访问相机以扫描 QR 码。 it is working fine when i am run debug app but when i build release apk then its not working not camera and not internet even i already set permissions in AndroidManifest.xml file.当我运行调试应用程序时它工作正常但是当我构建发布 apk 时它不能工作而不是相机和互联网即使我已经在 AndroidManifest.xml 文件中设置了权限。 here is my AndroidManifest file code:-这是我的 AndroidManifest 文件代码:-

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="in.nic.rajshaladarpan.filetrackingsystem">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

   <application
        android:label="File Tracking System"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

And my pubspec.ymal file code is here:-我的 pubspec.ymal 文件代码在这里:-

name: filetrackingsystem
description: A new Flutter application.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  qrscan: ^0.2.22
  image_gallery_saver: ^1.1.0
  image_picker: ^0.6.1+4
  permission_handler: 7.1.0
  crypto: ^3.0.1
  http: ^0.13.3
  shared_preferences: ^2.0.6
  progress_dialog: ^1.2.4
  intl: ^0.16.0
  modal_progress_hud_nsn: ^0.1.0-nullsafety-0
  group_radio_button: ^1.1.0

#  permission_handler: ^5.0.1+1

dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  assets:
    - splash.jpg
    - login_bg.jpg
    - all_screen_bg.jpg
    - navigation_icon.png
    - filetracking.png
    - user.png
    - file_black.png
    - file_yellow.png
    - copy.png
    - restbg.jpg
    - headerbg.png
    - back_arrow.png
    - qr_icon.png
  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

All internet access issues answer has the same line of solution that add internet permission inside AndroidManifest file before create release build but these solution not worked for me, So here i am asking this question.所有互联网访问问题的答案都具有相同的解决方案,即在创建发布版本之前在 AndroidManifest 文件中添加互联网权限,但这些解决方案对我不起作用,所以我在这里问这个问题。 Please help me请帮我

Note that you have to also add all permissions necessary in the release version AndroidManifest , and not only in the debug AndroidManifest , but in your question, you did not mention in which file you added the permissions请注意,您还必须在发布版本AndroidManifest中添加所有必需的权限,不仅在调试AndroidManifest中,而且在您的问题中,您没有提到您在哪个文件中添加了权限

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM