Gradle: Execution failed for task ':processDebugManifest' - android

I'm getting a gradle error at building since yesterday - it just came randomly....
Full stacktrace here:
My project depends on multiple libraries and it built without any problems until yesterday (even with the librarys)
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.android.support:support-v4:13.0.0'
compile project(":libs:DatabaseCreationHelper")
compile project(":libs:actionbarsherlock")
Anyone has an idea how to fix it? it just randomly came... Full stacktrace here:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':ItchyFeet:processDebugManifest'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter$1.run(CacheLockReleasingTaskExecuter.java:35)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:179)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:232)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:83)
at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter.execute(CacheLockReleasingTaskExecuter.java:33)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.ContextualisingTaskExecuter.execute(ContextualisingTaskExecuter.java:34)
at org.gradle.api.internal.changedetection.state.CacheLockAcquiringTaskExecuter$1.run(CacheLockAcquiringTaskExecuter.java:39)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
at org.gradle.api.internal.changedetection.state.CacheLockAcquiringTaskExecuter.execute(CacheLockAcquiringTaskExecuter.java:37)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:282)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.executeTask(DefaultTaskPlanExecutor.java:48)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.processTask(DefaultTaskPlanExecutor.java:34)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:27)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:89)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.api.internal.changedetection.state.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
at org.gradle.api.internal.changedetection.state.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:48)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:39)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: java.lang.RuntimeException: Manifest merging failed. See console for more info.
at com.android.builder.AndroidBuilder.doMerge(AndroidBuilder.java:475)
at com.android.builder.AndroidBuilder.mergeLibraryManifests(AndroidBuilder.java:461)
at com.android.builder.AndroidBuilder.processManifest(AndroidBuilder.java:301)
at com.android.builder.AndroidBuilder$processManifest.call(Unknown Source)
at com.android.build.gradle.tasks.ProcessAppManifest.doFullTaskAction(ProcessAppManifest.groovy:65)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.groovy:71)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at com.android.build.gradle.tasks.ProcessAppManifest_Decorated.invokeMethod(Unknown Source)
at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:217)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:199)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:526)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:509)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 67 more

Found the solution to this problem:
gradle assemble -info gave me the hint that the Manifests have different SDK Versions and cannot be merged.
I needed to edit my Manifests and build.gradle file and everything worked again.
To be clear you need to edit the uses-sdk in the AndroidManifest.xml
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" />
and the android section, particularly minSdkVersion and targetSdkVersion in the build.gradle file
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}

In a general way, to see what is the error, you can see the merged Manifest File in Android studio
Go on your manifest file
Click on the bottom tab "Merged Manifest"
On the right screen, in "Other Manifest Files", check for any error due to graddle :

I wish the Lukas Olsen solution works for other scenarios, But in my case is quite different.
I faced the same while add ActionBarShelock to project, by comparing to the older library I found that application tag is missing in manifest. By adding one line I fixed my issue.
</application>

i solved by putting this one line in application tag...
tools:node="replace"

This appears to occur because Google Play Services require Android 2.2, which is SDK version 8.
In build.gradle, make sure your minSdkVersion is at least 8. The default appears to be 7. So you have something like this:
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.google.android.gms:play-services:3.1.36'
}

I also faced this error when I was adding firebase push notifications in my app. but in my case I was doing a very silly mistake which i noticed after some time.
I declared below code in manifest two times. After removing duplicate declaration. my issue solved.
<service android:name="com.evampsaanga.mytelenor.firebase.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>`
so you also check if there is anything duplicate in your app manifest file.

Maybe it's because of duplicate Activity declaration in your manifest.

If you add dependencies such as ActionBarSherlock by Gradle,
carefully set your targetSdkVersion 17 or above.
Below quote is --info logs when ActionBarSherlock mismatch with private project.
[C:\Me\Documents\GitHub\project\AndroidManifest.xml:3, C:\Me\Documents\GitHub\project\build\exploded-bundles\ComActionbarsherlockActionbarsherlock440.aar\AndroidManifest.xml:2] Main manifest has but library uses targetSdkVersion='17'
:testApp:processDebugManifest FAILED
It would be better that maintains own project targetSdkVersion as newest as possible.

I came across the same problem and what I did to fix it was to add
tools:replace="android:icon"
to element at AndroidManifest to override

It could be a duplicate permission added in the manifest file. In my case
"uses-permission android:name="android.permission.READ_PHONE_STATE" was repeated.

Just add these two lines at "gradle.properties":
android.useAndroidX=true
android.enableJetifier=true

For what I can see, if you have a multi-module project with Android Studio and gradle, the IDE try to merge manifest files from every module into a Main manifest.
If you have a module A and a module B, and in the A manifest you declare some activity from B module, gradle will enconter a issue when merging.
Try removing cross-module reference in manifest files.

2 things you need to add to AndroidManifest.xml:
1st: add xmlns:tools="http://schemas.android.com/tools" to manifest tag
<manifest xmlns:android=".........
package="...........
xmlns:tools="http://schemas.android.com/tools">
2nd: Add tools:replace="icon" to application tag
<application
android:icon=.........
android:label=.......
tools:replace="icon">

In my case,
I define the activity twice in manifest file
<application
android:allowBackup="false"
android:label="#string/app_name"
>
<activity
android:name="com.xxx.ActivityOne"
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="stateHidden|adjustResize" />
//Problem here.. same activity twice define
<activity
android:name="com.xxx.ActivityOne"
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="stateHidden|adjustResize" />
</application>
After remove the duplicate error solved.

In the manifest, add property android:exported="true" to the launcher activity tag
Edit (14th April 2022)
If you have multiple manifest files (eg.debug and release) make sure the android.name property is mentioned in both

I had the same problem and none of the other answers helped.
In my case, a comment in the manifest file was the culprit:
<manifest [...]
android:installLocation="auto">
<!-- change installLocation back to external after test -->
<uses-sdk [...]
(This might be a bug, seeing how comments in other areas of the manifest dont cause any problems.)

Found another possible solution for this when trying to update my Urban Airship to the latest version.
In my top-level build.gradle file the code looked like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
by default as generated by Android Studio. I changed this to a later gradle version by replacing this with:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.+'
}
}
And after that the project would build.

I came across similar problem ,when I run
cordova build android
which report errors:
/home/app/phonegap/helloworld/platforms/android/AndroidManifest.xml:15:5 Error:
uses-sdk:minSdkVersion 7 cannot be smaller than version 10 declared in library /home/app/phonegap/helloworld/platforms/android/build/intermediates/exploded-aar/android/CordovaLib/unspecified/debug/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="org.apache.cordova" to force usage
:processDebugManifest FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 7 cannot be smaller than version 10 declared in library /home/app/phonegap/helloworld/platforms/android/build/intermediates/exploded-aar/android/CordovaLib/unspecified/debug/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="org.apache.cordova" to force usage
In my case,
uses-sdk:minSdkVersion 7 cannot be smaller than version 10 declared
,above solution do not work! but I solve them by replace
<preference name="android-minSdkVersion" value="7" />
as
<preference name="android-minSdkVersion" value="10" />
in this two file /home/app/phonegap/helloworld/config.xml , /home/app/phonegap/helloworld/platforms/android/res/xml/config.xml

This error might be because of an attribute left empty in the manifest file (AndroidManifest.xml).
An example:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:logo="#drawable/ic_actionbar"
android:supportsRtl="true"
android:fullBackupContent=""> <!--THIS Line-->
...
</application>
The fullBackupContent is empty in the above example.
When it's changed to android:fullBackupContent="true" it will be fixed.

For Manifest merger failed: Apps targeting Android 12
add android:exported="true"
<activity android:name=".MainActivity"
android:exported="true"
>

In my case...I was targetting API 31. In the newer API you have to explicitly declare exported=true or exported=false on activities and receivers so that other apps can launch them i.e if you have any intent-filters you should declare "exported=true".
exported info

Try changing:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" />
To:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
...
<uses-sdk xmlns:tools="http://schemas.android.com/tools"
android:minSdkVersion="14" android:targetSdkVersion="16" />

if you are using android studio you should run the android studio through the command prompt(in windows) or terminal(in UNIX base OS) so you can see more detail about this error in command prompt window.

I had these error since I didnt have the required SDK version installed. After downloading and installing the SDK version present in build.gradle/Android Manifest file, it got resolved.

In my case, it was because of duplicate permission in my Manifest file and minSDKVersion of library was greater than minSDKVersion of my project. I just made that minSDKVersion equal and compiled with success.

This Issue is raise because of
compileSdkVersion 26
buildToolsVersion "26.0.0"
or
compile 'com.android.support:appcompat-v7:26.+'
instead of this use
compileSdkVersion 25
buildToolsVersion "25.0.3"
compile 'com.android.support:appcompat-v7:25.+'

In my case I had written the tag twice. That was my only mistake It was before code`
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<application tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" android:networkSecurityConfig="#xml/react_native_config" />
<application application tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" android:networkSecurityConfig="#xml/react_native_config" >
</application>
`
Just removing the application tag solved my problem.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" android:networkSecurityConfig="#xml/react_native_config" />
</manifest>
The points you should have only one tag; can have more than one and , but one tag. That's what I know at this moment :)

Maybe you have some duplicated Activities
Like this:
<activity android:name=".register.RegisterStepsActivity" />
....
<activity android:name=".register.RegisterStepsActivity" />
just comment one of them

This is an answer for those who are experiencing a similar error while trying to run their Flutter app. To their credit, I discovered this by following Kevin ABRIOUX's answer.
My original error was:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:processDebugManifest'.
> Failed to query the value of task ':app:processDebugManifest' property 'mainMergedManifest'.
> Could not create task ':app:processDebugMainManifest'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Open the android directory in Android Studio.
Once the studio fully loads and the "Project" pane has content, you should be able to run your VSC debugger.
In my particular case I have a secret that gets referenced by android/app/build.gradle. If you are missing such a secret from android/local.properties then step 2. is going to fail. Thankfully, it will give you an error that will point to the missing variable. Save any such variable to the file, close the studio, and repeat step 2. again.
Good luck and happy coding!

I met the problem in another reason.
I was building app in Android Studio, and I had a app module and another module. App module depended on the other module.
But part of build.gradle of app module is :
<application
android:allowBackup="false"
android:label="#string/app_name"
android:supportsRtl="true">
...
</application>
while the other module's build.gradle part is:
<application
android:allowBackup="true"
android:label="Android Lua"
android:supportsRtl="true">
</application>
So, I change the module's build.gradle part to:
<application
android:allowBackup="false"
android:label="#string/app_name"
android:supportsRtl="true">
</application>
Problem solved.

Related

Manifest Merger Error when using Dynamic Features and Build Flavors

With dynamic-feature-modules it is possible to define in the AndroidManifest.xml wheter a module should come preinstalled:
<dist:module
...
dist:onDemand="false"
dist:title="#string/title_shop">
....
</dist:module>
or not:
<dist:module
...
dist:onDemand="true"
dist:title="#string/title_shop">
....
</dist:module>
I have two build flavors in my project. The module should be preinstalled in one flavor but not in the other.
The idea is to have this default AndroidManifest.xml in the main source set:
<dist:module
...
dist:onDemand="true"
dist:title="#string/title_shop">
....
</dist:module>
For build flavors that should have the module preinstalled - I create a AndroidManifest.xml file that overrides that dist:onDemand property
to false:
<dist:module
...
tools:replace="dist:onDemand"
dist:onDemand="false"
...
</dist:module>
Unfortunately, this does not work. The Manifest Merger fails with the following errors:
Merging Errors: Error: tools:replace specified at line:11 for attribute dist:onDemand, but no new value specified shop manifest, line 10 Error: Validation failed, exiting shop manifest.
Does anyone have an idea what's wrong here?
This answer worked for me. The idea is to have two copies of the AndroidManifest.xml, which are identical except
<dist:module
...
tools:node="replace"
dist:onDemand="false">
...
</dist:module>
which replaces the whole element.
The manifest merger tool combines all XML elements from each file by following some merge heuristics. If the merger tool finds that both manifests contain the same attribute with different values, then a merge conflict occurs.
Docs:
https://developer.android.com/studio/build/manifest-merge
To expand on celaeno's answer
If I tried to have just debug and release (or whatever your two build types are) AndroidManifests that were full and exact copies except changes to dist:onDemand line. This didnt' work. Gradle yelled at me about a missing src/main/AndroidManifest.xml. So I actually created three files:
main
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.example.somefeature">
<application ...>
<activity
android:name=...
</activity>
</application>
<!-- NO dist:module block -->
</manifest>
debug
<dist:module
dist:instant="false"
dist:title="#string/somefeature">
<dist:delivery>
<dist:install-time />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
release
<dist:module
dist:instant="false"
dist:title="#string/somefeature">
<dist:delivery>
<dist:on-demand />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>

If i start a new Application then this error is showing. How i can resolve it

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
Add this into your AndroidManifest.xml file the <application> tag.
<meta-data
android:name="android.support.VERSION"
android:value="26.1.0"
tools:replace="android:value" />
You can also provide other version e.g. 27.1.1
You can force the annotation library to test using in build.gradle:
androidTestCompile 'com.android.support:support-annotations:26.1.0'
Another solution is to use this in the top level file:
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
}
use any of one in Above two options, I hope it may useful to you.

Is there a better way to recognize errors?

After working on a project for about a month, my project started executing errors.. Whenever I'm trying to run the program via phone, it executes "app stopped working".. I monetize to check "android monitor" to know who causes the error..(FATAL EXCEPTION: main):
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.app.programavima.java.javaprogramavimas.MainActivity" on path: DexPathList[[zip file "/data/app/com.app.programavima.java.javaprogramavimas-1/base.apk", zip file "/data/app/com.app.programavima.java.javaprogramavimas-1/split_lib_slice_7_apk.apk"],nativeLibraryDirectories=[/data/app/com.app.programavima.java.javaprogramavimas-1/lib/arm64, /vendor/lib64, /system/lib64]]
Am I missing these "base.apk", "arm64", "lib64" files? Maybe something else is making my app to executes errors?
Every help would be pleased, I can manage to import some code, because there's a lot of files inside my project
Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true // add this line
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1' // add this library
}
In your manifest update with this code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" > // add this line
...
</application>
</manifest>

Android project working for everyone but me. [duplicate]

I am trying to integrate Google sign in, in my app, I added these libraries:
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
Also add this to project build gradle:
classpath 'com.google.gms:google-services:1.4.0-beta3'
Also add plugin to app build gradle:
apply plugin: 'com.google.gms.google-services'
then add required permissions
but when I try to run my app, received this error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0\bin\java.exe'' finished with non-zero exit value 2
Try adding multiDexEnabled true to your app build.gradle file.
defaultConfig {
multiDexEnabled true
}
EDIT:
Try Steve's answer first. In case it happens frequently or first step didn't help multiDexEnabled might help. For those who love to dig deeper here is couple similar issues (with more answers):
:app:dexDebug ExecException finished with non-zero exit value 2
Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException
Another thing to watch for, is that you don't use
compile 'com.google.android.gms:play-services:8.3.0'
That will import ALL the play services, and it'll only take little more than a hello world to exceed the 65535 method limit of a single dex APK.
Always specify only the services you need, for instance:
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
I just had to Clean my project and then it built successfully afterwards.
This error began appearing for me when I added some new methods to my project. I knew that I was nowhere near the 65k method limit and did not want to enable multiDex support for my project if I could help it.
I resolved it by increasing the memory available to the :app:transformClassesForDexForDebug task. I did this by specifying javaMaxHeapSize in gradle.build.
gradle.build
android {
...
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
}
I tried this after having had no success with other common solutions to this problem:
Running a project clean
Manually deleting the /app/build and /build directories from my project
Invalidating Gradle Cache and restarting Android Studio
Error
Error:Execution failed for task
> ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java''
finished with non-zero exit value 1
Note: increasing the memory available to the DEX task can cause performance problems on systems with lower memory - link.
I also faced similar issue in Android Studio 1.5.1 and gradle 1.5.0.
I just have to remove unwanted libraries from dependencies which may be automatically added in my app's build.gradle file.
One was : compile 'com.google.android.gms:play-services:8.4.0'.
So for best practices try to only include specific play services library like for ads include only
dependencies {
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
Although
defaultConfig {
multiDexEnabled true
}
this will also solve the issue, but provides with a lot of Notes in gradle console, making it confusing to find the other real issues during build
you can see the documentation of Android
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
I'm using AS 1.5.1 and encountered the same problem. But just cleaning the project just wont do, so I tried something.
clean project
restart AS
Sync Project
This worked with me, so I hope this helps.
At my case change buildToolsVersion from "24" to "23.0.2", solve the problem.
In my case the Exception occurred because all google play service extensions are not with same version as follows
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-appinvite:9.8.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
It worked when I changed this to
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-appinvite:9.8.0'
compile 'com.google.android.gms:play-services-analytics:9.8.0'
I resolved it with the next:
I configured
multidex
In build.gradle you need to add the next one.
android {
...
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
...
}
dexOptions {
incremental true
maxProcessCount 4 // this is the default value
javaMaxHeapSize "2g"
}
...
}
dependencies {
...
compile 'com.android.support:multidex:1.0.1'
...
}
Add the next one in local.properties
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
After that into Application class you need to add the Multidex too.
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
//mas codigo
}
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Don't forget add the line code into Manifest.xml
<application
...
android:name=".MyApplication"
...
/>
That's it with this was enough for resolve the bug:
Execution failed for task ':app:transformClassesWithDexForDebug.
Check very well into build.gradle with javaMaxHeapSize "2g" and the local.properties org.gradle.jvmargs=-Xmx2048m are of 2 gigabyte.
I had same problem when i rolled back to old version via git, and that version had previous .jar library of one 3rd party api, and for some reason turned out that both jar of the same sdk, just different versions were in /libs folder.
First Delete intermediates files
YOUR APP FOLDER\app\build\intermediates
OR
Clean your project and then rebuild.
Thent add
multiDexEnabled true
i.e.
defaultConfig {
multiDexEnabled true
}
It's work for me
I solved this issue by change to use latest buildToolsVersion
android {
//...
buildToolsVersion '26.0.2' // change from '23.0.2'
//...
}
A helpful answer if all above didn't work for you.
Go to your app gradle file,
Check all the dependency versions are mentioned with proper version code rather than any relative value like (com.example.demo:+)
Previous - implementation 'com.google.api-client:google-api-client-android:+'
After - implementation 'com.google.api-client:google-api-client-android:1.30.0'
If you are using the latest gradle version ie classpath 'com.android.tools.build:gradle:1.5.0' and classpath 'com.google.gms:google-services:1.4.0-beta3', then try updating the latest support respository from the SDK manager and rebuild the entire project.
If you need add this reference for cordova plugin add next line in your plugin.xml file.
<framework src="com.android.support:support-v4:+" />
If the different dependencies have a same jar also cause this build error.
For example:
compile('com.a.b:library1');
compile('com.c.d:library2');
If "library1" and "library2" has a same jar named xxx.jar, this will make such an error.
It happened to me because of Eclipse memory leak. I had to restart my computer.
I changed a couple of pngs and the build number in the gradle and now I get this. No amount of cleaning and restarting helped. Disabling Instant Run fixed it for me. YMMV
I had the same option and as soon as I turned off Instant run, it worked fine on my API16 device, but on the API24 device it worked fine with Instant run.
Hope this helps someone having the same issue
Simply go to Build - Edit Build Types - Properties Tab - Build Type Version and downgrade it to ver 23.0.1. Click ok.
This works for android studio 1.5.
It worked for me.
the write answer is in gradle put
defaultConfig {
multiDexEnabled true
}
then application name in manifest
android:name="android.support.multidex.MultiDexApplication"
wish this answer is hellpful to some one
this code solved problem
defaultConfig {
multiDexEnabled true
}
For easiest way to implement google sign in visit: google sign in android
Also try
dexOptions {
javaMaxHeapSize "4g"
}
Also keep same version number for different services.
I solved this issue by adding:
In build.gradle:
defaultConfig {
multiDexEnabled true
}
in local.properties ,
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
mention dependency:
compile 'com.android.support:multidex:1.0.1'
Clean and Rebuild.
Incase 'Instant Run' is enable, then just disable it.

Get compiled .class output directory in Android Gradle task

I'm creating a Gradle task for my Android project that needs to know the path to the compiled .class files. How can I get this path? I've found suggestions (here and here; also see the Gradle docs for SourceSet) that sourceSets.main.output.classDir will give me this path, but when I try to use it, I get the error
Could not find property 'output' on source set main.
This happens even when I create a new, minimal project, with the following build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'android'
android {
compileSdkVersion 22
buildToolsVersion "20.0.0"
task printClassesDir << {
println sourceSets.main.output.classesDir
}
}
This minimal project builds fine, but will give that error if I run the task printClassesDir. How can I get the .class file output directory in my task?
I've also tried the suggestion of <build variant>.javaCompile.classpath from this answer to another question. I was able to access this property with
applicationVariants.find{it.name == 'debug'}.javaCompile.classpath
but this file collection is empty.
For reference, here are the other files for my minimal project:
src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="a.b">
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="22" />
<application>
<activity android:name=".Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
src/main/java/a/b/Main.java
package a.b;
import android.app.Activity;
public class Main extends Activity { }
I was able to find this path using the compile<Variant>JavaWithJavac tasks. These are of type JavaCompile, so they have destinationDir properties:
task printDebugClassesDir << {
println compileDebugJavaWithJavac.destinationDir
}
This prints the build/intermediates/classes/debug directory, which contains the compiled class files. The same thing works for release.

Categories

Resources