coconauts / NotificationListener-cordova

NotificationListenerService plugin for Cordova/Phonegap
Other
37 stars 28 forks source link

ERROR : UNKNOWN ELEMENT <uses-permission> FOUNF #4

Closed rnayabed closed 6 years ago

rnayabed commented 6 years ago

whenever i try to build the cordova project, gradle gives me an error : `
/home/debayan/cordovaProjects/asd/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:42: error: unknown element found.

`

PLEASE HELP

rephus commented 6 years ago

Hi, did you try doing cordova platform add android and follow the README ? cordova plugin add https://github.com/coconauts/NotificationListener-cordova

Could you tell me how to replicate your error ? what version of cordova are you using ?

rnayabed commented 6 years ago

Well, my cordova version is 8.0.0 java jdk version is 1.8.0 and gradle version is 4.xxx

rnayabed commented 6 years ago

actually, i researched about it a bit on stackoverflow, and i got this solution (not really)... it seems that cordova 8.0.0 uses aapt2 by default. i think there is some problem with your manifest. the problems that were overlooked (as a warning) by aapt are now flagged as ERRORS in aapt2 link : https://stackoverflow.com/questions/46948498/android-studio-3-0-manifest-error-unknown-element-action-found

rnayabed commented 6 years ago

please figure this error as soon as possible please

rnayabed commented 6 years ago

and yes i followed all of your steps

rephus commented 6 years ago

I have cordova v6.3.1 and I haven't used it in about a year, is possible that the specification has changed since then. I'll take a look when I have time, but you already know more about the issue than me. Feel free to make a PR if you find the issue.

Also if you let me know all the steps you follow to get this error I'll be able to recreate it easily.

rnayabed commented 6 years ago

i solved the problem... when i disabled aapt2, gradle began to give me another error : import android.support.v7app.NotificationCompat; ^ not found so, i just removed that line from your code :} and then i got a successful build now i need to check whether it works fine or not:)

imnikhil331 commented 6 years ago

Same issue. Cordova Version: 8.0.0 Android Platform Version: 7.0.0 Error Text:

../platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:42: AAPT: error: unknown element found.

dsmalicsi commented 6 years ago

Hello, I am having the same issue and found out that the <uses-permission> tag is incorrectly placed in the XML's hierarchy. Please see this answer from stackoverflow for more info https://stackoverflow.com/a/46948576

The AAPT2 is strict with hierarchy, so aside from disabling it, it can be fixed by changing the way the <uses-permission> element is inserted to the AndroidManifest.xml file

In plugin.xml line 32, the <uses-permission> element here should be placed within a <config-file> container that has the parent /* or /manifest

<config-file target="AndroidManifest.xml" parent="/*">
    <uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
</config-file>

You can check out this documentation for reference on proper hierarchy https://developer.android.com/guide/topics/manifest/uses-permission-element

EDIT: I made a pull request https://github.com/coconauts/NotificationListener-cordova/pull/7

rnayabed commented 6 years ago

Why don't you guys disable aapt2 and retry

dsmalicsi commented 6 years ago

@ladiesman6969 Disabling it simply avoids the problem, but does not solve it. Aapt2 is enforcing the correct standards and we should follow too