Failed to create Android project in Android Studio 3.1 using Gradle 3.0.0

Firstly, I am completely unfamiliar with the Android platform, so please excuse me if I make any mistake. I am trying to create an android project using Gradle version 3.0.0 and using Google Android api annotations. Below is my build.gradle file project

 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } 

Here is my build.gradle application

 apply plugin: 'com.android.application' android { defaultConfig { applicationId "com.demo.see.android.app" minSdkVersion 16 targetSdkVersion 26 versionCode 22 versionName "3.2.0" compileSdkVersion 26 buildToolsVersion "26.0.2" /*javaCompileOptions { annotationProcessorOptions { includeCompileClasspath true } }*/ } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } /*apt { arguments { androidManifestFile ${variant.processResources.manifestFile} resourcePackageName "com.demo.see.android.app" } }*/ ext.daggerVersion = '1.0.0'; ext.androidAnnotationsVersion = '2.4'; def AAVersion = '3.3.2' //def AAVersion = "4.4.0" dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') //annotationProcessor 'com.googlecode.androidannotations:androidannotations:2.4' //compileOnly 'com.googlecode.androidannotations:androidannotations:2.4' //implementation 'com.googlecode.androidannotations:androidannotations-api:2.4' compile group: 'com.googlecode.androidannotations', name: 'androidannotations', version: '2.5.1' annotationProcessor 'com.googlecode.androidannotations:androidannotations:2.5.1' compileOnly 'com.google.android:android:4.1.1.4' implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:design:26.1.0' implementation 'com.google.code.gson:gson:2.2.2' implementation 'com.google.inject:guice:2.0-no_aop' implementation 'com.google.guava:guava:11.0' implementation 'joda-time:joda-time:2.3' implementation 'com.j256.ormlite:ormlite-android:4.31' implementation 'org.roboguice:roboguice:1.1.2' implementation 'org.apache.httpcomponents:httpmime:4.2.5' testImplementation 'com.pivotallabs:robolectric:1.2' testImplementation 'org.hamcrest:hamcrest-all:1.1' testImplementation 'org.mockito:mockito-core:1.8.5' testImplementation 'junit:junit:4.8.2' //annotationProcessor "org.androidannotations:androidannotations:$AAVersion" //implementation "org.androidannotations:androidannotations-api:$AAVersion" implementation "org.androidannotations:androidannotations-api:$AAVersion" annotationProcessor "org.androidannotations:androidannotations-api:$AAVersion"*/ //implementation 'com.google.dagger:dagger:2.0'-- //annotationProcessor 'com.google.dagger:dagger-compiler:2.0' /* implementation "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}" compile "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}:api" /*apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}" compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}" annotationProcessor "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}" apt "com.squareup.dagger:dagger-compiler:${daggerVersion}" compile "com.squareup.dagger:dagger:${daggerVersion}"*/ //compile 'com.google.dagger:dagger:2.0' //annotationProcessor 'com.google.dagger:dagger-compiler:2.0' } /*android.applicationVariants.each { variant -> aptOutput = file("${project.buildDir}/source/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 ] } }*/ 

exceptions revolve around the use of annotations. Note. The comment part mentioned in app.gradle is part of the trace and errors, as I tried several permutations and combinations and got a few exceptions, such as

 `Execution failed for task ':app:javaPreCompileDebug'. Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - androidannotations-2.5.1.jar (com.googlecode.androidannotations:androidannotations:2.5.1)` 

I am currently getting this error

 Error: Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.IllegalStateException: Could not find the AndroidManifest.xml file, going up from path [/home/bhargav/See/see-android/app/build/generated/source/apt/debug] found using dummy file [file:///home/bhargav/See/see-android/app/build/generated/source/apt/debug/dummy1513070341263.java] (max atempts: 10) 

In addition, I also enabled annotation processors from File> Other Settings> Default Setting> Compiler> Annotation Processing

I looked through a lot of links as below.

Android Studio + Gradle + Android Annotations

Androidannotations + Android Studio (almost works)

even if after finding out a workaround by some configuration settings, I get an error, for example, could not found symbol Eactivity & robojuice in the lines

 import com.googlecode.androidannotations.annotations.EActivity; import com.googlecode.androidannotations.annotations.RoboGuice; 

The version I'm using in this project

  • Android Studio - 3.0.1
  • Gradle - 3.0.0
  • Java 1.8 (recommendation for Android)
Folder structure

enter image description here

+5
source share

Source: https://habr.com/ru/post/1273993/


All Articles