我已经开始使用Google API进行编程,而我的第一个应用程序并不起作用。为什么? Android模拟器被黑屏阻止。
日志:
05-06 14:25:41.554: I/ActivityManager(73): Starting: Intent { flg=0x10000000 cmp=com.google.android.gsf/.update.SystemUpdateInstallDialog } from pid 174
05-06 14:25:41.573: W/WindowManager(73): Failure taking screenshot for (230x143) to layer 21000
05-06 14:25:41.685: I/InputReader(73): Device reconfigured: id=0, name='qwerty2', display size is now 1280x800
05-06 14:25:41.764: I/ActivityManager(73): Start proc com.android.deskclock for broadcast com.android.deskclock/.AlarmInitReceiver: pid=341 uid=10026 gids={}
05-06 14:25:41.997: D/MediaScannerService(156): start scanning volume internal: [/system/media]
05-06 14:25:42.187: I/ActivityManager(73): Starting: Intent { flg=0x10000000 cmp=com.google.android.gsf/.update.SystemUpdateDownloadDialog } from pid 174
05-06 14:25:42.595: E/TelephonyManager(174): Hidden constructor called more than once per process!
05-06 14:25:42.595: E/TelephonyManager(174): Original: com.google.android.location, new: com.google.android.gsf
05-06 14:25:42.764: I/dalvikvm(73): Jit: resizing JitTable from 512 to 1024
05-06 14:25:43.254: I/ActivityThread(341): Pub com.android.deskclock: com.android.deskclock.AlarmProvider
05-06 14:25:43.573: I/ActivityManager(73): Displayed com.android.launcher/com.android.launcher2.Launcher: +44s558ms
05-06 14:25:43.686: I/TabletStatusBar(123): DISABLE_CLOCK: no
05-06 14:25:43.686: I/TabletStatusBar(123): DISABLE_NAVIGATION: no
05-06 14:25:43.975: D/dalvikvm(174): GC_CONCURRENT freed 398K, 7% free 6554K/7047K, paused 7ms+35ms
05-06 14:25:44.475: I/TabletStatusBar(123): DISABLE_BACK: no
05-06 14:25:44.653: I/ARMAssembler(73): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x478be520:0x478be6e8] in 1714552 ns
05-06 14:25:45.284: D/dalvikvm(174): GC_EXPLICIT freed 34K, 8% free 6551K/7047K, paused 4ms+4ms
05-06 14:25:45.653: V/AlarmClock(341): AlarmInitReceiver finished
05-06 14:25:45.713: I/ActivityManager(73): Start proc com.android.quicksearchbox for broadcast com.android.quicksearchbox/.SearchWidgetProvider: pid=354 uid=10007 gids={3003}
05-06 14:25:45.893: D/dalvikvm(174): GC_EXPLICIT freed 47K, 8% free 6505K/7047K, paused 3ms+18ms
05-06 14:25:46.294: D/dalvikvm(174): GC_EXPLICIT freed 3K, 8% free 6502K/7047K, paused 4ms+4ms
05-06 14:25:46.664: I/ActivityThread(354): Pub com.android.quicksearchbox.google: com.android.quicksearchbox.google.GoogleSuggestionProvider
05-06 14:25:46.804: I/ActivityThread(354): Pub com.android.quicksearchbox.shortcuts: com.android.quicksearchbox.ShortcutsProvider
05-06 14:25:47.216: I/ActivityManager(73): Start proc com.android.music for broadcast com.android.music/.MediaAppWidgetProvider: pid=365 uid=10015 gids={3003, 1015}
05-06 14:25:47.674: D/dalvikvm(73): GC_CONCURRENT freed 4015K, 52% free 13520K/27783K, paused 56ms+19ms
05-06 14:25:48.514: D/GTalkService(174): [ReonnectMgr] ### report Inet condition: status=false, networkType=0
05-06 14:25:48.514: D/ConnectivityService(73): reportNetworkCondition(0, 0)
05-06 14:25:48.514: D/ConnectivityService(73): Inet connectivity change, net=0, condition=0,mActiveDefaultNetwork=0
05-06 14:25:48.514: D/ConnectivityService(73): starting a change hold
05-06 14:25:48.613: V/AlarmClock(341): AlarmInitReceiver finished
05-06 14:25:48.686: I/ActivityManager(73): Start proc com.google.android.gsf.login for service com.google.android.gsf.login/com.google.android.gsf.loginservice.GoogleLoginService: pid=378 uid=10013 gids={3003, 1015, 2001, 1007}
05-06 14:25:48.755: D/GTalkService(174): [ReonnectMgr] ### report Inet condition: status=false, networkType=0
05-06 14:25:48.755: D/ConnectivityService(73): reportNetworkCondition(0, 0)
05-06 14:25:48.764: D/ConnectivityService(73): Inet connectivity change, net=0, condition=0,mActiveDefaultNetwork=0
05-06 14:25:48.834: D/ConnectivityService(73): currently in hold - not setting new end evt
05-06 14:25:49.754: E/TelephonyManager(174): Hidden constructor called more than once per process!
05-06 14:25:49.754: E/TelephonyManager(174): Original: com.google.android.location, new: com.google.android.gsf
05-06 14:25:50.674: D/dalvikvm(289): GC_EXPLICIT freed 36K, 5% free 6206K/6531K, paused 6424ms+49ms
05-06 14:25:50.837: W/ActivityManager(73): No content provider found for:
05-06 14:25:51.004: W/ActivityManager(73): No content provider found for:
05-06 14:25:51.054: D/PackageParser(73): Scanning package: /data/app/vmdl-195172957.tmp
05-06 14:25:51.426: D/MediaScanner(156): prescan time: 1351ms
05-06 14:25:51.445: D/MediaScanner(156): scan time: 94ms
05-06 14:25:51.445: D/MediaScanner(156): postscan time: 1ms
05-06 14:25:51.445: D/MediaScanner(156): total time: 1446ms
05-06 14:25:51.474: D/MediaScannerService(156): done scanning volume internal
05-06 14:25:51.523: D/ConnectivityService(73): Inet hold end, net=0, condition =0, published condition =0
05-06 14:25:51.523: D/ConnectivityService(73): no change in condition - aborting
05-06 14:25:51.924: I/PackageManager(73): Removing non-system package:hb.ku
05-06 14:25:51.924: I/ActivityManager(73): Force stopping package hb.ku uid=10039
05-06 14:25:52.417: D/PackageManager(73): Scanning package hb.ku
05-06 14:25:52.466: I/PackageManager(73): Package hb.ku codePath changed from /data/app/hb.ku-1.apk to /data/app/hb.ku-2.apk; Retaining data and using new
05-06 14:25:52.517: I/PackageManager(73): Unpacking native libraries for /data/app/hb.ku-2.apk
05-06 14:25:52.573: D/installd(33): DexInv: --- BEGIN '/data/app/hb.ku-2.apk' ---
05-06 14:25:52.933: D/dalvikvm(389): DexOpt: load 15ms, verify+opt 21ms
05-06 14:25:53.094: D/installd(33): DexInv: --- END '/data/app/hb.ku-2.apk' (success) ---
05-06 14:25:53.094: W/PackageManager(73): Code path for pkg : hb.ku changing from /data/app/hb.ku-1.apk to /data/app/hb.ku-2.apk
05-06 14:25:53.125: W/PackageManager(73): Resource path for pkg : hb.ku changing from /data/app/hb.ku-1.apk to /data/app/hb.ku-2.apk
05-06 14:25:53.125: D/PackageManager(73): Activities: hb.ku.ProbandoActivity
05-06 14:25:53.556: I/installd(33): move /data/dalvik-cache/data@app@hb.ku-2.apk@classes.dex -> /data/dalvik-cache/data@app@hb.ku-2.apk@classes.dex
05-06 14:25:53.556: D/PackageManager(73): New package installed in /data/app/hb.ku-2.apk
05-06 14:25:54.453: D/dalvikvm(149): GC_CONCURRENT freed 1010K, 8% free 14319K/15495K, paused 5ms+11ms
05-06 14:25:54.594: I/ActivityManager(73): Force stopping package hb.ku uid=10039
05-06 14:25:54.663: I/ActivityManager(73): Force stopping package hb.ku uid=10039
05-06 14:25:55.493: D/PackageManager(73): generateServicesMap(android.accounts.AccountAuthenticator): 3 services unchanged
05-06 14:25:55.533: D/dalvikvm(149): GC_FOR_ALLOC freed 1254K, 12% free 14290K/16135K, paused 189ms
05-06 14:25:55.584: D/PackageManager(73): generateServicesMap(android.content.SyncAdapter): 5 services unchanged
05-06 14:25:55.773: D/dalvikvm(213): GC_EXPLICIT freed 254K, 6% free 6437K/6791K, paused 4ms+4ms
05-06 14:25:56.233: D/dalvikvm(149): GC_EXPLICIT freed 802K, 11% free 14588K/16327K, paused 4ms+6ms
05-06 14:25:56.353: D/PackageManager(73): generateServicesMap(android.accounts.AccountAuthenticator): 3 services unchanged
05-06 14:25:56.373: D/PackageManager(73): generateServicesMap(android.content.SyncAdapter): 5 services unchanged
05-06 14:25:56.474: W/RecognitionManagerService(73): no available voice recognition services found
05-06 14:25:56.853: I/ActivityManager(73): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=397 uid=10010 gids={}
05-06 14:25:57.305: I/ActivityThread(397): Pub com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider
05-06 14:25:58.566: D/dalvikvm(149): GC_FOR_ALLOC freed 1364K, 13% free 14697K/16775K, paused 130ms
05-06 14:25:58.714: I/AccountTypeManager(213): Loaded meta-data for 1 account types, 0 accounts in 216ms
05-06 14:25:59.214: D/dalvikvm(149): GC_FOR_ALLOC freed 4117K, 32% free 11479K/16775K, paused 85ms
05-06 14:25:59.703: D/ExchangeService(316): Reconciling accounts...
05-06 14:25:59.853: D/dalvikvm(149): GC_CONCURRENT freed 1116K, 28% free 12129K/16775K, paused 5ms+6ms
05-06 14:26:00.413: D/dalvikvm(149): GC_CONCURRENT freed 1109K, 23% free 12986K/16775K, paused 8ms+4ms
05-06 14:26:00.896: D/dalvikvm(213): GC_CONCURRENT freed 214K, 5% free 6756K/7111K, paused 4ms+512ms
05-06 14:26:00.916: D/dalvikvm(149): GC_CONCURRENT freed 1084K, 18% free 13922K/16775K, paused 4ms+6ms
05-06 14:26:01.724: D/dalvikvm(73): GC_EXPLICIT freed 1312K, 52% free 13606K/27783K, paused 39ms+21ms
05-06 14:26:01.804: I/installd(33): unlink /data/dalvik-cache/data@app@hb.ku-1.apk@classes.dex
05-06 14:26:01.813: D/AndroidRuntime(232): Shutting down VM
05-06 14:26:01.848: I/AndroidRuntime(232): NOTE: attach of thread 'Binder Thread #3' failed
05-06 14:26:01.853: D/dalvikvm(232): GC_CONCURRENT freed 108K, 85% free 325K/2048K, paused 1ms+5ms
05-06 14:26:01.853: D/jdwp(232): adbd disconnected
05-06 14:26:02.643: D/AndroidRuntime(410): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
05-06 14:26:02.643: D/AndroidRuntime(410): CheckJNI is ON
05-06 14:26:03.594: D/AndroidRuntime(410): Calling main entry com.android.commands.am.Am
05-06 14:26:03.644: I/ActivityManager(73): Force stopping package hb.ku uid=10039
05-06 14:26:03.653: I/ActivityManager(73): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=hb.ku/.ProbandoActivity } from pid 410
05-06 14:26:03.653: W/WindowManager(73): Failure taking screenshot for (216x135) to layer 21005
05-06 14:26:03.727: D/AndroidRuntime(410): Shutting down VM
05-06 14:26:03.773: I/AndroidRuntime(410): NOTE: attach of thread 'Binder Thread #3' failed
05-06 14:26:03.785: I/ActivityManager(73): Start proc hb.ku for activity hb.ku/.ProbandoActivity: pid=419 uid=10039 gids={3003}
05-06 14:26:03.826: D/dalvikvm(410): GC_CONCURRENT freed 109K, 83% free 354K/2048K, paused 1ms+1ms
05-06 14:26:03.826: D/jdwp(410): adbd disconnected
05-06 14:26:05.573: W/ActivityThread(419): Application hb.ku is waiting for the debugger on port 8100...
05-06 14:26:05.573: I/System.out(419): Sending WAIT chunk
05-06 14:26:05.615: I/dalvikvm(419): Debugger is active
05-06 14:26:05.814: I/System.out(419): Debugger has connected
05-06 14:26:05.823: I/System.out(419): waiting for debugger to settle...
05-06 14:26:06.035: I/System.out(419): waiting for debugger to settle...
05-06 14:26:06.233: I/System.out(419): waiting for debugger to settle...
05-06 14:26:06.455: I/System.out(419): waiting for debugger to settle...
05-06 14:26:06.653: I/System.out(419): waiting for debugger to settle...
05-06 14:26:06.855: I/System.out(419): waiting for debugger to settle...
05-06 14:26:07.066: I/System.out(419): waiting for debugger to settle...
05-06 14:26:07.275: I/System.out(419): waiting for debugger to settle...
05-06 14:26:07.477: I/System.out(419): waiting for debugger to settle...
05-06 14:26:07.674: I/System.out(419): waiting for debugger to settle...
05-06 14:26:07.873: I/System.out(419): waiting for debugger to settle...
05-06 14:26:08.016: V/TLINE(73): new: android.text.TextLine@40b3dc18
05-06 14:26:08.084: I/System.out(419): waiting for debugger to settle...
05-06 14:26:08.283: I/System.out(419): waiting for debugger to settle...
05-06 14:26:08.483: I/System.out(419): waiting for debugger to settle...
05-06 14:26:08.686: I/System.out(419): waiting for debugger to settle...
05-06 14:26:08.894: I/System.out(419): waiting for debugger to settle...
05-06 14:26:09.094: I/System.out(419): waiting for debugger to settle...
05-06 14:26:09.294: I/System.out(419): waiting for debugger to settle...
05-06 14:26:09.334: D/dalvikvm(149): GC_EXPLICIT freed 946K, 15% free 14417K/16775K, paused 8ms+15ms
05-06 14:26:09.496: I/System.out(419): waiting for debugger to settle...
05-06 14:26:09.544: D/dalvikvm(149): GC_EXPLICIT freed <1K, 15% free 14417K/16775K, paused 3ms+4ms
05-06 14:26:09.714: I/System.out(419): debugger has settled (1474)
05-06 14:26:11.993: D/dalvikvm(419): GC_CONCURRENT freed 144K, 5% free 6498K/6791K, paused 12ms+7ms
05-06 14:26:13.693: W/ActivityManager(73): Launch timeout has expired, giving up wake lock!
05-06 14:26:14.983: W/ActivityManager(73): Activity idle timeout for ActivityRecord{409f0178 hb.ku/.ProbandoActivity}
05-06 14:26:15.294: D/dalvikvm(419): GC_CONCURRENT freed 257K, 6% free 6644K/7047K, paused 5ms+3ms
05-06 14:26:19.057: D/dalvikvm(419): GC_CONCURRENT freed 290K, 7% free 6802K/7239K, paused 19ms+6ms
05-06 14:26:22.094: D/dalvikvm(149): GC_EXPLICIT freed <1K, 15% free 14417K/16775K, paused 4ms+100ms
05-06 14:26:22.224: D/dalvikvm(419): GC_CONCURRENT freed 796K, 13% free 6421K/7367K, paused 4ms+9ms
05-06 14:26:30.989: I/InputDispatcher(73): Dropping event because there is no touched window or focused application.
05-06 14:26:31.144: I/InputDispatcher(73): Dropping event because there is no touched window or focused application.
05-06 14:26:31.581: I/InputDispatcher(73): Dropping event because there is no touched window or focused application.
05-06 14:26:48.022: I/InputDispatcher(73): Dropping event because there is no touched window or focused application.
05-06 14:29:35.008: I/dalvikvm(73): Jit: resizing JitTable from 1024 to 2048
05-06 14:30:33.434: D/SntpClient(73): request time failed: java.net.SocketException: Address family not supported by protocol
05-06 14:35:33.477: D/SntpClient(73): request time failed: java.net.SocketException: Address family not supported by protocol
文件主要:ProbandoActivity.java
package hb.ku;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class ProbandoActivity extends MapActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
//getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onCreate(savedInstanceState);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
档案AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hb.ku"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".ProbandoActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:2)
不确定这是否是唯一的问题,但在您的活动中,您在findViewById
之前尝试setContentView
。这是错的。您需要首先告诉Android您要加载哪个XML,然后引用元素。
答案 1 :(得分:0)
我修改了你的代码,所以请检查一下,它可以帮助你......按照代码行的顺序...
public class ProbandoActivity extends MapActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}