Android无法从AndroidManifest.xml读取packageName

问题描述 投票:1回答:2

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)

这是我的清单文件:

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

有几个问题有相同的错误,但没有一个解决方案对我有用。如果你有类似的问题请帮忙。

android android-studio gradle build.gradle manifest
2个回答
0
投票

你使用了错误的插件

apply plugin: 'com.android.library'

上面的插件是针对图书馆项目的

applicationId适用于app,不能与库一起使用

所以将应用程序ID添加到build.gradle文件中,该文件包含以下插件

apply plugin: 'com.android.application'

-1
投票

您可以打开Android工作室,确保您的项目是使用项目模型打开的,就像屏幕截图一样。现在,您可以尝试删除已经引用错误的包。

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