在尝试设置Google Maps v2时,我一直在
无法解析Lcom / alpha / dealtap / Map的超类; (40)
java.lang.RuntimeException:无法实例化活动 ComponentInfo {com.alpha.dealtap / com.alpha.dealtap.Map}: java.lang.ClassNotFoundException:loaderdalvik中的com.alpha.dealtap.Map。 loaderdalvik.system.PathClassLoader [/system/framework/com.google.android.maps.jar:/data/app/com.alpha.dealtap-1.apk
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alpha.dealtap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<permission
android:name="com.alpha.dealtap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="dealtap.permission.MAPS_RECEIVE" />
<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="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="com.example.mapdemo.permission.MAPS_RECEIVE"/> -->
<!-- This might be the problem......The Google code produces an error -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/dealtap_text"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.alpha.dealtap.Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.alpha.dealtap.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.alpha.dealtap.Search_Page"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.alpha.dealtap.SEARCH_PAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.alpha.dealtap.DealPage"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.alpha.dealtap.DEALPAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.alpha.dealtap.StorePage"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.alpha.dealtap.STOREPAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.alpha.dealtap.Map"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.alpha.dealtap.MAP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.alpha.dealtap.TapDeal"
android:label="TapDeal"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="com.alpha.dealtap.TAPDEAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Took it out for privacy" />
</application>
</manifest>
Map.Java
package com.alpha.dealtap;
import com.alpha.dealtap.R;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class Map extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
}
}
Map.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/white" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
我已经按照Google开发流程和几个教程进行了操作,但还没有找到答案
谢谢!
新的LogCat
06-09 14:11:30.552:E / AndroidRuntime(11833):致命异常:主要 06-09 14:11:30.552:E / AndroidRuntime(11833):java.lang.RuntimeException:无法启动活动ComponentInfo {com.alpha.dealtap / com.alpha.dealtap.Map}:android.view.InflateException:Binary XML文件行#7:错误膨胀类片段 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.app.ActivityThread.access $ 1500(ActivityThread.java:124) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:968) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.os.Handler.dispatchMessage(Handler.java:99) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.os.Looper.loop(Looper.java:130) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.app.ActivityThread.main(ActivityThread.java:3806) 06-09 14:11:30.552:E / AndroidRuntime(11833):at java.lang.reflect.Method.invokeNative(Native Method) 06-09 14:11:30.552:E / AndroidRuntime(11833):at java.lang.reflect.Method.invoke(Method.java:507) 06-09 14:11:30.552:E / AndroidRuntime(11833):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839) 06-09 14:11:30.552:E / AndroidRuntime(11833):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-09 14:11:30.552:E / AndroidRuntime(11833):at dalvik.system.NativeStart.main(Native Method) 06-09 14:11:30.552:E / AndroidRuntime(11833):引起:android.view.InflateException:二进制XML文件行#7:错误膨胀类片段 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.view.LayoutInflater.inflate(LayoutInflater.java:408) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.view.LayoutInflater.inflate(LayoutInflater.java:320) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.view.LayoutInflater.inflate(LayoutInflater.java:276) 06-09 14:11:30.552:E / AndroidRuntime(11833):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.app.Activity.setContentView(Activity.java:1703) 06-09 14:11:30.552:E / AndroidRuntime(11833):at com.alpha.dealtap.Map.onCreate(Map.java:13) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660) 06-09 14:11:30.552:E / AndroidRuntime(11833):......还有11个 06-09 14:11:30.552:E / AndroidRuntime(11833):引起:android.support.v4.app.Fragment $ InstantiationException:无法实例化片段com.google.android.gms.maps.SupportMapFragment:确保课程name存在,是public,并且具有一个公共的空构造函数 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.support.v4.app.Fragment.instantiate(Fragment.java:401) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.support.v4.app.Fragment.instantiate(Fragment.java:369) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) 06-09 14:11:30.552:E / AndroidRuntime(11833):... 20多个 06-09 14:11:30.552:E / AndroidRuntime(11833):引起:java.lang.ClassNotFoundException:加载器dalvik.system.PathClassLoader中的com.google.android.gms.maps.SupportMapFragment [/ data / app / com .alpha.dealtap-2.apk] 06-09 14:11:30.552:E / AndroidRuntime(11833):at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 06-09 14:11:30.552:E / AndroidRuntime(11833):at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 06-09 14:11:30.552:E / AndroidRuntime(11833):at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 06-09 14:11:30.552:E / AndroidRuntime(11833):在android.support.v4.app.Fragment.instantiate(Fragment.java:391)
答案 0 :(得分:2)
步骤1:摆脱<uses-library android:name="com.google.android.maps" />
,因为地图V2没有使用它。
步骤2:如果您使用的是ADT插件的R22(或更高版本)版本,请务必fix your build path。
如果这些没有帮助,请确保您已将Play Services Android库项目正确附加到项目中。例如,如果您手动修改了构建路径(超出了步骤2要求的范围),那么这不是附加Play服务Android库项目的正确方法。
答案 1 :(得分:0)
添加你的片段属性android:name =“com.google.android.gms.maps.SupportMapFragment” 在此权限中添加完整包名称(缺少com。):“
<uses-permission android:name="dealtap.permission.MAPS_RECEIVE />
将google-play-services.jar从extras添加到您的libs,无论您已经添加了哪个库项目。
最重要的是,添加您的活动:
GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();