2014-10-19 84 views
3

我正在嘗試使用AndroidStudio(0.8.9),Gradle(2.1)和Android註釋3.0開發應用程序。Android Studio中的Android註釋:找不到現有文件

正常的gradle同步發生沒有問題。

但是,儘快嘗試創建該項目,我遇到了一個奇怪的錯誤:它表示AndroidManifest.xml無法在/ build的子目錄中找到,儘管此文件確實存在。

這裏試圖做一個掙錢的時候,gradle這個輸出:

Executing tasks: [: compileDebugSources] 
Parallel execution with configuration on demand is an incubating feature.* * * * * * * * * * * * * * * * * * * * * * * * * * * * 
variant: debug 
manifest: [/home/laurent - bernabe/AndroidStudioProjects/ChessPositionManagerAndroid/build/intermediates/manifests/full/debug/AndroidManifest.xml] 
aptOutput: /home/laurent - bernabe/AndroidStudioProjects/ChessPositionManagerAndroid/build/source/apt/debug * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
variant: release 
manifest: [/home/laurent - bernabe/AndroidStudioProjects/ChessPositionManagerAndroid/build/intermediates/manifests/full/release/AndroidManifest.xml] 
aptOutput: /home/laurent - bernabe/AndroidStudioProjects/ChessPositionManagerAndroid/build/source/apt/release * * * * * * * * * * * * * * * * * * * * * * * * * * * * : preBuild: preDebugBuild: checkDebugManifest: preReleaseBuild: prepareComAndroidSupportAppcompatV72000Library UP - TO - DATE: prepareComAndroidSupportSupportV42000Library UP - TO - DATE: prepareDebugDependencies: compileDebugAidl UP - TO - DATE: compileDebugRenderscript UP - TO - DATE: generateDebugBuildConfig UP - TO - DATE: generateDebugAssets UP - TO - DATE: mergeDebugAssets UP - TO - DATE: generateDebugResValues UP - TO - DATE: generateDebugResources UP - TO - DATE: mergeDebugResources UP - TO - DATE: processDebugManifest UP - TO - DATE: processDebugResources UP - TO - DATE: generateDebugSources UP - TO - DATE: compileDebugJava 
Note: Resolve log file to/home/laurent - bernabe/AndroidStudioProjects/ChessPositionManagerAndroid/build/generated/source/apt/androidannotations.log 
Note: 21: 15: 51.226[Daemon Thread 2] INFO o.a.AndroidAnnotationProcessor: 86 - Initialize AndroidAnnotationProcessor with options { 
    androidManifestFile = [/home/laurent - bernabe/AndroidStudioProjects/ChessPositionManagerAndroid/build/intermediates/manifests/full/debug/AndroidManifest.xml], resourcePackageName = com.loloof64.android.chs_pos_mngr 
} 
Note: 21: 15: 51.493[Daemon Thread 2] INFO o.a.AndroidAnnotationProcessor: 117 - Start processing 
for 1 annotations on 8 elements 
error: 21: 15: 51.541[Daemon Thread 2] ERROR o.a.h.AndroidManifestFinder: 95 - Could not find the AndroidManifest.xml file in specified path: [/home/laurent - bernabe/AndroidStudioProjects/ChessPositionManagerAndroid/build/intermediates/manifests/full/debug/AndroidManifest.xml] 
Note: 21: 15: 51.542[Daemon Thread 2] INFO o.a.p.TimeStats: 81 - Time measurements: [Whole Processing = 49 ms], 
[Extract Annotations = 44 ms], 
[Extract Manifest = 3 ms], 
Note: 21: 15: 51.543[Daemon Thread 2] INFO o.a.AndroidAnnotationProcessor: 131 - Finish processing 
Note: 21: 15: 51.760[Daemon Thread 2] INFO o.a.AndroidAnnotationProcessor: 117 - Start processing 
for 0 annotations on 0 elements 
Note: 21: 15: 51.760[Daemon Thread 2] INFO o.a.p.TimeStats: 81 - Time measurements: [Whole Processing = 0 ms], 
Note: 21: 15: 51.761[Daemon Thread 2] INFO o.a.AndroidAnnotationProcessor: 131 - Finish processing 
warning: Unclosed files 
for the types '[dummy1413746151186]'; 
these types will not undergo annotation processing 
1 error 
1 warning 
FAILED 
FAILURE: Build failed with an exception.*What went wrong: Execution failed 
for task ':compileDebugJava'. > Compilation failed; 
see the compiler error output 
for details.*Try: Run with--stacktrace option to get the stack trace.Run with--info or--debug option to get more log output. 
BUILD FAILED 
Total time: 9.216 secs 

這裏是我的搖籃腳本:

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.13.2' 
     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' 
    } 
} 
apply plugin: 'com.android.application' 
apply plugin: 'android-apt' 
repositories { 
    mavenCentral() 
} 
configurations { 
    apt 
} 
dependencies { 
    compile fileTree(include: '*.jar', dir: 'libs') 
    compile files('libs/androidsvg-1.2.1.jar') 
    compile 'com.android.support:appcompat-v7:20.0.0' 
    compile 'org.androidannotations:androidannotations-api:3.0' 
    apt 'org.androidannotations:androidannotations:3.0' 
} 
android { 
    compileSdkVersion 20 
    buildToolsVersion "20.0.0" 
    defaultConfig { 
     minSdkVersion 9 
     targetSdkVersion 20 
    } 
    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 
     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 
     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 
} 
apt { 
    arguments { 
     androidManifestFile variant.outputs.processResources.manifestFile 
     resourcePackageName 'com.loloof64.android.chs_pos_mngr' 
    } 
} 
def getSourceSetName(variant) { 
    return new File(variant.dirName).getName(); 
} 
android.applicationVariants.all { 
    variant - > 
     def aptOutputDir = project.file("${project.buildDir}/source/apt/") 
    def aptOutput = new File(aptOutputDir, variant.dirName) 
    println "****************************" 
    println "variant: ${variant.name}" 
    println "manifest: ${variant.outputs.processResources.manifestFile}" 
    println "aptOutput: ${aptOutput}" 
    println "****************************" 
    android.sourceSets[getSourceSetName(variant)].java.srcDirs += aptOutput.getPath() 
    variant.javaCompile.options.compilerArgs += [ 
     '-processorpath', configurations.apt.getAsPath(), 
     '-AandroidManifestFile=' + variant.outputs.processResources.manifestFile, 
     '-s', aptOutput 
    ] 
    variant.javaCompile.source = variant.javaCompile.source.filter { 
     p - > 
     return !p.getPath().startsWith(aptOutputDir.getPath()) 
    } 
    variant.javaCompile.doFirst { 
     aptOutput.mkdirs() 
    } 
} 

這裏是我的清單:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.loloof64.android.chs_pos_mngr" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="19" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/Theme.Base.AppCompat.Light.DarkActionBar"> 
     <activity 
       android:name="com.loloof64.android.chs_pos_mngr.activities.PositionActivity_" 
      android:label="@string/title_activity_position" 
      android:uiOptions="splitActionBarWhenNarrow"> 
      <meta-data android:name="android.support.UI_OPTIONS" 
       android:value="splitActionBarWhenNarrow" /> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

</manifest> 
+1

如果你申請'Android的apt',你不需要塊以'android.applicationVariants.all'既不是'getSourceSetName '功能。在build.gradle中嘗試不使用此代碼。這個問題也可能來自項目路徑中的空間('laurent - bernabe')。 – yDelouis 2014-10-20 07:18:25

+0

我已經在我的Gradle腳本中刪除了所有無用的代碼。但同樣的效果:一個簡單的同步工作,而make命令找不到我的AndroidManifest.xml。當我嘗試美化代碼時,您在文件夾路徑中看到的空格可能已添加(實際上,它是/ home/laurent-bernabe/...)。另外,Gradle控制檯獲取相同的堆棧跟蹤(無法找到清單)。 – loloof64 2014-10-20 08:13:53

回答

1

終於讓我找到該解決方案,感謝yDelouis讓我走上了道路:

我還必須刪除,在gradle這個腳本以下注釋行:

apt { 
    arguments { 
     //androidManifestFile variant.outputs.processResources.manifestFile 
     resourcePackageName 'com.loloof64.android.chs_pos_mngr' 
    } 
}