Error while generating signed apk when i use googl

2019-07-15 04:01发布

问题:

Hello i am getting this error while generating signed apk :

      Error:Execution failed for task ':app:lintVitalRelease'.
        > Lint found fatal errors while assembling a release target.
       To proceed, either fix the issues identified by lint, or modify your      build script as follows:
         ...
       android {
       lintOptions {
        checkReleaseBuilds false
          // Or, if you prefer, you can continue to check for errors in release builds,
         // but continue the build even when errors are found:
        abortOnError false
        }
       }

This is my manifest :

       <?xml version="1.0" encoding="utf-8"?>
       <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="android.OMMSoftware.Navsahydri">

       <uses-permission android:name="android.permission.INTERNET" />
       <uses-permission  android:name="android.permission.ACCESS_NETWORK_STATE"  />
       <uses-permission
       android:name="android.permission.ACCESS_FINE_LOCATION"
       android:protectionLevel="signature" />
       <uses-permission
       android:name="android.permission.ACCESS_COARSE_LOCATION"
       android:protectionLevel="signature" />

       <uses-library
       android:name="com.google.android.maps"
       android:required="true" />

       <application
        android:allowBackup="true"
        android:icon="@drawable/logo_circular"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/MyMaterialTheme">
       <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyDjqmmXd1d1yk7BtncDQgXSmya-NdBkc2w" />

        <activity android:name=".Splash">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        </activity>
        <activity android:name=".Home" />
        <activity android:name=".Gallery" />
        <activity android:name=".Contactus" />
        <activity android:name=".Placements"></activity>
        </application>
        </manifest>

code is error free,even apk is building,but when i try to generate signed apk it shows above error,I am using google map in my project.Please help.

回答1:

The Android plugin for Gradle allows you to configure certain lint options, such as which checks to run or ignore, using the lintOptions {} block in your module-level build.gradle file.

  android {
  ...
  lintOptions {
            checkReleaseBuilds false
            abortOnError false
            ignoreWarnings true //false
              }
       }

Then Clean-Rebuild and Run .



回答2:

Setting the lintOptions to ignore errors or warnings is not the way to go about this and wait for the app to crash in a release build.

The ideal way to solve this problem is to ensure we fix the errors before building an APK. You can run the "Inspect Code" utility from within Android Studio (Android Studio Main Menu > Analyze > Inspect Code). Choose the Inspection Scope as Whole Project and run the utility. Fix all reported errors and you should be able to build the APK.

Please note, every single error has to be fixed if you want to get rid of this problem. Another point to note: The Lint utility automatically gives you options (in most cases) to fix the errors. Use your judgement to use/not use them.

Side Note: If you are using any custom modules and you have access to Source code, ensure no deprecated APIs are being used that goes in-contra to the SDK versions you are compiling and targeting.

After all potential crash-causing-errors have been resolved and you still encounter the issue, then set the lintOption abortOnError to false, but keep the option checkReleaseBuilds to true, so you can continue to build the APK and still see the errors while building and fix them as required.