为什么我的 android 库在另一个项目中使用时会生成一个额外的 apk?

问题描述 投票:0回答:3

我创建了一个简单的 android 库。问题是,无论何时在任何项目中使用它,并为该项目生成一个 apk,都会安装两个不同的 apk 实例。

就像上面的例子一样,一旦我在项目中添加库并运行它,就会安装两个不同的 apk。

我知道问题出在图书馆。 您可以在此处访问图书馆.

下面是我的库的gradle文件

apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

ext {
    bintrayRepo = 'KenyanCounties' // Repo name in bintray dashboard
    bintrayName = 'studios.luxurious.kenya47counties' // package name of the bintray repo

    publishedGroupId = 'com.martinmbae.kenyan.47counties'   // this is the ID we want to see in implementation line
    libraryName = 'kenyacountieslibrary'     // this is the module name of library
    artifact = 'library'        // this is the artifact we want to see in implementation line

    libraryDescription = 'An android library that displays all kenyan libraries for selection. Each library countains a name, county number and a flag' // description of library

    siteUrl = 'https://github.com/MartinMbae/Sample'    // git repo url
    gitUrl = 'https://github.com/MartinMbae/Sample.git' // git repo vcs url

    libraryVersion = '1.0.1'      // library version

    developerId = 'martinmbae'                // This is your bintray username
    developerName = 'Martin Mbae'              // Developer's name
    developerEmail = '[email protected]'                // Developer's email

    licenseName = 'The Apache Software License, Version 2.0'  // for example, The Apache Software License, Version 2.0
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'   // for example, http://www.apache.org/licenses/LICENSE-2.0.txt
    allLicenses = ["Apache-2.0"]    // array of licenses, for example, ["Apache-2.0"]
}



    android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply from: 'publish.gradle'
//apply from: 'bintray.gradle'
android build.gradle android-library gradle-plugin
3个回答
1
投票

我认为你需要检查你的清单文件

我想你在不止一项活动中添加了

<intent-filter>

确保

<intent-filter>
像这样添加到您的主要或默认活动中

示例代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.asknilesh.demo">
<uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".HomeActivity">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

1
投票

问题是除了主应用程序中的启动器外,您的图书馆还在其清单中声明了一个启动器

Activity

        <activity android:name=".activities.Kenya47Counties">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

如果你从图书馆的

AndroidManifest.xml
中删除它,你的问题应该消失了。


-1
投票

` Hys ob yenuveo sroise 机架 fejyv t

  1. Frkjs。双十字
  2. 图片图片图片全部清除
  3. 背景图形变化自动AI语言Java
  4. 列表项**
  5. https://www.instagram.com/p/Crqsh3NM3Bk/?igshid=NTc4MTIwNjQ2YQ== 在此处输入链接描述

**

在这里输入链接描述

© www.soinside.com 2019 - 2024. All rights reserved.