Java.lang.ExceptionInInitializerError, создающий экземпляр ReverseGeocodeRequest [Android SDK]

Jéferson Marques спросил: 07 октября 2018 в 10:15 в: runtime-error

Я пытаюсь использовать Here API ReverseGeoLocation и после того, как я добавил пакет в свой проект и попытался запустить пример из Документации, начинающий получать эту ошибку времени выполнения.

Вот мой манифест :

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myproject.project">    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>    <uses-feature android:name="android.hardware.camera" />    <permission
        android:name="com.example.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>    <uses-permission android:name="com.example.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>    <application
        android:hardwareAccelerated="true"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">        <meta-data android:name="com.here.android.maps.appid" android:value="XXXXX"/>
        <meta-data android:name="com.here.android.maps.apptoken" android:value="XXXXX"/>        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="XXXXXX />        <activity
            android:label="Na Estrada"
            android:screenOrientation="portrait"
            android:name=".activity.BemVindoActivity">            <intent-filter>                <action android:name="android.intent.action.MAIN"/>                <category android:name="android.intent.category.LAUNCHER"/>            </intent-filter>        </activity>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.LoginActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.Cadastrar1Activity"/>        <activity
            android:label=""
            android:name=".activity.Cadastrar2Activity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.MenuActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.InicialActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.InicioFimTrajetoActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.OperacaoActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.DetalheDoEventoDeEmergenciaActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.DetalheDaParadaPlanejadaActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.DetalheDaRotaActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.ImagensActivity"/>        <activity
            android:label=""
            android:name=".activity.ParadaPlanejadaActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.FinalizarParadaSenhaActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.FinalizarParadaActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.RotasActivity"/>        <activity
            android:label=""
            android:screenOrientation="portrait"
            android:name=".activity.EventosActivity"/>    </application></manifest>

Мой build.Gradle

apply plugin: 'com.android.application'android {compileSdkVersion 26defaultConfig {
    applicationId "com.naestrada.project"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}buildTypes {    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}dependencies {
// Jar libs
implementation(name:'HERE-sdk', ext:'aar')implementation fileTree(dir: 'libs', include: ['*.jar'])// Support libs
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:26.1.0'// Supernova UI Toolkit
implementation 'io.supernova:android-ui-toolkit:1.0.1'// Play Services
implementation 'com.google.android.gms:play-services-maps:15.0.1'
// Play Services
implementation 'com.google.android.gms:play-services-maps:10.0.1'implementation 'com.google.maps:google-maps-services:0.2.11'
implementation 'org.slf4j:slf4j-simple:1.7.25'// Page Control
implementation 'com.romandanylyk:pageindicatorview:1.0.0'implementation 'org.locationtech.jts:jts-core:1.15.0'
implementation 'com.google.code.gson:gson:2.8.0'// Unit tests dependencies
testImplementation 'junit:junit:4.12'// Integration tests dependencies
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'}

И мой код .

  private void onTirarFotoPressed() {
        try {
            // Implementation of ResultListener
            class ReverseGeocodeListener implements ResultListener<Address> {
                @Override
                public void onCompleted(Address data, ErrorCode error) {
                    if (error != ErrorCode.NONE) {
                        // Handle error
                    } else {                        Alert.OkDialog(Sys.lastContext(),"",data.toString());                        // Process result data
                    }
                }
            }
            if (location!=null) {                GeoCoordinate hlocation = new GeoCoordinate(
                        location.getLatitude(),
                        location.getLongitude()
                );                ResultListener<Address> listener = new ReverseGeocodeListener();
                // EXCEPTION HAPPENS HERE
                ReverseGeocodeRequest request = new ReverseGeocodeRequest(hlocation);
                if (request.execute(listener) != ErrorCode.NONE) {
                    // Handle request error                }
            }
        } catch (Exception ex) {
            Alert.OkDialog(this,"",ex.getMessage());
        }    }

Ошибка stackTrace:

 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.naestrada.project, PID: 1148
    java.lang.ExceptionInInitializerError
        at com.here.android.mpa.internal.cl.<init>(PlacesBaseRequest.java:60)
        at com.here.android.mpa.internal.ds.<init>(PlacesReverseGeocodeRequest.java:56)
        at com.here.android.mpa.search.ReverseGeocodeRequest.<init>(ReverseGeocodeRequest.java:38)
        at com.naestrada.project.activity.OperacaoActivity.onTirarFotoPressed(OperacaoActivity.java:215)

Везде все в порядке, приложение построить, но когда я нажимаю кнопку для выполнения запроса, я получаю эту ошибку глубоко в одном из классов SDK.

0 ответов