尝试解决在 AndroidManifest.xml 中检测到的重复包
Posted
技术标签:
【中文标题】尝试解决在 AndroidManifest.xml 中检测到的重复包【英文标题】:Trying to resolve duplicate packages detected in AndroidManifest.xml 【发布时间】:2020-01-12 18:12:19 【问题描述】:我有一个 android 应用程序(以及随附的 web/appengine 应用程序),可以很好地与端点 v1 一起工作,我正在尝试按照现在的需要构建/使用端点 v2。我将每个项目都转换为 Maven 项目,但无法构建 android 应用程序。
这是我当前的错误:
[INFO]
[INFO] ------------------< TopCaddieMobile:TopCaddieMobile >-------------------
[INFO] Building TopCaddie 0.0.1-SNAPSHOT
[INFO] --------------------------------[ apk ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ TopCaddieMobile ---
[INFO] Deleting C:\Users\steve\eclipse-workspace\TopCaddieMobile\target
[INFO]
[INFO] --- android-maven-plugin:4.3.0:generate-sources (default-generate-sources) @ TopCaddieMobile ---
[INFO] Manifest copied from C:\Users\steve\eclipse-workspace\TopCaddieMobile\src\main\AndroidManifest.xml to C:\Users\steve\eclipse-workspace\TopCaddieMobile\target\AndroidManifest.xml
[INFO] Extracting libs
[INFO] Extracting aar support-compat...
[INFO] Extracting aar runtime...
[INFO] Extracting aar versionedparcelable...
[INFO] Extracting aar cursoradapter...
[INFO] Extracting aar support-core-utils...
[INFO] Extracting aar documentfile...
[INFO] Extracting aar loader...
[INFO] Extracting aar livedata...
[INFO] Extracting aar runtime...
[INFO] Extracting aar livedata-core...
[INFO] Extracting aar localbroadcastmanager...
[INFO] Extracting aar print...
[INFO] Extracting aar support-fragment...
[INFO] Extracting aar support-core-ui...
[INFO] Extracting aar customview...
[INFO] Extracting aar viewpager...
[INFO] Extracting aar coordinatorlayout...
[INFO] Extracting aar drawerlayout...
[INFO] Extracting aar slidingpanelayout...
[INFO] Extracting aar interpolator...
[INFO] Extracting aar swiperefreshlayout...
[INFO] Extracting aar asynclayoutinflater...
[INFO] Extracting aar viewmodel...
[INFO] Extracting aar support-vector-drawable...
[INFO] Extracting aar animated-vector-drawable...
[ERROR] Error when generating sources.
org.apache.maven.plugin.MojoExecutionException:
Duplicate packages detected in AndroidManifest.xml files
Such scenario generally means that the build will fail with a compilation error due to missing resources in R file.
You should consider renaming some of the duplicate packages listed below to avoid the conflict.
Conflicting artifacts:
[animated-vector-drawable, support-vector-drawable] have similar package='android.support.graphics.drawable'
You can downgrade the failure to a warning by setting the 'failOnDuplicatePackages' plugin property to false.
at com.simpligility.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.checkPackagesForDuplicates (GenerateSourcesMojo.java:746)
at com.simpligility.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute (GenerateSourcesMojo.java:326)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.134 s
[INFO] Finished at: 2020-01-12T11:53:35-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.simpligility.maven.plugins:android-maven-plugin:4.3.0:generate-sources (default-generate-sources) on project TopCaddieMobile:
这是我的 pom 文件:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TopCaddieMobile</groupId>
<artifactId>TopCaddieMobile</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>TopCaddie</name>
<packaging>apk</packaging>
<properties>
<android.sdk.path>
C:\Android\android-sdk
</android.sdk.path>
</properties>
<repositories>
<repository>
<id>com.android.support</id>
<name>appcompat Repository</name>
<url>https://maven.google.com</url>
<layout>default</layout>
</repository>
<!--
<repository>
<id>com.android.support</id>
<name>appcompat Repository</name>
<url>https://mvnrepository.com/artifact/com.android.support/appcompat-v7/</url>
<layout>default</layout>
</repository>
-->
</repositories>
<dependencies>
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>28.0.0</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.3.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.76</version>
<configuration>
<!-- deploy configuration -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<configuration>
<rules><dependencyConvergence/></rules>
</configuration>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.simpligility.maven.plugins
</groupId>
<artifactId>
android-maven-plugin
</artifactId>
<versionRange>[4.3.0,)</versionRange>
<goals>
<goal>emma</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
这是我的清单:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="26" android:versionName="4.2.6"
package="com.topcaddie">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<permission android:name="com.topcaddiemobile.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.topcaddiemobile.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="com.android.vending.BILLING" />
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="24"/>
<application
android:allowBackup="true"
android:icon="@drawable/golf"
android:label="@string/app_name"
android:name="com.topcaddiemobile.GolfApp"
android:theme="@style/Theme.Black.WActionBar"
android:supportsRtl="true"
>
<!-- android:debuggable="false" -->
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.TermsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!--
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.TermsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
-->
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.PreMainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.AccountActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.TopTabs">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.SettingsActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.CopyHoleActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.Hole_Play_Tabs">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/title_activity_main"
android:name="com.topcaddiemobile.FragmentHolderActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/player_title"
android:name="com.topcaddiemobile.players.PlayerViewListActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/course_title"
android:name="com.topcaddiemobile.CourseListActivity"
android:parentActivityName=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/course_title"
android:name="com.topcaddiemobile.RequestCourseActivity"
android:parentActivityName=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="@string/course_title"
android:name="com.topcaddiemobile.CourseWebSendActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="Courses on TopCaddie.com"
android:name="com.topcaddie.old.CourseFromWebActivity">
>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="Courses on TopCaddie.com"
android:name="com.topcaddie.old.CourseWebActivity">
>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:label="Courses on TopCaddie.com"
android:name="com.topcaddiemobile.CourseGAEWebActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.VoiceHandler">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.ShotStatActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.HoleScoreActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.AddFeatureActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.HoleScoreEditActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:configChanges="orientation"
android:name="com.topcaddiemobile.HoleActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:configChanges="orientation" android:name="com.topcaddiemobile.HoleLocationActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:configChanges="orientation"
android:name="com.topcaddiemobile.HoleClubChoiceActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.ScorecardActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.ScoreActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.shots.ShotViewListActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.shots.ShotStatListActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.players.AddPlayerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.topcaddiemobile.clubs.AddClubActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<service android:name="com.topcaddiemobile.GCMIntentService"/>
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.topcaddiemobile"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.topcaddiemobile"/>
</intent-filter>
</receiver>
<activity android:launchMode="singleTop" android:name="com.topcaddiemobile.RegisterActivity"/>
</application>
我没有直接引用这些库中的任何一个,所以我不知道如何解决这个问题。 提前感谢您的帮助!
【问题讨论】:
【参考方案1】:在 Manifest 文件中,使用了不同的包名。请纠正他们。
在这里,在清单标签中:- package="com.topcaddie" 在应用程序和活动标签包中:- android:name="com.topcaddiemobile.GolfApp"
【讨论】:
谢谢。我更正了清单并重新“mvn clean install”。我有同样的错误。 希望此链接对您有所帮助***.com/questions/51370352/…以上是关于尝试解决在 AndroidManifest.xml 中检测到的重复包的主要内容,如果未能解决你的问题,请参考以下文章
手机看出现please add or correct eventreceiver in androidmanifest!怎么解决
错误:您是不是在 AndroidManifest.xml 中声明了此活动?尝试上课时
Android的AndroidManifest.xml中报错!如何解决?
Dexguard 删除 AndroidManifest.xml
AndroidManifest.xml 在构建后没有得到更新
org.eclipse.swt.SWTException:尝试打开 AndroidManifest.xml 时出现“小部件已释放”