【发布时间】:2016-07-15 18:57:18
【问题描述】:
当我使用 MapBox 库启动 android 应用程序时出现异常:
"android.view.InflateException:二进制 XML 文件第 9 行:错误 膨胀类 com.mapbox.mapboxsdk.views.MapView"
“原因”字段包含以下文本:
java.lang.ClassNotFoundException: 找不到类 路径上的“com.mapbox.mapboxsdk.views.MapView”:DexPathList [[zip 文件 "/data/app/com.example.my.mymapbox-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.my.mymapbox-2/lib/arm, /vendor/lib, /system/lib]]
请帮忙
这是我的代码:
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.my.mymapbox"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-beta.2@aar'){
transitive=true
}
}
MainActivity.java
package com.example.my.mymapbox;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:access_token="@string/accessToken"/>
<!-- note the access token string created in the previous step -->
</RelativeLayout>
【问题讨论】:
-
您是否尝试过完全干净和 gradle 构建您的项目?
-
Clean & gradle build 没有帮助。
-
另一个你应该记住的想法是无效的Token也会导致inflating错误。
标签: android mapbox inflate-exception