Get compiled .class output directory in Android Gradle task - android

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.

Related

Class Not Found when build APK when using dynamic feature

I have menu module setup by 'com.android.dynamic-feature'. Everything working fine when I coding and run by android studio. When package apk by Build -> Build APK(s) it crash Class Not Found when I start activity in module.
Notes: the activity path is correct, I guess my module doesn't attach into app
Manifest module:
<dist:module
dist:instant="false"
dist:onDemand="false"
dist:title="">
<dist:delivery>
<dist:install-time />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
module gradle
apply plugin: 'com.android.dynamic-feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: '../shared_dependencies.gradle'
Is there any mistake here? Thanks
If you use <dist:fusing dist:include="true" /> and sign your app by APK it still not include into your APK. dynamic-feature only use with AAB format.
If you still want to use APK format you have to use bundle-tool to generate universal APK from AAB
https://developer.android.com/studio/command-line/bundletool
Building Android project that has dynamic feature modules will always work on emulator as there is no delivery system as on Google Play. Also you should use Build -> Build Bundle(s)/APK(s)->Build Bundle(s) option when you are using feature modules.
In your main module's build.gradle file you need to set dynamicFeatures, e.g.:
android {
...
dynamicFeatures = [
':module1',
':module2',
':module3'
]
...
}
While in dynamic feature module's build.gradle file you need dependency for main module:
dependencies {
implementation project(':app')
}

Android Parse Setup

I am trying to set up my first parse project however its not going so well. I would think it should be very straight forward however im still having issues and there are no current tutorials on youtube that i can find that work. The latest tutorial i've found for it is 3 years old.
I'm trying to follow the instructions here:
https://docs.parseplatform.org/android/guide/#installation
I've tried it 2 ways.
1) I have downloaded the parse project from github here:
https://github.com/parse-community/Parse-SDK-Android
Downloading this project comes with a lot of extras for this that are currently way over my head like folders for fcm, gcm, and ktx. The parse folder however also comes with a ton of classes.
I've been following tutorials which gave me a template parse project that was already set up however it was mean for android studio 2.2 i believe (Im currently running 3.3) When i would try to upgrade the files, it would give me tons of compatibility errors.
if anyone has any suggestions on how to fix this, i would greatly appreciate it. Here is what I have tried below:
i've followed the instructions in the link above however i get this error:
Could not find method implementation() for
arguments [com.github.parse-community.Parse-SDK-Android:parse:1.18.5] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
What i dont understand is that the instructions asked me to do this.
2) the second way i've tried it is that i've created a new project in android and i still get the same error at that line.
here is my gradle file for the ways i've tried it:
way number 1)
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.18.5"
}
}
plugins {
id 'com.github.ben-manes.versions' version '0.20.0'
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
compileSdkVersion = 27
supportLibVersion = '27.1.1'
firebaseJobdispatcherVersion = '0.8.5'
minSdkVersion = 14
targetSdkVersion = 27
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.parse">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="App"></application>
<application />
</manifest>
way number 2)
// 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.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.18.5"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.parsetemplate">
<application
android:name="App"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I was getting the same error when I followed parse README.MD
All you need to delete your current project and start a new one and follow the below guide.
https://www.back4app.com/docs/android/parse-android-sdk
You need to copy the complete repositories block, which is inside allprojects block from the build.gradle(Project: your_project_name), and paste it at the end of the build.gradle(Module: app) file.
After you have done that you should rebuild your project once.

apk file does not contain the java file

Am getting the following error
E/AndroidRuntime( 3069): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{fun.n.games/fun.n.games.HelloActivity}: java.lang.ClassNotFoundException: Didn't find class "fun.n.games.HelloActivity" on path: DexPathList[[zip file "/data/app/fun.n.games-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
This error shows up when I try to execute my android app that I have installed on my AVD.
My AVD is running as follows
$ emulator -avd Nexus_S_API_22
The code for the HelloActivity is present.
package fun.n.games;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hello_layout);
}
#Override
public void onStart() {
super.onStart();
TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText("Hello world!");
}
}
It is being pulled together by the following manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fun.n.games"
android:versionCode="1"
android:versionName="1.0.0" >
<application android:label="#string/app_name" >
<activity
android:name="fun.n.games.HelloActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is being built by a single build.gradle
buildscript {
// use the jcenter repository to download the dependencies
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
}
And I am using gradle from command prompt to build and install
$ gradle installDebug
Apart from the error at the beginning of the post, when I search through the build folder, I don't see the HelloActivity.class that I was expecting there.
How do I get the java class to get added to the apk file?
Replace android:name="fun.n.games.HelloActivity" with android:name=".HelloActivity"
Gradle was indeed not finding the java files to compile. Reason being my java file was in the wrong location.
Incorrect location
/src/main/fun/n/games/HelloActivity.java
Correct location
/src/main/java/fun/n/games/HelloActivity.java
The java folder was missing and hence gradle was not finding the class to compile.

Why are my Cucumber definition steps undefined in Android Studio

I have an android application project that I want to add automated tests in it. For that I would like to use Cucumber for java in Android Studio and execute those tests directly into my IDE (with a Run/Debug configuration).
I am on Windows 7 sp1 64 bits using Android Studio 0.8.9. I've added the plugins Gherkin version 134.1007 and Cucumber for Java version 134.1007. I use the following libraries for Cucumber :
cucumber-android-1.1.8
cucumber-core-1.1.8
cucumber-html-0.2.3
cucumber-java-1.1.8
cucumber-junit-1.1.8
cucumber-jvm-deps-1.0.3
gherkin-2.12.2
robotium-solo-5.2.1
This is my Project structure :
TruckCalibrator/
.idea/
app/
build/
libs/
[libraries listed above in .jar format]
src/
main/
java/
com/
novomnetworks/
formeval/
truckcalibrator/
MainActivity.java
res/
AndroidManifest.xml
test/
assets/
features/
app_start.feature
java/
com/
novomnetworks/
formeval/
truckcalibrator/
test/
CucumberTest.java
build.gradle
build/
gradle/
This is my gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.novomnetworks.formeval.truckcalibrator"
minSdkVersion 16
targetSdkVersion 20
versionCode 1
versionName "1.0"
testInstrumentationRunner "cucumber.api.android.CucumberInstrumentation"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
instrumentTest {
java.srcDirs = ['src/test/java']
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.satyan:sugar:1.3'
}
This is my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.novomnetworks.formeval.truckcalibrator"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" />
<instrumentation
android:name="cucumber.api.android.CucumberInstrumentation"
android:targetPackage="com.novomnetworks.formeval.truckcalibrator.test" />
<application
android:allowBackup="true"
android:icon="#drawable/launcher_icon"
tools:replace="icon"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="com.orm.SugarApp">
<uses-library android:name="android.test.runner" />
<meta-data android:name="DATABASE" android:value="form-eval.db" />
<meta-data android:name="VERSION" android:value="1" />
<meta-data android:name="QUERY_LOG" android:value="true" />
<meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="com.novomnetworks.formeval.truckcalibrator.database" />
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is my Cucumber step definitions file (CucumberTest.java) :
package com.novomnetworks.formeval.truckcalibrator.test;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import cucumber.api.CucumberOptions;
import cucumber.api.PendingException;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.api.junit.Cucumber;
import com.novomnetworks.formeval.truckcalibrator.MainActivity;
import com.novomnetworks.formeval.truckcalibrator.R;
import com.robotium.solo.Solo;
import org.junit.runner.RunWith;
/**
* Created by rroyer on 2014-10-24.
*/
#RunWith(Cucumber.class)
/*#CucumberOptions(monochrome = true,
tags = "#tags",
features = "src/test/assets/features/",
format = { "pretty","html: cucumber-html-reports", "json: cucumber-html-reports/cucumber.json" },
dryRun = false,
glue = "com.novomnetworks.formeval.truckcalibrator.test" )*/
public class CucumberTest extends ActivityInstrumentationTestCase2<MainActivity> {
private static final String TAG = "CucumberTest";
Solo solo;
public CucumberTest() {
super(MainActivity.class);
}
#Before
protected void before() throws Exception {
Log.d(TAG, "setUp");
super.setUp();
solo = new Solo(getInstrumentation(), getActivity());
getActivity().resetDB();
}
#After
protected void after() throws Exception {
Log.d(TAG, "tearDown");
solo.finishOpenedActivities();
super.tearDown();
}
#Given("^I started the app$")
public void i_started_the_app() throws Throwable {
solo.waitForActivity(MainActivity.class);
throw new PendingException();
}
#Then("I should see the action bar")
public void I_should_see_the_action_bar() throws Exception {
assertNotNull(getActivity().getMenu());
}
#Given("I am on the clients list")
public void I_am_on_the_clients_list() throws Exception {
solo.waitForFragmentById(R.layout.fragment_clients);
}
#Then("^I should see the clients list header$")
public void I_should_see_the_clients_list_header() throws Exception {
assertTrue(solo.searchText(solo.getString(R.string.clients)));
assertTrue(solo.searchText(solo.getString(R.string.sorted_by)));
assertNotNull(solo.getView(R.id.clients_spinner));
}
#Then("I should see the new client button")
public void I_should_see_the_new_client_button() throws Exception {
assertNotNull(solo.getView(R.id.action_new_client).isShown());
}
#Then("^I should see the clients list$")
public void I_should_see_the_clients_list() throws Exception {
assertNotNull(solo.getView(R.id.clients));
}
}
And this is my feature file :
Feature: Démarrage de l'app
Scenario: La barre de menu devrait s'afficher
Given I started the app
Then I should see the action bar
Scenario: La liste des clients devrait s'afficher
Given I started the app
Then I should see the clients list header
And I should see the new client button
And I should see the clients list
When I run my Cucumber test configuration, (screenshot bellow) The features are found but my step definitions are not. The output says
Undefined step: Given I started the app
Undefined step: Then I should see the action bar
Undefined step: Given I started the app
Undefined step: Then I should see the clients list header
Undefined step: And I should see the new client button
Undefined step: And I should see the clients list
2 Scenarios (2 undefined)
6 Steps (6 undefined)
0m0,000s
You can implement missing steps with the snippets below:
#Given("^I started the app$")
public void i_started_the_app() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
[other similar suggestions...]
I've searched the web for a whole day without finding the correct way to link my step definitions file. Every post I find seems to tell people to mention the test package in the configuration field Glue and this is what I've done, but it's no use. If you look closely to my CucumberTest.java file, you can see that I tried with a #CucumberOptions annotation too but it did not change the result. I also tried with and without the #RunWith(Cucumber.class) annotation.
What am I doing wrong?
You are throwing an exception: throw new PendingException();
in
#Given("^I started the app$")
public void i_started_the_app() throws Throwable {
solo.waitForActivity(MainActivity.class);
throw new PendingException();
}
I came across the same problem and I think I solved it. First, we need to use androidTestCompile configurations on all cucumber related libraries. Note that we need to use #jar qualifier for cucumber-android library to avoid gradle getting the apklib file instead of the jar file. For example :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
...
androidTestCompile 'info.cukes:cucumber-core:1.2.0'
androidTestCompile 'info.cukes:cucumber-java:1.2.0'
androidTestCompile 'info.cukes:gherkin:2.12.2'
androidTestCompile 'info.cukes:cucumber-html:0.2.3'
androidTestCompile 'info.cukes:cucumber-android:1.2.0#jar'
}
Secondly, we don't need to use cucumber-java plugin for Android Studio. We need to run the test on the emulator/device, and I can't find a way to set that up with cucumber-java plugin. Instead, just use Android Test for your run configurations and set the Specific Instrumentation Runner to cucumber.api.android.CucumberInstrumentation.
And the last thing I noticed is that you don't need to use #RunWith annotation. Just use #CucumberOptions on one of your classes, and it works.
Your tests should be in folder src/androidTest instead of src/test
Also I would separate the CucumberTest.java into one class for Cucumber Runner with the configuration annotations and a separate class extending from ActivityInstrumentationTestCase2 containing your glue code.
Here you have a running example for Android Studio using Cucumber and Espresso instead of Robotium:
https://github.com/neoranga55/CleanGUITestArchitecture

Gradle: Execution failed for task ':processDebugManifest'

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.

Categories

Resources