TeamMaestro / angular-native-seed

Build web apps and NativeScript applications from one codebase using the AngularCLI.
265 stars 71 forks source link

"The parser encountered a bad or missing package name in the manifest" #34

Open joshcomley opened 7 years ago

joshcomley commented 7 years ago

Hi guys,

I cloned, ran npm i in the root, npm i in the nativescript sub-folder, and then ran npm run android.phone to my Samsung S7.

First time around it works (although with the navigation buttons in grey boxes as opposed to matching blue with the background), but upon subsequent calls to npm run android.phone I get:

Unable to apply changes on device: ce091609f2b8d00704. Error is: The parser encountered a bad or missing package name in the manifest..

I tried recloning the project and starting again, same results. First time around it installs, second time around I end up with this error.

Does anybody have any thoughts?

All the best and thanks for the project, Josh

joshcomley commented 7 years ago

I don't have any trouble with the standard Angular NativeScript template, but I am running NativeScript@next version.

joshcomley commented 7 years ago

I think I've found out what the problem is, but I have to go out for a bit now so I won't be able to try and fix it.

Nevertheless, the App_Resources folder is copied from \nativescript to \nativescript\app, and various package details are updated from a template by NS, such as, in app.gradle:

applicationId = "__PACKAGE__"

To:

applicationId  = "com.domain.project"

But on subsequent calls to npm run android.phone the updated version is replaced back to "__PACKAGE__", I think from the copy command, thus creating an invalid package ID.

donburgess commented 7 years ago

The App_Resources directory by design is located in the nativescript project's root folder and copied over into the app directory. This ensures that it doesn't get mixed up with any code and that anything you put in there isn't lost when copying over the build files. You should be able to make all your updates in /nativescript/App_Resources and then when they're copied over the TNS build process takes over from there.

Does this clarify what you're looking at or did I not understand your problem correctly?

joshcomley commented 7 years ago

Hi thanks for your reply!

I am unable to build the app twice from a clean clone of the repository.

Perhaps it isn't an issue with the App_Resources directory, I've just got back in so I'll investigate, but if I run npm run android.phone two times in succession from a fresh clone, all but the first fail with the The parser encountered a bad or missing package name in the manifest at the point the app is trying to be installed onto the phone.

joshcomley commented 7 years ago

Here is a comparison of, for example, app.gradle in the app subfolder, with the left side being after running npm run android.phone just once, and the right hand side running it twice and receiving the error:

screenshot

If I go back to the original gradle file: \nativescript\App_Resources\Android\app.gradle

Change that from __PACKAGE__ to com.domain.project then I get npm run android.phone working every time.

If I create a project based on the hello-world-ng template:

tns create ng-hello-world --template tns-template-hello-world-ng

Then the generated \app\App_Resources\app.gradle contains:

applicationId = "__PACKAGE__"  

If I then run tns run android, the contents of app.gradle change to:

applicationId = "org.nativescript.nghelloworld"  

And stay that way on subsequent runs.

I think what is happening is NS is pre-processing these files but only once, so on every build after the first one, unprocessed App_Resource files are copied in to the app directory and breaks the build.

donburgess commented 7 years ago

joshcomley I agree it does sound like that is how the tns cli works. I am thinking up some ways to overcome this and will visit some of them probably this weekend.

vvsxy commented 7 years ago

First of, I too observe this problem and it was driving me mad. Thanks @joshcomley for the (temporary?) fix.

gordingin commented 6 years ago

I still receive this error. After I change the file, I rerun npm run android, the files get regenerated and it is overwritten.

Update: I edited the right file in the wrong folder.

rogertthat commented 6 years ago

Confirmed that adjusting the Application Identifier field in SideKick does not update the applicationId entry in app.gradle.

IAMtheIAM commented 6 years ago

This is still occurring. What is the proper fix besides changing that file app.gradle?