FAILURE: Build failed with an exception: overide method getItemViewType


#1

How I can resolve problem during compile. I get error:
Running full build
D:\docs\sk\platforms\android\app\src\main\java\com\tns\gen\com\telerik\widget\list\ListViewDataSourceAdapter_frnal_ts_helpers_l58_c38__ListViewDataSourceAdapter.java:30: erro
r: getItemViewType(int) in ListViewDataSourceAdapter_frnal_ts_helpers_l58_c38__ListViewDataSourceAdapter cannot override getItemViewType(int) in ListViewDataSourceAdapter
public int getItemViewType(int param_0) {
^
overridden method is final
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

thanks


#2

Have you tried running tns doctor to see if there’s an update available?

tns doctor
√ Getting environment information

√ 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.
√ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
No issues were detected.
√ Getting NativeScript components versions information...
‼ Update available for component nativescript. Your current version is 4.0.2 and the latest available version is 4.1.0.
‼ Update available for component tns-core-modules. Your current version is 4.0.1 and the latest available version is 4.1.0.
‼ Update available for component tns-android. Your current version is 4.0.1 and the latest available version is 4.1.1.
× Component tns-ios is not installed.

#4

Face the same issue. Unable to build. Clearing all the modules&hooks&platforms didn’t resolve it.

Modules up to date.
tns doctor
√ Getting environment information

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.
√ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
√ Getting NativeScript components versions information…
√ Component nativescript has 4.1.0 version and is up to date.
√ Component tns-core-modules has 4.1.0 version and is up to date.
√ Component tns-android has 4.1.2 version and is up to date.
× Component tns-ios is not installed.


#5

I have the same issue after I add the listview to the app:

/platforms/android/app/src/main/java/com/tns/gen/com/telerik/widget/list/ListViewDataSourceAdapter_listview_245_32_ListViewDataSourceAdapter.java:35: error: getItemViewType(int) in ListViewDataSourceAdapter_listview_245_32_ListViewDataSourceAdapter cannot override getItemViewType(int) in ListViewDataSourceAdapter
public int getItemViewType(int param_0) {
^
overridden method is final
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/Ryan/Workspace/vscode/GymMaster-Online/platforms/android/app/src/main/java/com/tns/gen/com/telerik/widget/autocomplete/AutoCompleteAdapter_autocomplete_60_32_AutoCompleteAdapter.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:compileDebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.


#6

I have had the same issue even though I installed ListView several days ago my app has been building and running up to yesterday.

I uninstalled the ListView plugin and it built and ran successfully for several hours but it is now failing again with this error.

I checked and the ListView plugin is definitely not installed.

I ran tns build android --log trace and there are several fail lines eg:

Blockquote
17:10:28.847 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ‘:app:compileDebugJavaWithJavac’.] from daemon DaemonInfo{pid=9920,

Any fix for this?


#7

When you say ListView plugin, are you referring to RadListView? Is it possible for you to upload a sample to Github and share the link.


#8

That was the plugin I removed.

However I think I have gotten past this by removing and adding again Android.

tns platform remove android
tns platform add android

The project now builds and runs on device.


#9

Still having problems I’m afraid.

I cannot add the RadListView plugin and build for some reason. I have only installed it and am not referencing it anywhere (it is in package.json). I get this error again.

C:\Users\user\apps\myapp\platforms\android\app\src\main\java\com\tns\gen\com\telerik\widget\list\ListViewDataSourceAdapter_listview_244_32_ListViewDataSourceAdapter.java:35: error: getItemViewType(int) in ListViewDataSourceAdapter_listview_244_32_ListViewDataSourceAdapter cannot override getItemViewType(int) in ListViewDataSourceAdapter
        public int getItemViewType(int param_0)  {

The app is based on the nativescript tabs angular template.

If I create the starter nativescript angular project with football players, for example, I am able to add RadListView and build no problem.

Any ideas? Thanks.


#10

Can you shows what you got in package.json?


#11

Thanks for responding. Here is my package.json:

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.myapp",
    "tns-android": {
      "version": "4.1.3"
    }
  },
  "scripts": {
    "lint": "tslint \"app/**/*.ts\""
  },
  "dependencies": {
    "@angular/animations": "~6.0.0",
    "@angular/common": "~6.0.0",
    "@angular/compiler": "~6.0.0",
    "@angular/core": "~6.0.0",
    "@angular/forms": "~6.0.0",
    "@angular/http": "~6.0.0",
    "@angular/platform-browser": "~6.0.0",
    "@angular/platform-browser-dynamic": "~6.0.0",
    "@angular/router": "~6.0.0",
    "nativescript-angular": "~6.0.0",
    "nativescript-camera": "^4.0.2",
    "nativescript-drop-down": "^4.0.1",
    "nativescript-pro-ui": "^3.4.1",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-listview": "^3.5.9",
    "reflect-metadata": "~0.1.10",
    "rxjs": "~6.1.0",
    "tns-core-modules": "^4.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular-devkit/core": "~0.6.3",
    "@angular/compiler-cli": "~6.0.0",
    "@ngtools/webpack": "~6.0.3",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "clean-webpack-plugin": "~0.1.19",
    "codelyzer": "~4.3.0",
    "copy-webpack-plugin": "~4.5.1",
    "css-loader": "~0.28.11",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-sass": "~1.6.0",
    "nativescript-dev-typescript": "~0.7.0",
    "nativescript-dev-webpack": "~0.12.0",
    "nativescript-worker-loader": "~0.9.0",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.3.0",
    "sass-loader": "~7.0.1",
    "tslint": "~5.10.0",
    "typescript": "~2.7.2",
    "uglifyjs-webpack-plugin": "~1.2.5",
    "webpack": "~4.6.0",
    "webpack-bundle-analyzer": "~2.13.0",
    "webpack-cli": "~2.1.3",
    "webpack-sources": "~1.1.0"
  }
}

EDIT:

I see nativescript-pro-ui is a deprecated bundle that includes nativescript-ui-listview - so I had it installed twice. Sheesh. I have uninstalled nativescript-pro-ui and think it is good now, thanks.


#12

Glad you figured out :slight_smile:


#13

I deleted this line: require (“nativescript-ui-autocomplete / angular”); of vendor.ts and execute tns build. It worked for me