【问题标题】:Error while generating signed apk when i use google map?使用谷歌地图生成签名apk时出错?
【发布时间】:2017-08-29 10:17:04
【问题描述】:

您好,我在生成签名 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
        }
       }

这是我的清单:

       <?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>

代码没有错误,即使 apk 正在构建,但是当我尝试生成签名 apk 时,它显示上述错误,我在我的项目中使用谷歌地图。请帮助。

【问题讨论】:

  • 您是否尝试将建议的lintOptions 添加到您的build.gradle
  • 不,还没有。我需要添加吗?

标签: android google-maps android-manifest


【解决方案1】:

Gradle 的 Android 插件允许您使用模块级 build.gradle 文件中的 lintOptions {} 块配置某些 lint 选项,例如运行或忽略哪些检查。

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

然后清理重建运行

【讨论】:

  • 我该怎么办?我在我的 gradle 中没有看到 android{...} .. hastebin.com/okajehivob.pl
  • 对不起.. 我找到了那个文件。误打开主文件
  • @Spectre 好的。前进
  • 在终端运行gradlew lint --debug会显示错误报告的保存路径,阅读并纠正错误
【解决方案2】:

将 lintOptions 设置为忽略错误或警告并不是解决此问题并等待应用在发布版本中崩溃的方法。

解决此问题的理想方法是确保我们在构建 APK 之前修复错误。您可以在 Android Studio (Android Studio Main Menu &gt; Analyze &gt; Inspect Code) 中运行“检查代码”实用程序。选择检查范围为Whole Project 并运行该实用程序。修复所有报告的错误,您应该能够构建 APK。

请注意,如果您想摆脱这个问题,就必须修复每一个错误。还有一点需要注意:Lint 实用程序会自动为您提供(在大多数情况下)修复错误的选项。使用您的判断来使用/不使用它们。

附注:如果您使用任何自定义模块并且您可以访问源代码,请确保没有使用与您正在编译和定位的 SDK 版本相反的已弃用 API。

在解决了所有潜在的导致崩溃的错误后,您仍然遇到问题,然后将 lintOption abortOnError 设置为 false,但将选项 checkReleaseBuilds 保留为 true,以便您可以继续构建 APK 并在构建时仍会看到错误,并根据需要进行修复。

【讨论】:

  • 这是理想的方法和最佳实践。如果上述步骤也没有修复错误,请尝试在此路径查找错误 - /app/build/reports/lint-results-release-fatal.xml 参考 - stackoverflow.com/questions/24098494/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-08
  • 1970-01-01
  • 1970-01-01
  • 2017-10-15
  • 1970-01-01
相关资源
最近更新 更多