Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

AS 3.2 Alpha - Could not find the AndroidManifest.xml file, using generation folder #2128

Description

@veresvit

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:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'

android {
	compileSdkVersion 27
	defaultConfig {
		...
		compileOptions {
			sourceCompatibility JavaVersion.VERSION_1_8
			targetCompatibility JavaVersion.VERSION_1_8
		}
		javaCompileOptions {
			annotationProcessorOptions {
				// Needs to be same as package name and manifest package
				arguments = ['resourcePackageName': 'pack.age.name']
			}
		}
	}
	buildTypes {
		release {
			minifyEnabled false
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
		}
	}
	flavorDimensions "default"
	productFlavors {
		flavtest {
			buildConfigField "String", "ENDPOINT_URL", '"https://.../"'
			versionNameSuffix "-test"
		}
		preprod {
			buildConfigField "String", "ENDPOINT_URL", '"https://.../"'
			versionNameSuffix "-preprod"
		}
		production {
			buildConfigField "String", "ENDPOINT_URL", '"https://.../"'
		}
	}
	dependencies {
		...
		annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:3.1.0"
		// Permission dispatcher annotation
		annotationProcessor "com.github.AleksanderMielczarek:AndroidAnnotationsPermissionsDispatcherPlugin:2.1.1"
		// AA
		annotationProcessor "org.androidannotations:androidannotations:4.4.0"
		implementation "org.androidannotations:androidannotations-api:4.4.0"
		// Android Annotations for Greenrobot
		annotationProcessor "com.tmtron:green-annotations:1.0.2"
		implementation "com.tmtron:green-annotations-api:1.0.2"
	}
	apply plugin: 'com.google.gms.google-services'
}

Stacktrace in case of AA crash:

\app\build\generated\source\apt\flavtest\androidannotations.log

10:13:34.489 [Daemon worker Thread 11] ERROR o.a.i.h.AndroidManifestFinder:147 - Could not find the AndroidManifest.xml file, using  generation folder [C:\Users\username\Documents\_Projects\Appname\app\build\generated\source\apt\flavtest\debug])

Activity

  1. sandsaber commented on Mar 28, 2018

    @sandsaber

    +1 issue, noticed same thing.
    Did try, no luck
    arg("androidManifestFile", variant.outputs[0].processResourcesTask.manifestFile) arg("resourcePackageName", android.defaultConfig.applicationId)

  2. petacz commented on Mar 29, 2018

    @petacz

    +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

  3. PetrKrestaAi commented on Mar 29, 2018

    @PetrKrestaAi

    +1
    Same event without variants

  4. zqr95518 commented on Apr 3, 2018

    @zqr95518

    +1
    Broken with 3.2.0-alpha09 also.

  5. petacz commented on Apr 18, 2018

    @petacz

    Also with 3.2.0-alpha10 and 11

  6. zqr95518 commented on Apr 27, 2018

    @zqr95518

    It seems if you not import or use the EActivity, they will generate correctly.

  7. carrymaster commented on Jun 5, 2018

    @carrymaster

    Also with 3.2.0-alpha16. Any solution without removing EActivity annotation?

  8. veresvit commented on Jun 5, 2018

    @veresvit
    Author

    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.

  9. rajeshsubramanian commented on Jun 5, 2018

    @rajeshsubramanian

    Appreciate it @veresvit. This worked for me on macOS HS too.

    "androidManifestFile": "app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml"
    
  10. carrymaster commented on Jun 5, 2018

    @carrymaster

    Thanks @veresvit! This worked perfectly.

    But with this solution, would we be using the debug manifest in release?

  11. dodgex commented on Jun 9, 2018

    @dodgex
    Member

    I'm currently working on a fix for this one.

  12. self-assigned this
    on Jun 9, 2018
  13. dodgex commented on Jun 9, 2018

    @dodgex
    Member

    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-SNAPSHOT wihtout the androidManifestFile option

  14. petacz commented on Jun 13, 2018

    @petacz

    Link to PR #2147

  15. LouisCAD commented on Jun 18, 2018

    @LouisCAD

    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)) } }
  16. Namnodorel commented on Sep 19, 2018

    @Namnodorel

    I tried using 4.5.0-SNAPSHOT, the bug still persisted until I used the manifest argument. My manifest location is app\build\intermediates\merged_manifests\debug\AndroidManifest.xml

    (AS 3.2 RC3)

  17. juliocbcotta commented on Sep 19, 2018

    @juliocbcotta

    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 a applicationIdSuffix.

    I removed the kapt arguments block and ran the command:
    ./gradle clean assembleStageRelease

    I get an error that says:
    e: error: The generated $MY_PACKAGE_STAGE_.R class cannot be found

    I did not test much, but it seems to be the same to other variants too.

  18. luanmm commented on Oct 9, 2018

    @luanmm

    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.gradle file, import this script:

    apply from: "$rootDir/<build_scripts_folder>/annotations.gradle"

    Credits to:

  19. Kenji94 commented on Oct 10, 2018

    @Kenji94

    It's not perfect because gradlew build will 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+)")

  20. dodgex commented on Oct 13, 2018

    @dodgex
    Member

    AndroidAnnotations 4.5.0 just has been released and should be available on maven central soon !

  21. fededri commented on Oct 25, 2018

    @fededri

    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.

    You saved me

  22. dodgex commented on Oct 25, 2018

    @dodgex
    Member

    @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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions