yandexmobile / yandexmapkit-android

Yandex Map Kit for Android
161 stars 65 forks source link

android.view.InflateException: Binary XML file line #10: Error inflating class ru.yandex.yandexmapkit.MapView #217

Closed crescent7272 closed 8 years ago

crescent7272 commented 8 years ago

Hi,

I have used this yandex map in my previous android application. But now the same code does not work. Probably I am missing something but I cant find where it is. Any help would be greately appreciated. This is error lines:

FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{gcm.b4deploy.com.zimmetler/gcm.b4deploy.com.zimmetler.PersonMap.myapplication.Map.YandexMap}: android.view.InflateException: Binary XML file line #10: Error inflating class ru.yandex.yandexmapkit.MapView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2234) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) at android.app.ActivityThread.access$600(ActivityThread.java:181) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5037) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class ru.yandex.yandexmapkit.MapView at android.view.LayoutInflater.createView(LayoutInflater.java:613) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) at android.view.LayoutInflater.inflate(LayoutInflater.java:489) at android.view.LayoutInflater.inflate(LayoutInflater.java:396) at android.view.LayoutInflater.inflate(LayoutInflater.java:352) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at gcm.b4deploy.com.zimmetler.PersonMap.myapplication.Map.YandexMap.onCreate(YandexMap.java:38) at android.app.Activity.performCreate(Activity.java:5020) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)  at android.app.ActivityThread.access$600(ActivityThread.java:181)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:153)  at android.app.ActivityThread.main(ActivityThread.java:5037)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:417) at android.view.LayoutInflater.createView(LayoutInflater.java:587) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at gcm.b4deploy.com.zimmetler.PersonMap.myapplication.Map.YandexMap.onCreate(YandexMap.java:38)  at android.app.Activity.performCreate(Activity.java:5020)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)  at android.app.ActivityThread.access$600(ActivityThread.java:181)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:153)  at android.app.ActivityThread.main(ActivityThread.java:5037)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.NoClassDefFoundError: ru.yandex.yandexmapkit.MapSurfaceView at ru.yandex.yandexmapkit.MapView.<init>(Unknown Source) at java.lang.reflect.Constructor.constructNative(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)  at android.view.LayoutInflater.createView(LayoutInflater.java:587)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at gcm.b4deploy.com.zimmetler.PersonMap.myapplication.Map.YandexMap.onCreate(YandexMap.java:38)  at android.app.Activity.performCreate(Activity.java:5020)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)  at android.app.ActivityThread.access$600(ActivityThread.java:181)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:153)  at android.app.ActivityThread.main(ActivityThread.java:5037)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)  at dalvik.system.NativeStart.main(Native Method) 

The error shows the line in my YandexMap.java activity which is:

setContentView(R.layout.content_yandex_map);

And in that layout at line 10 there is this line :

<ru.yandex.yandexmapkit.MapView

These are my permissions in android manifest:

`

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />`

This is my activity definition in manifest: <activity android:name=".PersonMap.myapplication.Map.YandexMap" android:label="@string/title_activity_yandex_map" android:theme="@style/AppTheme.NoActionBar">

This is my layout file which I create yandex map view:

`<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="gcm.b4deploy.com.zimmetler.PersonMap.myapplication.Map.YandexMap"

<ru.yandex.yandexmapkit.MapView android:id="@+id/map" android:layout_width="fill_parent" android:layout_height="300dp" android:apiKey="9b2hjqmGFyP1GLs6hiX26arwHrlKyLoJGpNdhz3UEN9jR6TPPjbHiNe2rC4caPBdYd~qnG80AGwk2Dhjf6qJE~RGdMc3J9EAEliCb5Ss0U4=" /> `

I also added yandex lib into my app build.gradle file which is:

compile 'ru.yandex:yandexmapkit:2.4.2@aar'

And I added following lines into my outer build.gradle file:

`allprojects { repositories { jcenter() maven { url 'https://github.com/yandexmobile/yandexmapkit-android/raw/maven/' }

}

}`

I used the same api key with my previous android application because I couldnt find where to get the api key.

In my first project I sent email to yandex support and they gave me the api key. But now I dont know where to find. When I search in google, I find some documentations which is in Russian and I dont understand any thing unfortunately. But I dont think that api key is the reason because in my previous project first I did not write anything for my android:apiKey line and it did not give me this error.

Any idea? Thanks in advance.

mksaint13 commented 8 years ago

Hi. Send me your sample. mksaint13@yandex-team.ru

crescent7272 commented 8 years ago

Thank you so much, I sent it. =)

crescent7272 commented 8 years ago

Problem solved without nothing to be done. Maybe just shotdown was needed. Thanks for the help

mksaint13 commented 8 years ago

Thank

NurekeBH commented 7 years ago

@mksaint13 HELP ME #251

Akbarov commented 6 years ago

I had also the same problem because I had put API key in the wrong place please put them with this order. Hope it would work. MapKitFactory.setApiKey(MAPKIT_API_KEY); MapKitFactory.initialize(this); setContentView(R.layout.user_location);