在添加android_alarm_manager之前,应用程序运行正常。为什么现在显示“ Gradle构建无法生成Android软件包。”?

时间:2019-07-16 22:09:27

标签: android gradle plugins flutter android-alarms

应用运行正常,直到执行以下操作:

  • 已添加: android_alarm_manager: ^0.4.1+7

  • 将我的AndroidManifest更改为:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.package_name">

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>


    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="package_name"
        android:icon="@mipmap/ic_launcher">

        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->

            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <service
            android:name="io.flutter.plugins.androidalarmmanager.AlarmService"
            android:permission="android.permission.BIND_JOB_SERVICE"
            android:exported="false"/>
        <receiver
            android:name="io.flutter.plugins.androidalarmmanager.AlarmBroadcastReceiver"
            android:exported="false"/>
        <receiver
            android:name="io.flutter.plugins.androidalarmmanager.RebootBroadcastReceiver"
            android:enabled="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>
    </application>
</manifest>
  • 删除所有构建文件夹并运行flutter clean

  • 然后运行带有风味(dev)的flutter应用程序:

  • 出现以下错误:

Gradle build failed to produce an Android package.

  • 我还注意到no apk is generated in the path: build/app/outputs" (no outputs folder)

我在网上四处张望,显然是由于抖动对apk路径(https://github.com/flutter/flutter/issues/18232https://github.com/flutter/flutter/issues/34882)进行了硬编码,并且由于未生成apk(由上一点解释),所以导致了这个问题有道理。

我只是不明白为什么添加此插件(android_alarm_manager)会以某种方式导致这种情况。

我以前使用各种口味运行过该应用,并且可以正常运行(当我删除插件时也可以运行)

我在这里也看到了这个答案,建议升级gradle(https://stackoverflow.com/a/56232099/4131960),但是我已经在使用更高的版本。

我正在使用以下版本:

  • Gradle

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

    classpath 'com.android.tools.build:gradle:3.3.2'

  • SDK的 compileSdkVersion 28 minSdkVersion 21 targetSdkVersion 28

  • 香料

flavorDimensions "flavors"
    productFlavors {
        dev {
            dimension "flavors"
            applicationIdSuffix ".dev"
            versionNameSuffix "-dev"
        }
        prod {
            dimension "flavors"
        }
    }

由于我实际上尚未将此插件添加到实现中(即创建警报),所以我希望运行该应用程序不会出现问题

0 个答案:

没有答案