NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 196 forks source link

Issues w/ uiDebug on $ tns android run --emulator #1370

Closed N3ll closed 8 years ago

N3ll commented 8 years ago

From @DenverCoder-9 on January 2, 2016 2:6

I am trying to get the sample-Groceries app to run on my Macbook. I've followed all of the Installation instructions and have verified that TNS Doctor returns no issues, my Android SDK is installed, I've configured a virtual device, and setup the correct paths for ANDROID_HOME. but I still cannot successfully run an app.

My issue seems to come back to a process called uiDebug, I'll get to about 80% and then it fails every single time. I'm not very familiar with Java, hence the reason I'm trying to use NativeScript so I don't have a clue how to fix it.

Here is the output I see:

:dexNativescript-telerik-uiDebug

Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:

Unknown source file : com.android.dex.DexException: Multiple dex files define LJsDebugRun;

Unknown source file : at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)

Unknown source file : at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)

Unknown source file : at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)

Unknown source file : at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)

Unknown source file : at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)

Unknown source file : at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)

Unknown source file : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)

Unknown source file : at com.android.dx.command.dexer.Main.run(Main.java:246)

Unknown source file : at com.android.dx.command.dexer.Main.main(Main.java:215)

Unknown source file : at com.android.dx.command.Main.main(Main.java:106)

:dexNativescript-telerik-uiDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':dexNativescript-telerik-uiDebug'.

> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

I am completely out of ideas so any help someone could offer would be greatly appreciated.

I have done a little bit more digging and I can see in the merger.xml file the following info:

I attempted to checkout /Users/DenverCoder/Dev/nativescript/sample-Groceries/platforms/android/src/nativescript-telerik-uiDebug/assets and it does not exist.

I do not have this directory: nativescript-telerik-uiDebug so the assets directory is unavailable and I presume this is where my error begins...

Copied from original issue: NativeScript/NativeScript#1317

tjvantoll commented 8 years ago

I hit this issue as well and I’m not sure what’s up. I get basically the exact same error:

Execution failed for task ':dexNativescript-telerik-uiDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

I’m using version 1.5.1 of the Android runtime.

tjvantoll commented 8 years ago

I was also able to recreate the issue with version 1.5.0 of the Android runtime. Here’s the full log https://gist.github.com/tjvantoll/fdeac9c3c09415e0c7c4

Plamen5kov commented 8 years ago

the problem is there are two .jar files that define the same type.

that means that probably some .jar file in the node_modules is in conflict with another .jar file in another plugin or dependency.

solution is to find the duplicated type and delete one of the .jar files it is in.

teobugslayer commented 8 years ago

To add to @Plamen5kov's answer, often this happens with widgets.jar. A quick fix would be to delete the platform/android/libs/widgets.jar file

blagoev commented 8 years ago

There is an issue how android build is handling dev dependencies and is already logged here https://github.com/NativeScript/android-runtime/issues/323

blagoev commented 8 years ago

As a workaround for the specific issue remove jscs from devDependencies of your project

Daxito commented 8 years ago

I just installed nativescript-telerik-ui and now I am getting almost the same error, but this one is complaining about:

Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

Is there an issue with this plug in maybe???

teobugslayer commented 8 years ago

@Daxito,

This seems like an unrelated problem. At any rate we are trying to reproduce it and will write back when we have more information on the matter.

Daxito commented 8 years ago

Ok, let me know if you need more info from my side, I don't have anything special, just the latest version of nativescript and the latest version of the plugin, trying to use the SideDrawer.

ginev commented 8 years ago

Hello @Daxito Can you share with us the exact steps you have performed to reproduce the problem? I don't seem to be able to reproduce it on my side and a little assistance from you will be great!

Thanks!

Daxito commented 8 years ago

Can I just give a copy of my project? it only contains one or two views, if so, how? it is on my local pc.

Daxito commented 8 years ago

Ok, this is the log from beginnnig to end, from the time I create the project, add platforms, add plugin and try to run using my attached android device, I dont have to even try to use the plugin, but FYI if I dont add the plugin it works fine.

LOG:

Jacks-MacBook-Air-2:documents juanoviedo$ tns create SampleApp3

Project SampleApp3 was successfully created

Jacks-MacBook-Air-2:documents juanoviedo$ cd SampleApp3

Jacks-MacBook-Air-2:SampleApp3 juanoviedo$ tns platform add android

Copying template files...

Project successfully created.

Jacks-MacBook-Air-2:SampleApp3 juanoviedo$ tns plugin add nativescript-telerik-ui

npm WARN package.json @ No description

npm WARN package.json @ No repository field.

npm WARN package.json @ No README data

npm WARN package.json @ No license field.

nativescript-telerik-ui@0.2.3 node_modules/nativescript-telerik-ui

Successfully installed plugin nativescript-telerik-ui.

Jacks-MacBook-Air-2:SampleApp3 juanoviedo$ tns run android

Successfully prepared plugin nativescript-telerik-ui for android.

Project successfully prepared

:config phase: createDefaultIncludeFiles

+found plugins: nativescript-telerik-ui

:config phase: createPluginsConfigFile

+creating product flavors include.gradle file in configurations folder...

:config phase: pluginExtend

+applying configuration from: /Users/juanoviedo/Documents/SampleApp3/platforms/android/configurations/include.gradle

+applying configuration from: /Users/juanoviedo/Documents/SampleApp3/platforms/android/configurations/nativescript-telerik-ui/include.gradle

:config phase: copyAarDependencies

:config phase: addAarDependencies

+adding dependency: /Users/juanoviedo/Documents/SampleApp3/platforms/android/libs/aar/Chart-2015.3.1307-trial-release.aar

+adding dependency: /Users/juanoviedo/Documents/SampleApp3/platforms/android/libs/aar/Common-2015.3.1307-trial-release.aar

+adding dependency: /Users/juanoviedo/Documents/SampleApp3/platforms/android/libs/aar/Data-2015.3.1307-trial-release.aar

+adding dependency: /Users/juanoviedo/Documents/SampleApp3/platforms/android/libs/aar/Input-2015.3.1307-trial-release.aar

+adding dependency: /Users/juanoviedo/Documents/SampleApp3/platforms/android/libs/aar/List-2015.3.1307-trial-release.aar

+adding dependency: /Users/juanoviedo/Documents/SampleApp3/platforms/android/libs/aar/Primitives-2015.3.1307-trial-release.aar

:preBuild UP-TO-DATE

:preNativescript-telerik-uiDebugBuild UP-TO-DATE

:checkNativescript-telerik-uiDebugManifest

:preNativescript-telerik-uiReleaseBuild UP-TO-DATE

:prepareChart201531307TrialReleaseLibrary

:prepareComAndroidSupportAppcompatV72310Library

:prepareComAndroidSupportRecyclerviewV72310Library

:prepareComAndroidSupportSupportV42310Library

:prepareCommon201531307TrialReleaseLibrary

:prepareData201531307TrialReleaseLibrary

:prepareInput201531307TrialReleaseLibrary

:prepareList201531307TrialReleaseLibrary

:preparePrimitives201531307TrialReleaseLibrary

:prepareNativescript-telerik-uiDebugDependencies

:compileNativescript-telerik-uiDebugAidl

:compileNativescript-telerik-uiDebugRenderscript

:generateNativescript-telerik-uiDebugBuildConfig

:cleanLocalAarFiles

:deleteJavaDir UP-TO-DATE

:ensureMetadataOutDir UP-TO-DATE

:collectAllJars

:isMetadataGenerationNecessary

:buildMetadata

Skip android.support.v7.internal.view.WindowCallbackWrapper

Error: java.lang.NoClassDefFoundError: android/view/SearchEvent

Skip android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23

Error: java.lang.NoClassDefFoundError: android/hardware/fingerprint/FingerprintManager$AuthenticationCallback

Skip android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23$1

Error: java.lang.NoClassDefFoundError: android/hardware/fingerprint/FingerprintManager$AuthenticationCallback

Skip com.telerik.android.primitives.widget.sidedrawer.BlurFadeLayer

Error: java.lang.NoClassDefFoundError: Landroid/support/v8/renderscript/RenderScript;

:copyMetadata

:generateNativescript-telerik-uiDebugAssets UP-TO-DATE

:mergeNativescript-telerik-uiDebugAssets

:generateNativescript-telerik-uiDebugResValues

:generateNativescript-telerik-uiDebugResources

:mergeNativescript-telerik-uiDebugResources

:processNativescript-telerik-uiDebugManifest

:processNativescript-telerik-uiDebugResources

/Users/juanoviedo/Documents/SampleApp3/platforms/android/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.0/res/values-v23/values-v23.xml:2 : Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

/Users/juanoviedo/Documents/SampleApp3/platforms/android/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.0/res/values-v23/values-v23.xml:2 : Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

:processNativescript-telerik-uiDebugResources FAILED

FAILURE: Build failed with an exception.

Execution failed for task ':processNativescript-telerik-uiDebugResources'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/Cellar/android-sdk/24.3.3/build-tools/22.0.1/aapt'' finished with non-zero exit value 1

  • Try:

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

BUILD FAILED

Total time: 21.028 secs

Command /Users/juanoviedo/Documents/SampleApp3/platforms/android/gradlew failed with exit code 1

run android

┌────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────┐

│ Usage │ Synopsis │

│ Run on all connected │ $ tns run android [--key-store-path --key-store-password --key │

│ devices and running │ -store-alias --key-store-alias-password ] [--release] [--justlaunch] │

│ emulators │ │

│ Run on a selected │ $ tns run android --device [--key-store-path --key-store │

│ connected device or │ -password --key-store-alias --key-store-alias-password ] [- │

│ running emulator │ -release] [--justlaunch] │

│ Start an emulator and │ $ tns run android --emulator [] [--key-store-path --key │

│ run the app inside it │ -store-password --key-store-alias --key-store-alias-password │

│ │ ] [--release] [--justlaunch] │

└────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────┘

Runs your project on a connected Android device or in a native Android emulator, if configured. This is shorthand for prepare, build and deploy. While your app is running, prints the output from the application in the console.

Options

* --device - Specifies a connected device on which to run the app. 

* --emulator - If set, runs the app in a native emulator for the target platform, if configured. When set, you can also set any other valid combination of emulator options as listed by $ tns help emulate android. 

* --release - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the --key-store-* options.

* --key-store-path - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.

* --key-store-password - Provides the password for the keystore file specified with --key-store-path. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.

* --key-store-alias - Provides the alias for the keystore file specified with --key-store-path. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.

* --key-store-alias-password - Provides the password for the alias specified with --key-store-alias-password. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.

* --justlaunch - If set, does not print the application output in the console. 

Attributes

* <Device ID> is the index or name of the target device as listed by $ tns device android

* <Emulator Options> is any valid combination of options as listed by $ tns help emulate android

Jacks-MacBook-Air-2:SampleApp3 juanoviedo$

ginev commented 8 years ago

Hello @Daxito ,

Can you please check which Android platforms you have installed on your computer? You can do this by running the Android SDK Manager. I think you're missing API Level 23. Thanks!

Daxito commented 8 years ago

I already had installed API Level from 17 to 23, but yes it was related to the API Level, my environment variable for the SDK was pointing to another folder, once I set the folder that the SDK Manager reported it worked! Thank you!

ginev commented 8 years ago

Sure, no problem!

Ivshti commented 8 years ago

@ginev is it possible that tns doctor checks for stuff like that? I ran into the same issue. It was resolved by installing SDK 23 from the manager, but tns doctor did not report any issues beforehand.

ginev commented 8 years ago

@teobugslayer probably will give more insights about this?

rosen-vladimirov commented 8 years ago

Hi, tns-doctor command checks for the required ANDROID_HOME and all required Android tools. However we do not require SDK 23 as mandatory. Android projects should work fine with API Level 22. In case a plugin requires API Level 23 explicitly, CLI cannot check this as it's external source. So in case you had SDK 22 and all other required tools, tns doctor will not print any warnings :)

Hope this explains the case :)