2017-06-13 76 views
1

在android studio中有問題。不知道什麼是錯的,或從文件丟失,這是我的build.gradle文件:Android無法從AndroidManifest.xml中讀取packageName

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

有一個具有相同錯誤的幾個問題,但沒有任何解決方案爲我工作。如果你有類似的問題,請幫助。

+0

這是可能的,這是錯誤的build.gradle文件(項目文件),你應該添加模塊的build.gradle文件「機器人」的信息。檢查此答案的更多信息:https://stackoverflow.com/a/28296240/3442734 – Wrobel

+0

哇,你是對的。不知道我是如何設法混淆它們的。非常感謝 –

+1

正如Wrobel所評論的,這裏是解決問題的方法。 https://stackoverflow.com/questions/28295933/difference-between-build-gradleproject-and-build-gradlemodule/28296240#28296240 –

回答

0

您可以打開Android的工作室,請確保您的項目與項目模型打開,就像屏幕捕獲。現在,你可以嘗試刪除已提到了錯誤的包。

0

你用錯了插件

apply plugin: 'com.android.library' 

上面的插件是庫項目

的applicationID是爲應用程序,它不能與圖書館

所以添加應用程序ID使用到build.gradle文件,它具有以下插件

apply plugin: 'com.android.application'