【问题标题】:Flutter: APK does not open the app when installed on deviceFlutter:APK在设备上安装时不会打开应用程序
【发布时间】:2021-12-13 17:00:57
【问题描述】:

我已经使用命令flutter build apk --split-per-abi 为我正在开发的应用程序构建了apk 文件。它在没有任何警告的情况下运行。

但是,当我尝试在手机上安装该应用时,它无法打开。我收到一条消息说应用程序已正确安装,我什至看到应用程序带有自定义图标,但是当我打开它时它不起作用。

这是我的build.gradle,以防万一

android {
    compileSdkVersion 31

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "<ID>"
        minSdkVersion 23
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

编辑:我使用 flutter clean 删除了我的构建,当我再次构建 apk 时出现以下错误。

Building with sound null safety 

Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider-2.0.6\android\src\main\java\io\flutter\plugins\pathprovider\PathProviderPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-2.5.4\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\printing-5.6.0\android\src\main\java\net\nfet\flutter\printing\PrintingPlugin.java uses or overrides a deprecated API.       
Note: Recompile with -Xlint:deprecation for details.
Running Gradle task 'assembleRelease'... 

               

【问题讨论】:

  • 试试我的回答here希望对你有帮助
  • 我试过了,但是当我安装应用程序时,我收到一条消息说“应用程序未安装”
  • 你能告诉我,如果你使用了获取和发布数据等在线功能,你可以设置互联网权限吗?
  • 我正在使用 firebase..

标签: android flutter apk flutter-build


【解决方案1】:

您是否尝试在发布模式下运行应用程序?

要在发布模式下运行应用程序,试试这个-

flutter run --release

这样,您就可以看到在运行时触发了哪些错误并进行相应的调试。

据我所知,我认为这可能与 proguard 规则有关。

【讨论】:

  • 在发布模式下运行时遇到了什么错误?
  • 另外,尝试使用此命令构建您的应用程序,如果它与 proguard 规则有任何关系,则此命令将起作用。颤振构建 apk --release --split-per-abi --no-shrink
  • 你试过不收缩命令吗?
  • 在调试模式下应用是否正常工作?
猜你喜欢
  • 2013-12-15
  • 1970-01-01
  • 1970-01-01
  • 2021-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-19
  • 1970-01-01
相关资源
最近更新 更多