Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Help, I kept getting UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined after defining host for universal links #134

Closed
blue2609 opened this issue Dec 29, 2017 · 54 comments

Comments

@blue2609
Copy link

blue2609 commented Dec 29, 2017

I have no idea what happened, one second the universal links plugin was working just fine and then suddenly now whenever I tried to define a host in the config.xml file I always got this error:

(node:xxxxx) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined

as a result of me doing "cordova run android"

However, once I get rid of the

<host name="....."> </host>

section, doing "cordova run android" will build the project with no issue whatsoever. Please help! I don't know what's wrong with this project and the error message is not exactly helping me either.

@runezor
Copy link

runezor commented Jan 7, 2018

Exact same issue here.

Did you manage to solve it?

@blue2609
Copy link
Author

blue2609 commented Jan 7, 2018

Hi mate,

Well yes and no. Yes because I did manage to fix it but no because apparently the problem was not caused by the universal links plugin itself. The problem was the result of me changing the cordova project package name from com.oldName.oldName to com.newName.newName in config.xml <widget> element.

Eventually I had to rename the new package name back to the old one which is com.oldName.oldName to fix the issue. Instead of renaming the package name directly, someone from stackoverflow informed me that to change a cordova project android package name you can simply add the android-packageName attribute inside the config xml <widget> element and specify a new package name for the cordova android project.

Link to my stackoverflow post below right here:
https://stackoverflow.com/questions/48029421/change-cordova-project-android-package-name

Cheers mate, hope this helps you a bit.

@runezor
Copy link

runezor commented Jan 8, 2018

That's an add odd reason for the error; I don't believe I've made any changes to my widget id

@blue2609
Copy link
Author

blue2609 commented Jan 8, 2018

@runezor

yeah it's very weird isn't it haha. I honestly have no idea to this day what the error really means. It's not exactly informative as well which makes it harder for us to pinpoint why the error got produced in the first place.

Cheers mate, let me know how it goes yeah?

@runezor
Copy link

runezor commented Jan 8, 2018

Sadly that does seem to be a trend. I'm in no position to complain, this being open source and all, but a lot of my recent headaches have been due to confusing or misleading error messages. I hope they'll make it a priority at one point, until then I'll just do my best to avoid them.

Thanks for your help though. I'm currently reconstructing my project, so far without errors. I may just try waiting for a fix, or avoid deep linking all together. Here's hoping that it just works when I get to testing though

@blue2609
Copy link
Author

blue2609 commented Jan 8, 2018

@runezor

No mate, let's try to fix it haha.

How exactly did you apply the universal links plugin into your project?

Let me start with my project first, for me:

  1. I did cordova plugin add cordova-universal-links-plugin
  2. I went to my <project folder>/config.xml and I added this:
   <universal-links>
        <host name="www.whatever.com">
            <path event="linkFunctionHandler" url="path/to/whatever" />
        </host>
    </universal-links>
  1. in my index.js, inside the onDeviceReady: function() I subscribed the event linkFunctionHandler to a javaScript function named linkFunctionHandler() like this:
   onDeviceReady: function() {
        console.log("Device is ready for work");
        this.receivedEvent('deviceReady');
  
        universalLinks.subscribe('linkFunctionHandler',linkFunctionHandler);
    },
  1. I made a function called linkFunctionHandler inside index.js such like so:
function linkFunctionHandler(eventData){
    // Do anything you want right here with the eventData object passed
    console.log("The linkFunctionHandler javascript function is executed");
    console.log("The URL which made the app executed this function was" + eventData.url);
}

That's all there is to it mate, that's all I did. Once I did cordova run android after that on my Google Pixel XL (1st Gen) -- Android 8.1, the universal links plugin worked right away.

The outpout on my google chrome web browser console by the linkFunctionHandler() above in this case would be:

The linkFunctionHandler javascript function is executed
The URL which made the app executed this function was http://www.whatever.com/path/to/whatever

@runezor
Copy link

runezor commented Jan 9, 2018

With a slight (irrational) fear I'll try following your steps here when I'm at that point in my project rebuilt. Crossing my fingers I'll see that beautiful "build succesful!" this time

@blue2609
Copy link
Author

blue2609 commented Jan 9, 2018

@runezor

yeah let me know how it goes :)

@ramyatrouny
Copy link

hello guys
am still facing this issue as well I guess it's all related to universal links and the changed package name, in addition, this error was posted while am trying to integrate facebook plugin using firebase I tried almost everything as well I redeployed this integration from scratch with no success.

did you manage to solve it?

@bogacg
Copy link

bogacg commented Jan 12, 2018

I'm also facing same issue. Any solution anyone?

@ramyatrouny
Copy link

for now, i just removed the link and suddenly everything is working fine, it's extremely weird but for my current implementation it doesn't need them
am working on facebook login using firebase

@bogacg
Copy link

bogacg commented Jan 12, 2018

@mba3gar Which link? You mean one in config.xml ?
<host name="....."> </host> part?

@ramyatrouny
Copy link

yes the host name= and where you insert the dynamic links parts just remove the whole xml tag
and try to build your project
<universal-links> <host name="www.whatever.com"> <path event="linkFunctionHandler" url="path/to/whatever" /> </host> </universal-links>

@bogacg
Copy link

bogacg commented Jan 12, 2018

@mba3gar ok thanks, will try.

@bogacg
Copy link

bogacg commented Jan 12, 2018

@mba3gar Yes, it seems plugin works, yet it complains about the missing <universal-links> tag.

On the other hand, redirection doesn't give me Facebook login page then it ends on its own and when redirection/popup ends, my app doesn't get credentials, I'll check that out.

@ramyatrouny
Copy link

ramyatrouny commented Jan 12, 2018

@bogacg consider the following function to login via facebook
`loginfacebook(){
let provider = new firebase.auth.FacebookAuthProvider();
console.log(provider);

firebase.auth().signInWithPopup(provider).then(res =>{
console.log(res);
});`

replace signin with redirect to sign in with popup

please share with me your firebase version if it's 4.8.1 or 4.8.2

@bogacg
Copy link

bogacg commented Jan 13, 2018

I've tried it with 4.8.0 & 4.8.2.

When I check console I see this error:

code : "auth/redirect-cancelled-by-user",
message: "The redirect operation has been cancelled by the user before finalizing."

I'll try uninstall and re-install cordova plugins, if no luck then cancel this and use native Facebook/Google plugins.

@blue2609
Copy link
Author

Damn guys I didn't know that many people are getting the same error. I can't help you guys much though because my problem was because I changed the package name, but that's it.

@1brunovieira
Copy link

I'm with the same issue, does someone know any workaround?

@runezor
Copy link

runezor commented Jan 15, 2018

Apologies for the late response.
I tried using popups as a workaround and so far it's working flawlessly. For anyone trying to implement Facebook authentication I'd recommend doing the same, and hope that a fix arrives on this issue later on

@ramyatrouny
Copy link

hey, @runezor
i just tried to implement it as I mentioned before using popups
it works smoothly but the only issue am facing is that whenever the user is successfully logged in he has to close the browser to be able to go back to the application because it does not redirect.
did you found a workaround for this?

@GeorgeBarnard
Copy link

GeorgeBarnard commented Jan 16, 2018

Same issue here, I'm getting the error and I have not changed my app Id at all. I have tried adding the android-packageName attribute, but it's still giving me the error.

I have been following the firebase-cordova instructions, I don't know if anyone else has the issue using these?

Link to Docs

@ramyatrouny
Copy link

@GeorgeBarnard no we are still struggling with the same problem but you better use the following
`loginfacebook(){
let provider = new firebase.auth.FacebookAuthProvider();
console.log(provider);

firebase.auth().signInWithPopup(provider).then(res =>{
console.log(res);
});`

@GeorgeBarnard
Copy link

Yeah, thanks! I tried with pop-ups, and it seems to work, but no information makes it back to the application once the user has logged in. And as you mentioned before, there is no re-direct. I think i'll make do with email auth until a fix has been found.

@ramyatrouny
Copy link

@GeorgeBarnard can you please share with me the code once you are done?

@GeorgeBarnard
Copy link

GeorgeBarnard commented Jan 16, 2018

Sure, what do you want/need to see? I have been trying to get auth working in-app all day with no luck what-so-ever.

@json-alzate
Copy link

Hi guys, like you have many problems with signInWithPopup and signInWithRedirect, but I found this article: https://blog.ionicframework.com/ionic-firebase-facebook-login/
work with signInWithCredential. in theory what it does is get the facebook token with the native ionic plugin and send it to firebase.
this afternoon I will try to apply...

@donvie
Copy link

donvie commented Jan 17, 2018

Android Studio project detected
(node:7052) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined
(node:7052) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I got that error too, any helps please :-(

@bogacg
Copy link

bogacg commented Jan 17, 2018

I recommend using native plugins instead of this one.

@GeorgeBarnard
Copy link

@bogacg what would you recommend?

@ramyatrouny
Copy link

@donvie all these replies because we are all facing the same problem and we are trying to find a workaround for it

@developerjaag in this case you have to fill in the input field of the login with facebook credentials instead of a popup with a redirect so what if you have a 2 step verification enabled? it doesn't work

@bogacg
Copy link

bogacg commented Jan 17, 2018

@GeorgeBarnard Although process is more tedious, unless this plugin gets fixed we have no other choice it seems. Here are the resources I've read (one warning, some steps might have slightly changed, you'll notice):

Note: I had several issues during build and execution. Depending on your platform/versions you may or may not run into them too. Not subject to this post, and you can find answers with search, just make sure you are searching correct error messages.

@GeorgeBarnard
Copy link

@bogacg Thanks for this, informative articles. But you are right, they are fairly tedious. Hopefully a fix for this plugin comes before the need to change.

@joughbagh
Copy link

Hey guys.

Making this change in 'cordova-universal-links-plugin/hooks/lib/android/manifestWriter.js' fixed this issue for me:
b2c5784#diff-d5955d9f4d88b42e5efd7a3385be79e9

@ramyatrouny
Copy link

@joughbagh I just have a simple question
<universal-links> <host name="DYNAMIC_LINK_DOMAIN" scheme="https" /> <host name="AUTH_DOMAIN" scheme="https"> <path url="/__/auth/callback"/> </host> </universal-links>

does in the following universal links did you change the path url too? or you kept it the same?

@ramyatrouny
Copy link

@joughbagh Thank you, my problem is solved

@GeorgeBarnard
Copy link

@joughbagh Amazing thank you, solved this problem for me. Revealed many more in the process.

@mba3gar Have you managed to get auth working in-app?

@ramyatrouny
Copy link

@GeorgeBarnard yea sure but i changed few things in my code from Popup to sendRedirect

@GeorgeBarnard
Copy link

@mba3gar are you using sign in with facebook/google. I no longer have the manifest error, and the project builds fine, however I have a new error:

this operation is not supported in the environment this application is running on 'location.protocol' must be http, https or chrome-extension and web storage must be enabled

Did you run into anything like this? I know this has gone slightly off topic, but I am at loss.

@donvie
Copy link

donvie commented Jan 19, 2018

Thanks guys Its working now :-)

@ramyatrouny
Copy link

@GeorgeBarnard just check that you are using Https links in this universal links tag can you please share with me your links?

@muralimariyappan
Copy link

@joughbagh thanks man. it worked

@GeorgeBarnard
Copy link

@mba3gar Sure, Link.

The blacked out text is simply the App name. Does anything look wrong here?

@ramyatrouny
Copy link

@GeorgeBarnard mate, i have the same configuration as well for the universal link tags but the only difference is that am putting this tag directly under author
can you please try and update me accordingly

@AsmisAlan
Copy link

hey guys, thaks for resolve this error! ... but when i run in android i have this error with the gradle. any solution?

thanks :(.

:app:transformClassesWithDexBuilderForDebug
java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files
at com.google.common.base.Preconditions.checkState(Preconditions.java:456)
at com.android.builder.dexing.ClassFileEntry.withDexExtension(ClassFileEntry.java:64)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.removeDeletedEntries(DexArchiveBuilderTransform.java:274)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.transform(DexArchiveBuilderTransform.java:241)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.

com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files

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

  • Get more help at https://help.gradle.org

BUILD FAILED in 10s

@lingoyak
Copy link

lingoyak commented May 6, 2018

@joughbagh Thanks for the info. It worked great with the latest Cordova.

@hiepxanh
Copy link

hiepxanh commented May 7, 2018

why still someone not merge @joughbagh commit? it really helpful

@dorman99
Copy link

dorman99 commented May 7, 2018

hey guys , i still have the problem here, and i cant find any file in the hooks just read.me, anyone can help me?

@gklasen
Copy link

gklasen commented May 7, 2018

@AsmisAlan sometimes i had "DexArchiveBuilderTransform"-Errors in the past, which could be resolved by using the android platform with version 6.3.0.

@hiepxanh
Copy link

hiepxanh commented May 7, 2018

@dorman99 here you are
image
image

@dorman99
Copy link

dorman99 commented May 7, 2018

do i need to inject? or do something to get the plugin files ? i still cant find it

@hiepxanh
Copy link

hiepxanh commented May 7, 2018

image
it just place in (your project root) \plugins\cordova-universal-links-plugin\hooks\lib\android\manifestWriter.js

if still can't find it, show me your project folder?
remember, search in plugins folder, not node_modules, or hooks or anything else

@stefusilviu
Copy link

@joughbagh Thank you! It worked for me also.

@nordnet-deprecation-bot
Copy link
Contributor

👋 Hi! Thank you for your interest in this repo.

😢 We are not using nordnet/cordova-universal-links-plugin anymore, and we lack the manpower and the experience needed to maintain it. We are aware of the inconveniece that this may cause you. Feel free to use it as is, or create your own fork.

🔒 This will now be closed & locked.

ℹ️ Please see #160 for more information.

@nordnet nordnet locked and limited conversation to collaborators Sep 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests