NativeScript / nativescript-angular

Integrating NativeScript with Angular
http://docs.nativescript.org/angular/tutorial/ng-chapter-0
Apache License 2.0
1.21k stars 241 forks source link

Cannot successfully build Android app with tns run android --bundle #2066

Closed jpmartinsson closed 4 years ago

jpmartinsson commented 4 years ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug The app is compiling and working fine in iOS, but not on Android emulator or Android physical phone. The build is actually producing an apk-file and it is loaded onto the emulator (with the program immediately crashing). At the same time this is logged at the prompt: Unable to apply changes on device: emulator-5556. Error is: Socket connection timed out..

I believe I have tried all things I have read in related issues, like platform remove/add, removing node_modules, etc. tns doctor says: No issues were detected. ✔ Your ANDROID_HOME environment variable is set and points to correct directory. ✔ Your adb from the Android SDK is correctly installed. ✔ The Android SDK is installed. ✔ A compatible Android SDK for compilation is found. ✔ Javac is installed and is configured properly. ✔ The Java Development Kit (JDK) is installed and is configured properly. ✔ Xcode is installed and is configured properly. ✔ xcodeproj is installed and is configured properly. ✔ CocoaPods are installed. ✔ CocoaPods update is not required. ✔ CocoaPods are configured properly. ✔ Your current CocoaPods version is newer than 1.0.0. ✔ Python installed and configured correctly. ✔ The Python 'six' package is found. ✔ Xcode version 11.2.0 satisfies minimum required version 10. ✔ Getting NativeScript components versions information... ✔ Component nativescript has 6.2.0 version and is up to date.

If I run tns android build it also says Project successfully built. The apk crashes on the phone when started. When turning on --log trace there are a few suspicious thing, but I am too novice to make much sense of them. Among the logs are, e.g.

Error: Trying to handle SIGINT event. CLI overrides this behavior and does not allow handling SIGINT as this causes issues with Ctrl + C in terminal at process.on (/usr/local/lib/node_modules/nativescript/lib/nativescript-cli.js:22:22) at /usr/local/lib/node_modules/nativescript/node_modules/signal-exit/index.js:122:15

AND

[INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/jonasmartinsson/triply/development/triply-ui/node_modules/nativescript-datetimepicker/platforms/android', not found 22:13:25.279 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/jonasmartinsson/triply/development/triply-ui/node_modules/nativescript-iqkeyboardmanager/platforms/android', not found 22:13:25.279 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/jonasmartinsson/triply/development/triply-ui/node_modules/nativescript-ngx-shadow/platforms/android', not found 22:13:25.279 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/jonasmartinsson/triply/development/triply-ui/node_modules/nativescript-theme-core/platforms/android', not found ...etc...

log-trace.txt

jpmartinsson commented 4 years ago

The app works now. The error was in the androidmanifest.xml file.

I had changed <Activity android:name to something else (something that matched package name) than "com.tns.NativeScriptActivity". Does it have to be "com.tns.NativeScriptActivity"? Are there more things in the manifest file that are no-no to change from a Nativescript perspective?