Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

[Android] Cannot enable the location service (NoClassDefFoundError) #156

Closed

Description

@kefahB

Make sure to check the demo app(s) for sample usage

YES

Make sure to check the existing issues in this repository

YES but the solution does not work anymore !

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital
letter.
I have this error

JS: Error: Cannot enable the location service. Error: java.lang.NoClassDefFoundError: com.google.android.gms.location.LocationRequest
JS:     java.lang.Class.classForName(Native Method)
JS:     java.lang.Class.forName(Class.java:324)
JS:     java.lang.Class.forName(Class.java:285)
JS:     com.tns.Runtime.getClassForName(Runtime.java:1036)
JS:     com.tns.ClassResolver.resolveClass(ClassResolver.java:27)
JS:     com.tns.Runtime.resolveClass(Runtime.java:604)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:983)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:967)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:959)
JS:     com.tns.FragmentClass.onCreateView(FragmentClass.java:45)
JS:     android.app.Fragment.performCreateView(Fragment.java:2220)
JS:     android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
JS:     android.app.FragmentManagerImpl.moveToState(FragmentManager...

Which platform(s) does your issue occur on?

  • Android
"tns-android": {
	"version": "4.3.0-2018-08-13-04"
}
  • emulator or device. What type of device?
    emulator genyMotion and normal emulator

Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it)
    4.3.0-2018-08-07-12084
  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
"dependencies": {
		"base-64": "^0.1.0",
		"build-url": "^1.1.1",
		"email-validator": "^2.0.4",
		"moment": "^2.22.2",
		"nativescript-barcodescanner": "^2.7.7",
		"nativescript-camera": "^4.0.2",
		"nativescript-fancyalert": "^1.2.0",
		"nativescript-fontawesome": "^1.0.0",
		"nativescript-geolocation": "^4.3.0",
		"nativescript-google-maps-sdk": "^2.6.1",
		"nativescript-i18n": "^0.2.4",
		"nativescript-imagepicker": "^6.0.2",
		"nativescript-intl": "^3.0.0",
		"nativescript-loading-indicator": "^2.4.0",
		"nativescript-phone": "^1.3.1",
		"nativescript-socketio": "^3.0.2",
		"nativescript-telephony": "^1.0.4",
		"nativescript-theme-core": "~1.0.4",
		"nativescript-toast": "^1.4.6",
		"nativescript-zxing": "^1.5.6",
		"tns-core-modules": "^4.2.0",
		"tns-platform-declarations": "^4.1.0",
		"tslib": "^1.9.2",
		"utf8": "^3.0.0"
	},
	"devDependencies": {
		"babel-traverse": "6.26.0",
		"babel-types": "6.26.0",
		"babylon": "6.18.0",
		"lazy": "1.0.11",
		"nativescript-dev-sass": "^1.6.0",
		"nativescript-dev-typescript": "^0.7.1",
		"typescript": "~2.6.2"
	}
import * as geolocation from "nativescript-geolocation";

export function onLoad(args) {
    var page = args.object;

    geolocation.enableLocationRequest();
    let location  = geolocation.getCurrentLocation({});
    location.then(location => {
        console.log(location)
    })
    .catch(console.error)
    page.bindingContext = new Maps();
}

Thanks

Activity

  1. changed the title [-]Cannot enable the location service[/-] [+][Android] Cannot enable the location service (NoClassDefFoundError)[/+] on Aug 30, 2018
  2. kefahB commented on Sep 8, 2018

    @kefahB
    Author

    @DimitarTodorov please can you answer.

  3. kefahB commented on Sep 8, 2018

    @kefahB
    Author

    The solution is to add the flowing in app/App_Resources/Android/app.gradle as explain in the documentation :

    project.ext {
            googlePlayServicesVersion = "+"
    }

    And if like my case you do not have a include.gradle in the same path add it :

    dependencies {
    	def googlePlayServicesVersion = project.googlePlayServicesVersion
    	compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
    }
  4. S-Maxime commented on Aug 27, 2019

    @S-Maxime

    I don't know why this issue is closed.
    I get the same error, it has been 6h i'm working on nativescript-geolocation to have a map / marker and get my current location, that last thing who doesn't work because of this same error.
    And i tried what is listed here and here : #172

    This shit doesn't work neither. sorry.
    android { project.ext { googlePlayServicesVersion = "15.0.1" } }

  5. cabaji9 commented on Sep 9, 2019

    @cabaji9

    I don't know why this issue is closed.
    I get the same error, it has been 6h i'm working on nativescript-geolocation to have a map / marker and get my current location, that last thing who doesn't work because of this same error.
    And i tried what is listed here and here : #172

    This shit doesn't work neither. sorry.
    android { project.ext { googlePlayServicesVersion = "15.0.1" } }

    I tested it and it works with nativescript 6, nativescript-geolocation 5.1.0, angular 8.2.0

    project.ext {
    googlePlayServicesVersion = "16.+"
    }

    dependencies {
    def googlePlayServicesVersion = project.googlePlayServicesVersion
    compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions