该应用程序最初工作但后来停止了,因为我添加了一些其他代码,我已经撤消它,但现在旧的代码也没有工作。
我的清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.btrack"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="8" />
<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.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.example.btrack.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>
<activity
android:name="com.example.btrack.Inbay"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.btrack.Inbus"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.btrack.Bus_track"
android:label="@string/app_name" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDKrNEcOQfkJ2Co-YE_8B4sfXuzlSXqd7k"/>
</application>
<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"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
我的代码
package com.example.btrack;
import android.app.Activity;
import android.os.Bundle;
public abstract class Bus_track extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bus_track);
//GoogleMap mMap;
//mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
//mMap.setMyLocationEnabled(true);
}
}
布局
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
错误
04-05 22:48:10.550: I/Adreno200-EGL(10583): Reconstruct Branch: AU_LINUX_ANDROID_JB_2.3.04.01.01.032.173 + NOTHING
04-05 22:48:13.242: W/dalvikvm(10583): threadid=1: thread exiting with uncaught exception (group=0x41d72450)
04-05 22:48:13.252: E/AndroidRuntime(10583): FATAL EXCEPTION: main
04-05 22:48:13.252: E/AndroidRuntime(10583): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.btrack/com.example.btrack.Bus_track}: java.lang.InstantiationException: can't instantiate class com.example.btrack.Bus_track
04-05 22:48:13.252: E/AndroidRuntime(10583): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1986)
使用此代码的应用程序最初正在运行。
答案 0 :(得分:0)
更改此
public abstract class Bus_track extends Activity {
到
public class Bus_track extends Activity {
阅读本文
Interview: Can we instantiate abstract class?
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="8" /> // have the latest like 19
// Lint, if enabled, will warn you about it
另请考虑将所有<uses-permission.../>
代码移至application
代码
阅读开发人员文档和