'compileDebugJavaWithJavac' error while building apk


#1

but when i remove the push notification plugin its working fine

Error

:compileDebugRenderscript
 UP-TO-DATE
:generateDebugBuildConfig
:generateDebugResValues UP-TO-DATE
:processDebugGoogleServices
Parsing json file: E:\IONIC_2\Securityagc\platforms\android\google-services.json

:generateDebugResources
:mergeDebugResources

:processDebugManifest

:processDebugResources

:generateDebugSources
:incrementalDebugJavaCompilationSafeguard

:compileDebugJavaWithJavac

:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no p
revious execution, etc.).
E:\IONIC_2\Securityagc\platforms\android\src\com\adobe\phonegap\push\FCMService.
java:393: error: constructor Builder in class Builder cannot be applied to given
 types;
        mBuilder = new NotificationCompat.Builder(context, channelID);
                   ^
  required: Context
  found: Context,String
  reason: actual and formal argument lists differ in length
E:\IONIC_2\Securityagc\platforms\android\src\com\adobe\phonegap\push\FCMService.
java:403: error: constructor Builder in class Builder cannot be applied to given
 types;
        mBuilder = new NotificationCompat.Builder(context, channelID);
                   ^
  required: Context
  found: Context,String
  reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
:compileDebugJavaWithJavac FAILED

BUILD FAILED

Total time: 27.477 secs
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
E:\IONIC_2\Securityagc\platforms\android\src\com\adobe\phonegap\push\FCMService.
java:393: error: constructor Builder in class Builder cannot be applied to given
 types;
        mBuilder = new NotificationCompat.Builder(context, channelID);
                   ^
  required: Context
  found: Context,String
  reason: actual and formal argument lists differ in length
E:\IONIC_2\Securityagc\platforms\android\src\com\adobe\phonegap\push\FCMService.
java:403: error: constructor Builder in class Builder cannot be applied to given
 types;
        mBuilder = new NotificationCompat.Builder(context, channelID);
                   ^
  required: Context
  found: Context,String
  reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

[ERROR] An error occurred while running cordova build android (exit code 1).

ionic info

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.9.4
    npm  : 5.6.0
    OS   : Windows 7

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

please help me out anyone
Thanks


#2

Set Android_Home path To Your Android SDK .

For Example : Android_Home = C:\Users\User\AppData\Local\Android\sdk

refer this : https://stackoverflow.com/questions/33404552/execution-failed-for-task-appcompiledebugjavawithjavac-in-android-studio


#3

sure why not . below my sdk version
Screenshot_6


#4

where i remove this phonegap-plugin-push its working fine


#5

remove and add the plugin again


#6

after push notification plugin installation showing this error


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value val
ue=(25.4.0) from [com.android.support:appcompat-v7:25.4.0] AndroidManifest.xml:2
8:13-35
        is also present at [com.android.support:support-v13:26.1.0] AndroidManif
est.xml:28:13-35 value=(26.1.0).
        Suggestion: add 'tools:replace="android:value"' to <meta-data> element a
t AndroidManifest.xml:26:9-28:38 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
[ERROR] An error occurred while running cordova build android (exit code 1).

and in put this below code into build.gradle

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.4.0'
            }
        }

This error has gone away
but now showing this error 
**Execution failed for task ':compileDebugJavaWithJavac'.**
    }
}

#7

iā€™m install the plugin this way ionic cordova plugin add phonegap-plugin-push --variable SENDER_ID=xxxxxxxx
is it ok?


#8

Upgrade Your Build Tools Version :

In Your build.Grade :

android {
compileSdkVersion : 23
buildToolsVersion : ā€œ23.0.1ā€
}


#9

You Should Do Like this:

  1. ionic cordova plugin add phonegap-plugin-push

  2. npm install --save @ionic-native/push


#10

and put the sender id in this way
const options: PushOptions = {

   android: {
       //senderID: "xxxxxxx"
   },
   ios: {
       alert: 'true',
       badge: false,
       sound: 'false'
   },
   windows: {}
};

#11

No.sender ID is not the Problem

This is Not only The Plugin error


#12

while install push notification plugin showing this error

Screenshot_7


#13

Do This following

  1. npm cache clean

  2. npm install

  3. ionic cordova plugin rm phonegap-plugin-push

  4. ionic cordova plugin add phonegap-plugin-push

  5. npm install --save @ionic-native/push


#14

now while building apk. now showing this error
Screenshot_8


#15

change your

com.android.support:appcompat-v7:24.0.1


#16

how to change com.android.support:appcompat-v7:24.0.1?


#17

my file is look like this cordova.system.library.3=com.android.support:appcompat-v7:25.+


#18

in your platform>android>project.properties & androidmanifest.xml

change the target version as 24


#19

still showing same error


#20

ionic platform rm android
ionic platform add android@6.3.0