android.view.inflateexception二进制XML文件中的行#7错误充气类片段 [英] android.view.inflateexception binary xml file line #7 error inflating class fragment
问题描述
我是新来android.i需要从URL加载图像标记。就这样,我得到的错误android.view.inflateexception二进制XML文件中的行#7错误充气类片段
code MainActivity
包com.ngshah.goglemapv2withlazyloading;
进口的java.util.Hashtable;
进口android.app.ActivityManager;
进口android.content.Context;
进口android.graphics.Bitmap;
进口android.os.Build;
进口android.os.Bundle;
进口android.support.v4.app.FragmentActivity;
进口android.view.View;
进口android.widget.ImageView;
进口android.widget.TextView;
进口com.google.android.gms.maps.CameraUpdateFactory;
进口com.google.android.gms.maps.GoogleMap;
进口com.google.android.gms.maps.GoogleMap.InfoWindowAdapter;
进口com.google.android.gms.maps.SupportMapFragment;
进口com.google.android.gms.maps.model.BitmapDescriptorFactory;
进口com.google.android.gms.maps.model.LatLng;
进口com.google.android.gms.maps.model.Marker;
进口com.google.android.gms.maps.model.MarkerOptions;
进口com.ngshah.goglemapv2withlazyloading.R;
进口com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
进口com.nostra13.universalimageloader.cache.memory.impl.FIFOLimitedMemoryCache;
进口com.nostra13.universalimageloader.core.DisplayImageOptions;
进口com.nostra13.universalimageloader.core.ImageLoader;
进口com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
进口com.nostra13.universalimageloader.core.assist.QueueProcessingType;
进口com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;
公共类MainActivity扩展FragmentActivity {
私人GoogleMap的GoogleMap的;
私人最终经纬度HAMBURG =新的经纬度(53.558,9.927);
私人最终经纬度基尔=新的经纬度(53.551,9.993);
私人标记标记;
私人哈希表<字符串,字符串>标记;
私人ImageLoader的ImageLoader的;
私人DisplayImageOptions选项;
@覆盖
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
GoogleMap的=((SupportMapFragment)getSupportFragmentManager()。findFragmentById(R.id.map))
.getMap();
initImageLoader();
标记=新的Hashtable<字符串,字符串>();
ImageLoader的= ImageLoader.getInstance();
选项=新DisplayImageOptions.Builder()
.showStubImage(R.drawable.ic_launcher)//显示存根图片
.showImageForEmptyUri(R.drawable.ic_launcher)//如果是空的图像发现
.cacheInMemory()
。.cacheOnDisc()bitmapConfig(Bitmap.Config.RGB_565).build();
如果(GoogleMap的!= NULL){
googleMap.setInfoWindowAdapter(新CustomInfoWindowAdapter());
最终的标记汉堡= googleMap.addMarker(新MarkerOptions()。位置(汉堡)
.title伪(汉堡));
markers.put(hamburg.getId(),http://img.india-forums.com/images/100x100/37525-a-still-image-of-akshay-kumar.jpg);
最终的标记基尔= googleMap.addMarker(新MarkerOptions()
.position(基尔)
.title伪(基尔)
是.snippet(基尔是酷)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
markers.put(kiel.getId(),http://www.yodot.com/images/jpeg-images-sm.png);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(汉堡,15));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(10),2000,NULL);
}
}
私有类CustomInfoWindowAdapter实现InfoWindowAdapter {
私人浏览视图;
公共CustomInfoWindowAdapter(){
鉴于= getLayoutInflater()。膨胀(R.layout.custom_info_window,
空值);
}
@覆盖
公共查看getInfoContents(标记标记){
如果(MainActivity.this.marker!= NULL
&功放;&安培; MainActivity.this.marker.isInfoWindowShown()){
MainActivity.this.marker.hideInfoWindow();
MainActivity.this.marker.showInfoWindow();
}
返回null;
}
@覆盖
公共查看getInfoWindow(最终标记标记){
MainActivity.this.marker =标记;
字符串URL = NULL;
如果(marker.getId()=空&安培;!&安培;!标记=空&安培;&安培; markers.size()大于0){
如果(markers.get(marker.getId())= NULL和放大器;!&安培;
markers.get(marker.getId())!= NULL){
URL = markers.get(marker.getId());
}
}
最终ImageView的形象=((ImageView的)view.findViewById(R.id.badge));
如果(URL = NULL和放大器;!&安培;!url.equalsIgnoreCase(空)
&功放;&安培; !url.equalsIgnoreCase()){
imageLoader.displayImage(URL,图像,选项,
新SimpleImageLoadingListener(){
@覆盖
公共无效onLoadingComplete(字符串imageUri,
视图中查看,位图loadedImage){
super.onLoadingComplete(imageUri,观点,
loadedImage);
getInfoContents(标记);
}
});
} 其他 {
image.setImageResource(R.drawable.ic_launcher);
}
最后字符串标题= marker.getTitle();
最后的TextView titleUi =((TextView中)view.findViewById(R.id.title));
如果(标题!= NULL){
titleUi.setText(职称);
} 其他 {
titleUi.setText();
}
最后弦乐片段= marker.getSnippet();
最后的TextView snippetUi =((TextView中)查看
.findViewById(R.id.snippet));
如果(代码段!= NULL){
snippetUi.setText(片段);
} 其他 {
snippetUi.setText();
}
返回查看;
}
}
私人无效initImageLoader(){
INT memoryCacheSize;
如果(Build.VERSION.SDK_INT> = Build.VERSION_ codeS.ECLAIR){
INT memClass =((ActivityManager)
getSystemService(Context.ACTIVITY_SERVICE))
.getMemoryClass();
memoryCacheSize =(memClass / 8)* 1024 * 1024;
} 其他 {
memoryCacheSize = 2 * 1024 * 1024;
}
最后ImageLoaderConfiguration配置=新ImageLoaderConfiguration.Builder(
此).threadPoolSize(5)
.threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCacheSize(memoryCacheSize)
.memoryCache(新FIFOLimitedMemoryCache(memoryCacheSize-1000000))
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(新Md5FileNameGenerator())
.tasksProcessingOrder(QueueProcessingType.LIFO).enableLogging()
。建立();
。ImageLoader.getInstance()的init(配置);
}
}
activity_main.xml
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
工具:上下文=MainActivity。>
<片段
机器人:ID =@ + ID /图
机器人:layout_width =match_parent
机器人:layout_height =match_parent
类=com.google.android.gms.maps.SupportMapFragment/>
< / RelativeLayout的>
custom_info_window.xml
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@可绘制/ custom_info_bubble
机器人:方向=横向>
< ImageView的
机器人:ID =@ + ID /徽章
机器人:layout_width =50dp
机器人:layout_height =50dp
机器人:layout_marginRight =5DP
机器人:adjustViewBounds =真正的>
< / ImageView的>
<的LinearLayout
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直>
<的TextView
机器人:ID =@ + ID /标题
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:ellipsize =结束
机器人:单线=真
机器人:文字颜色=#FF000000
机器人:TEXTSIZE =14dp
机器人:TEXTSTYLE =黑体/>
<的TextView
机器人:ID =@ + ID /片段
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#ff7f7f7f
机器人:TEXTSIZE =14dp/>
< / LinearLayout中>
< / LinearLayout中>
AndroidManifest.xml中
< XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.ngshah.goglemapv2withlazyloading
安卓版code =1
机器人:VERSIONNAME =1.0>
<用途-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =17/>
<许可
机器人:名称=com.ngshah.googlemapv2.permission.MAPS_RECEIVE
安卓的ProtectionLevel =签名/>
<使用-权限的Android:名称=com.ngshah.googlemapv2.permission.MAPS_RECEIVE/>
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.WRITE_EXTERNAL_STORAGE/>
<使用-权限的Android:名称=com.google.android.providers.gsf.permission.READ_GSERVICES/>
<使用-权限的Android:名称=android.permission.ACCESS_COARSE_LOCATION/>
<使用-权限的Android:名称=android.permission.ACCESS_FINE_LOCATION/>
<用途特征
机器人:glEsVersion =0x00020000
机器人:要求=真/>
<应用
机器人:allowBackup =真
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
&所述;元数据
机器人:名称=com.google.android.maps.v2.API_KEY
机器人:值=我的钥匙/>
<活动
机器人:名称=com.ngshah.goglemapv2withlazyloading.MainActivity
机器人:标签=@字符串/ APP_NAME>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
&所述;元数据
机器人:名称=com.google.android.gms.version
机器人:值=@整数/ google_play_services_version/>
< /用途>
< /舱单>
日志文件
八月六日至23日:56:33.749:I /谷歌地图Android的API(15924):谷歌播放服务的客户端版本:4323000
8月6号至23号:56:33.759:I /谷歌地图Android的API(15924):谷歌播放服务包的版本:4452034
8月6号至23号:56:33.819:D / AndroidRuntime(15924):关闭虚拟机
8月6号至23号:56:33.819:W / dalvikvm(15924):主题ID = 1:螺纹退出与未捕获的异常(组= 0x420ae930)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):致命异常:主要
8月6号至23号:56:33.899:E / AndroidRuntime(15924):java.lang.RuntimeException的:无法启动的活动ComponentInfo{com.ngshah.goglemapv2withlazyloading/com.ngshah.goglemapv2withlazyloading.MainActivity}: android.view.InflateException:二进制XML文件中的行#7:错误充气类片段
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.ActivityThread.access $ 700(ActivityThread.java:157)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1289)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.os.Handler.dispatchMessage(Handler.java:99)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.os.Looper.loop(Looper.java:176)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.ActivityThread.main(ActivityThread.java:5317)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在java.lang.reflect.Method.invokeNative(本机方法)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在java.lang.reflect.Method.invoke(Method.java:511)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1102)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在dalvik.system.NativeStart.main(本机方法)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):android.view.InflateException:二进制XML文件中的行#7:错误充气类片段产生的原因
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.view.LayoutInflater.inflate(LayoutInflater.java:495)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.view.LayoutInflater.inflate(LayoutInflater.java:397)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.view.LayoutInflater.inflate(LayoutInflater.java:353)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:360)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.Activity.setContentView(Activity.java:1932)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.ngshah.goglemapv2withlazyloading.MainActivity.onCreate(MainActivity.java:45)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.Activity.performCreate(Activity.java:5326)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):11 ...更多
8月6号至23号:56:33.899:E / AndroidRuntime(15924):由:java.lang.SecurityException异常:该地图API需要额外的下列权限在AndroidManifest.xml中进行设置,以确保正确的行为:
8月6号至23号:56:33.899:E / AndroidRuntime(15924):其中,使用,许可安卓名=android.permission.ACCESS_NETWORK_STATE/>
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在lzv.a(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在mcg.a(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在mcg.a(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在mbi.a(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在lxn.a(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在lxm.a(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在fnb.onTransact(的SourceFile:107)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.os.Binder.transact(Binder.java:310)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.google.android.gms.maps.internal.IMapFragmentDelegate $ A $ a.onCreateView(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.google.android.gms.maps.SupportMapFragment $ a.onCreateView(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.google.android.gms.dynamic.a $ 4.B(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.google.android.gms.dynamic.aa(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.google.android.gms.dynamic.a.onCreateView(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在com.google.android.gms.maps.SupportMapFragment.onCreateView(来源不明)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:900)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)
8月6号至23号:56:33.899:E / AndroidRuntime(15924):21 ...更多
8月6号至23号:56:36.151:I /流程(15924):发送信号。 PID:15924 SIG:9
问题是在你的AndroidManifest.xml通过这条线在LogCat中的异常所指出:
致:java.lang.SecurityException异常:该地图API需要额外的下列权限在AndroidManifest.xml中进行设置,以确保正确的行为:
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
如果你这个权限添加到AndroidManifest它应该正常工作
I am new to android.i need to load a image from a url to marker. on doing this i am getting the error" android.view.inflateexception binary xml file line #7 error inflating class fragment"
code MainActivity
package com.ngshah.goglemapv2withlazyloading;
import java.util.Hashtable;
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.ngshah.goglemapv2withlazyloading.R;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.FIFOLimitedMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;
public class MainActivity extends FragmentActivity {
private GoogleMap googleMap;
private final LatLng HAMBURG = new LatLng(53.558, 9.927);
private final LatLng KIEL = new LatLng(53.551, 9.993);
private Marker marker;
private Hashtable<String, String> markers;
private ImageLoader imageLoader;
private DisplayImageOptions options;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
initImageLoader();
markers = new Hashtable<String, String>();
imageLoader = ImageLoader.getInstance();
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.ic_launcher) // Display Stub Image
.showImageForEmptyUri(R.drawable.ic_launcher) // If Empty image found
.cacheInMemory()
.cacheOnDisc().bitmapConfig(Bitmap.Config.RGB_565).build();
if ( googleMap != null ) {
googleMap.setInfoWindowAdapter(new CustomInfoWindowAdapter());
final Marker hamburg = googleMap.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
markers.put(hamburg.getId(), "http://img.india-forums.com/images/100x100/37525-a-still-image-of-akshay-kumar.jpg");
final Marker kiel = googleMap.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
markers.put(kiel.getId(), "http://www.yodot.com/images/jpeg-images-sm.png");
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}
}
private class CustomInfoWindowAdapter implements InfoWindowAdapter {
private View view;
public CustomInfoWindowAdapter() {
view = getLayoutInflater().inflate(R.layout.custom_info_window,
null);
}
@Override
public View getInfoContents(Marker marker) {
if (MainActivity.this.marker != null
&& MainActivity.this.marker.isInfoWindowShown()) {
MainActivity.this.marker.hideInfoWindow();
MainActivity.this.marker.showInfoWindow();
}
return null;
}
@Override
public View getInfoWindow(final Marker marker) {
MainActivity.this.marker = marker;
String url = null;
if (marker.getId() != null && markers != null && markers.size() > 0) {
if ( markers.get(marker.getId()) != null &&
markers.get(marker.getId()) != null) {
url = markers.get(marker.getId());
}
}
final ImageView image = ((ImageView) view.findViewById(R.id.badge));
if (url != null && !url.equalsIgnoreCase("null")
&& !url.equalsIgnoreCase("")) {
imageLoader.displayImage(url, image, options,
new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri,
View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view,
loadedImage);
getInfoContents(marker);
}
});
} else {
image.setImageResource(R.drawable.ic_launcher);
}
final String title = marker.getTitle();
final TextView titleUi = ((TextView) view.findViewById(R.id.title));
if (title != null) {
titleUi.setText(title);
} else {
titleUi.setText("");
}
final String snippet = marker.getSnippet();
final TextView snippetUi = ((TextView) view
.findViewById(R.id.snippet));
if (snippet != null) {
snippetUi.setText(snippet);
} else {
snippetUi.setText("");
}
return view;
}
}
private void initImageLoader() {
int memoryCacheSize;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
int memClass = ((ActivityManager)
getSystemService(Context.ACTIVITY_SERVICE))
.getMemoryClass();
memoryCacheSize = (memClass / 8) * 1024 * 1024;
} else {
memoryCacheSize = 2 * 1024 * 1024;
}
final ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
this).threadPoolSize(5)
.threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCacheSize(memoryCacheSize)
.memoryCache(new FIFOLimitedMemoryCache(memoryCacheSize-1000000))
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.tasksProcessingOrder(QueueProcessingType.LIFO).enableLogging()
.build();
ImageLoader.getInstance().init(config);
}
}
activity_main.xml
<RelativeLayout 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"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
custom_info_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/custom_info_bubble"
android:orientation="horizontal" >
<ImageView
android:id="@+id/badge"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginRight="5dp"
android:adjustViewBounds="true" >
</ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="#ff000000"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="@+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff7f7f7f"
android:textSize="14dp" />
</LinearLayout>
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ngshah.goglemapv2withlazyloading"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.ngshah.googlemapv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.ngshah.googlemapv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my key" />
<activity
android:name="com.ngshah.goglemapv2withlazyloading.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
log file
06-23 08:56:33.749: I/Google Maps Android API(15924): Google Play services client version: 4323000
06-23 08:56:33.759: I/Google Maps Android API(15924): Google Play services package version: 4452034
06-23 08:56:33.819: D/AndroidRuntime(15924): Shutting down VM
06-23 08:56:33.819: W/dalvikvm(15924): threadid=1: thread exiting with uncaught exception (group=0x420ae930)
06-23 08:56:33.899: E/AndroidRuntime(15924): FATAL EXCEPTION: main
06-23 08:56:33.899: E/AndroidRuntime(15924): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ngshah.goglemapv2withlazyloading/com.ngshah.goglemapv2withlazyloading.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.ActivityThread.access$700(ActivityThread.java:157)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.os.Handler.dispatchMessage(Handler.java:99)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.os.Looper.loop(Looper.java:176)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.ActivityThread.main(ActivityThread.java:5317)
06-23 08:56:33.899: E/AndroidRuntime(15924): at java.lang.reflect.Method.invokeNative(Native Method)
06-23 08:56:33.899: E/AndroidRuntime(15924): at java.lang.reflect.Method.invoke(Method.java:511)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
06-23 08:56:33.899: E/AndroidRuntime(15924): at dalvik.system.NativeStart.main(Native Method)
06-23 08:56:33.899: E/AndroidRuntime(15924): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:360)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.Activity.setContentView(Activity.java:1932)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.ngshah.goglemapv2withlazyloading.MainActivity.onCreate(MainActivity.java:45)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.Activity.performCreate(Activity.java:5326)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
06-23 08:56:33.899: E/AndroidRuntime(15924): ... 11 more
06-23 08:56:33.899: E/AndroidRuntime(15924): Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
06-23 08:56:33.899: E/AndroidRuntime(15924): <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
06-23 08:56:33.899: E/AndroidRuntime(15924): at lzv.a(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at mcg.a(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at mcg.a(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at mbi.a(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at lxn.a(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at lxm.a(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at fnb.onTransact(SourceFile:107)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.os.Binder.transact(Binder.java:310)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.google.android.gms.dynamic.a$4.b(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.google.android.gms.dynamic.a.a(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:900)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
06-23 08:56:33.899: E/AndroidRuntime(15924): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)
06-23 08:56:33.899: E/AndroidRuntime(15924): ... 21 more
06-23 08:56:36.151: I/Process(15924): Sending signal. PID: 15924 SIG: 9
The issue is in your AndroidManifest.xml as stated by this line in your LogCat Exception:
Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
If you add this permission to the AndroidManifest it should work correctly
这篇关于android.view.inflateexception二进制XML文件中的行#7错误充气类片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!