4

我檢查了幾個不同的問題,但沒有一個提供了適合我的解決方案。我開發了Android註釋的項目,當我試圖建立我的項目失敗,出現以下錯誤(Project_Location簡直是我的本地項目文件夾):Android Annotations找不到AndroidManifest.xml

error: Could not find the AndroidManifest.xml file in specified path : [/Project_Location/mobile/build/intermediates/manifests/full/debug/AndroidManifest.xml]

這是我的手機的build.gradle文件:

apply plugin: 'com.android.application' 

ext.androidAnnotationsVersion = '3.3.2'; 
ext.eventBusVersion = '2.4.0'; 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' 
    } 
} 

apply plugin: 'android-apt' 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    wearApp project(':wear') 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.google.android.gms:play-services:8.3.0' 
    apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}" 
    compile "org.androidannotations:androidannotations:${androidAnnotationsVersion}" 
    apt "de.greenrobot:eventbus:${eventBusVersion}" 
    compile "de.greenrobot:eventbus:${eventBusVersion}" 
} 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.dev.app_name" 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "0.3" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

configurations { 
    apt 
} 

apt { 
    arguments { 
     androidManifestFile variant.outputs.processResources.manifestFile 
     resourcePackageName 'com.dev' 
    } 
} 

android.applicationVariants.each { variant -> 
    aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}") 
    println "****************************" 
    println "variant: ${variant.name}" 
    println "manifest: ${variant.processResources.manifestFile}" 
    println "aptOutput: ${aptOutput}" 
    println "****************************" 

    variant.javaCompile.doFirst { 
     println "*** compile doFirst ${variant.name}" 
     aptOutput.mkdirs() 
     variant.javaCompile.options.compilerArgs += [ 
       '-processorpath', configurations.apt.getAsPath(), 
       '-AandroidManifestFile=' + variant.processResources.manifestFile, 
       '-s', aptOutput 
     ] 
    } 
} 

如果build.gradle文件看起來像一團糟,我試圖實現多個解決方案已經沒有成功。因此,如果有多餘的陳述可以被刪除,請隨時提供這些建議。目前,我只是爲什麼找不到明確存在的清單文件而難以理解。

+0

建設 - >重建項目? – piotrek1543

+0

@ piotrek1543在項目構建過程中出現錯誤。 –

+0

選擇乾淨,然後重建 - ith應該再生它們 – piotrek1543

回答

4

我固定的構建腳本應工作有關AndroidAnnotations:

apply plugin: 'com.android.application' 

ext.androidAnnotationsVersion = '3.3.2'; 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 
    } 
} 

apply plugin: 'com.neenbedankt.android-apt' 

dependencies { 
    apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}" 
    compile "org.androidannotations:androidannotations-api:${androidAnnotationsVersion}" 
} 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.dev.app_name" 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "0.3" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

apt { 
    arguments { 
     androidManifestFile variant.outputs[0]?.processResources?.manifestFile 
     resourcePackageName "com.dev.app_name" // the same as package in the manifest 
    } 
} 
+0

此建議奏效!經過一些小小的調整,我的項目正在成功建設。謝謝,這讓我瘋狂。 –

+0

apt插件自Android Studio以來已被棄用?你現在怎麼使用它? – nAkhmedov

+0

查看wiki:https://github.com/androidannotations/androidannotations/wiki/Building-Project-Gradle – WonderCsabo

相關問題