android - Android无法从AndroidManifest.xml读取packageName

标签 android android-studio gradle build.gradle manifest

android studio有问题。不确定文件中有什么错误或缺失,这是我的build.gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "aaa.myplugin"
        minSdkVersion 15
        targetSdkVersion 24

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

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/classes.jar')
}

//task to delete the old jar
task cleanJar(type: Delete) {
    delete 'release/MyPlugin.jar'
}

//task to export contents as jar
task exportJar(type: Copy) {
    from('build/intermediates/bundles/release/')
    into('release/')
    include('classes.jar')
    rename('classes.jar', 'MyPlugin.jar')
}

exportJar.dependsOn(cleanJar, build)

这是我的 list 文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="aaa.myplugin">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

    </application>

</manifest>

有几个问题都有相同的错误,但是没有一个解决方案对我有用。如果您遇到类似的问题,请提供帮助。

最佳答案

您使用了错误的插件

apply plugin: 'com.android.library'

上面的插件用于图书馆项目

applicationId适用于应用程序,不能与库一起使用

因此,将应用程序ID添加到具有以下插件的build.gradle文件中
apply plugin: 'com.android.application'

关于android - Android无法从AndroidManifest.xml读取packageName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44515300/

相关文章:

Android 媒体服务器在部分播放错误 100 0 后死机

Android Studio 不显示按钮的属性

java - Gradle : dependency license for Java/Spring library

Gradle:失败时重新运行任务?

gradle - 如何在自定义gradle插件中获取project.sourceSets.test.runtimeClasspath

android - 表达式不能是 Kotlin 中的选择器(出现在点之后)

java - 如何在 Android UI 中设置布局背景

android - 如何从 json 读取\uxxxx

android - 如何在 xml 中添加 TODO 注释?

android - 无法解析 : com. twitter.sdk.android:tweet-composer