Repository navigation
AS 3.2 Alpha - Could not find the AndroidManifest.xml file, using generation folder #2128
Description
Activity
+1 issue, noticed same thing.
Did try, no luck
arg("androidManifestFile", variant.outputs[0].processResourcesTask.manifestFile) arg("resourcePackageName", android.defaultConfig.applicationId)+1
I am not using build variants.It is broken even with com.android.tools.build:gradle:3.2.0-alpha07
com.android.tools.build:gradle:3.2.0-alpha06 works fine
+1
Same event without variants+1
Broken with 3.2.0-alpha09 also.Also with 3.2.0-alpha10 and 11
It seems if you not import or use the EActivity, they will generate correctly.
Also with 3.2.0-alpha16. Any solution without removing EActivity annotation?
Managed to make it work before the issue is fixed by adding this to the module's build.gradle android.defaultConfig:
javaCompileOptions { annotationProcessorOptions { arguments = [ 'androidManifestFile': 'app\\build\\intermediates\\merged_manifests\\debug\\processDebugManifest\\merged\\AndroidManifest.xml' ] } }This works on Windows with Android Studio - allows me to build the project and release a signed apk. Let me know if you figure out any better solution. On other OS the path might need to be adjusted.
Reacted by Petr V, Jason, Máté Homolya, Louis CAD, SimplySu, Dmitriy Godlevskiy, Federico Torres, Victor Ude, Giovanni Terlingen and Git-WorldAppreciate it @veresvit. This worked for me on macOS HS too.
"androidManifestFile": "app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml"Reacted by Jason, Ramon Mota, Amit Pal, Krasimir Kazakov, Victor Ude and Sean HankinsThanks @veresvit! This worked perfectly.
But with this solution, would we be using the debug manifest in release?
I'm currently working on a fix for this one.
PR is up and @WonderCsabo will review it asap I think. As soon as he has reviewed and merged the PR you can use the
4.5.0-SNAPSHOTwihtout theandroidManifestFileoptionReacted by Petr V, Federico Carrizo, evilsloth and Vit VeresLink to PR #2147
Here's my solution for a Kotlin project (using kapt), that works my multi-buildTypes project:
I define this method at the top of my build.gradle file:
private static String manifestPath(String buildTypeName) { def slash = File.separator return "app${slash}" + "build${slash}" + "intermediates${slash}" + "merged_manifests${slash}" + "$buildTypeName${slash}" + "process${buildTypeName.capitalize()}Manifest${slash}" + "merged${slash}" + "AndroidManifest.xml" }
Then, in each buildType closure, I add this:
kapt { arguments { arg('androidManifestFile', manifestPath(name)) } }Reacted by Carlos Briseño and a_subscriberI tried using
4.5.0-SNAPSHOT, the bug still persisted until I used the manifest argument. My manifest location isapp\build\intermediates\merged_manifests\debug\AndroidManifest.xml(AS 3.2 RC3)
I just tried the 4.5.0-SNAPSHOT and it is not working for me.
I have debug and release buildTypes and qa,stage and prod flavors where I add aapplicationIdSuffix.I removed the kapt arguments block and ran the command:
./gradle clean assembleStageReleaseI get an error that says:
e: error: The generated $MY_PACKAGE_STAGE_.R class cannot be foundI did not test much, but it seems to be the same to other variants too.
To avoid using a SNAPSHOT version in a production code (don't know when exactly anything will be done from the AA team), I ended up with this solution (based on tips from other developers). It works for Kotlin projects that use KAPT and consider flavors (this is my scenario).
Create a file with this script (to avoid putting a lot of [temporary] code in your
build.gradle):import java.util.regex.Pattern import java.util.regex.Matcher def static getManifestPath(String buildType) { def slash = File.separator return "app${slash}" + "build${slash}" + "intermediates${slash}" + "merged_manifests${slash}" + "$buildType${slash}" + "process${buildType.capitalize()}Manifest${slash}" + "merged${slash}" + "AndroidManifest.xml" } def getCurrentBuildType() { Gradle gradle = getGradle() String taskReqStr = gradle.getStartParameter().getTaskRequests().toString() println taskReqStr Pattern pattern = Pattern.compile("(assemble|generate|lint|test)(\\w+)") Matcher matcher = pattern.matcher(taskReqStr) if (matcher.find()) { String flavor = matcher.group(2) if (flavor.contains("Sources")) { flavor = flavor.replace("Sources", "") } char[] c = flavor.toCharArray() c[0] = Character.toLowerCase(c[0]) flavor = new String(c) println "getCurrentBuildType:" + flavor return flavor } else { println "getCurrentBuildType:cannot_find_current_build_type" return "" } } def currentBuildType = getCurrentBuildType() if (!currentBuildType.isEmpty()) { def manifestPath = getManifestPath(currentBuildType) kapt { arguments { arg("androidManifestFile", manifestPath) } } }
Then, in your
build.gradlefile, import this script:apply from: "$rootDir/<build_scripts_folder>/annotations.gradle"
Credits to:
- @LouisCAD
- wonsuc (from Stackoverflow)
Reacted by Thibo and Louis CADIt's not perfect because
gradlew buildwill not work.
But for the rest it's working.
You also need to modify the line
Pattern pattern = Pattern.compile(":(assemble|generate)(\\w+)")
to
Pattern pattern = Pattern.compile("(assemble|generate|lint|test)(\\w+)")Reacted by Luan Mattner MüllerAndroidAnnotations 4.5.0 just has been released and should be available on maven central soon !
Reacted by Mohamed Nazim and Morten HolmgaardManaged to make it work before the issue is fixed by adding this to the module's build.gradle android.defaultConfig:
javaCompileOptions { annotationProcessorOptions { arguments = [ 'androidManifestFile': 'app\\build\\intermediates\\merged_manifests\\debug\\processDebugManifest\\merged\\AndroidManifest.xml' ] } }This works on Windows with Android Studio - allows me to build the project and release a signed apk. Let me know if you figure out any better solution. On other OS the path might need to be adjusted.
You saved me
@fededri you can now just the latest 4.5.x version, this workaround is no longer needed. and for AS 3.3-beta/3.4-alpha you can use the 4.6.0-SNAPSHOT
Reacted by Louis CAD
On Android Studio 3.2 Alpha 8 with according build gradle plugin and using build variants its not posible to build the app. When downgrade to stable Android Studio 3.1 and build gradle plugin 3.1.0 the build works fine.
AndroidAnnotations version: 4.4.0
Android compile SDK version: 27
com.android.tools.build:gradle: 3.2.0-alpha08
build.gradle:
Stacktrace in case of AA crash: