Friday, 6 September 2013

Android Toast cannot be resolved as field or type

Android Toast cannot be resolved as field or type

I've done some research on the above error and it would seem that to solve
there are two ways most people do:
Re import R
Close and restart eclipse
However I have done both and yet I still get the same error. Does anyone
know of any other ways to defeat this error?
I'm thinking though that it may be my code. I'm trying to compile the
bluetooth le sample found here
I've brought over everything yet I'm still stuck with 36 errors with most
of them being this cannot be resolved as field or type error.
Here is how they call the toast line:
Toast.makeText(this, R.string.error_bluetooth_not_supported,
Toast.LENGTH_SHORT).show();
And there strings.xml found in the values folder:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">BLE Sample</string>
<string name="ble_not_supported">BLE is not supported</string>
<string name="label_data">Data:</string>
<string name="label_device_address">Device address:</string>
<string name="label_state">State:</string>
<string name="no_data">No data</string>
<string name="connected">Connected</string>
<string name="disconnected">Disconnected</string>
<string name="title_devices">BLE Device Scan</string>
<string name="error_bluetooth_not_supported">Bluetooth not
supported.</string>
<string name="unknown_device">Unknown device</string>
<string name="unknown_characteristic">Unknown characteristic</string>
<string name="unknown_service">Unknown service</string>
<!-- Menu items -->
<string name="menu_connect">Connect</string>
<string name="menu_disconnect">Disconnect</string>
<string name="menu_scan">Scan</string>
<string name="menu_stop">Stop</string>
</resources>
I'm literally a day into my first android development and this is all new
to me. I thought using the sample code they would provide would help me
get a good over view of how the bluetooth system works.
Can anyone help me beat this error?
I should add that every item on this list has an error. Any time I call
anything with R.string. it get the same error. Logcat since 1:25pm:
09-06 13:25:20.901: E/(526): W/virtual loc_api_adapter_err
LocApiAdapter::enableData(int): default implementation invoked
09-06 13:25:20.901: E/(526): W/virtual loc_api_adapter_err
LocApiAdapter::setAPN(char*, int): default implementation invoked
09-06 13:25:20.911: D/PicasaUploaderSyncManager(25851): active network:
NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason:
(unspecified), extra: "SOL2", roaming: false, failover: false,
isAvailable: true
09-06 13:25:20.921: D/GCM(2565): GcmService start Intent {
act=android.net.conn.CONNECTIVITY_CHANGE flg=0x8000010
cmp=com.google.android.gms/.gcm.GcmService (has extras) }
android.net.conn.CONNECTIVITY_CHANGE
09-06 13:25:21.051: D/ConnectivityService(526):
handleInetConditionHoldEnd: net=1, condition=100, published condition=0
09-06 13:25:21.542: D/Tethering(526): MasterInitialState.processMessage
what=3
09-06 13:25:21.642: E/(526): W/virtual loc_api_adapter_err
LocApiAdapter::enableData(int): default implementation invoked
09-06 13:25:21.642: E/(526): W/virtual loc_api_adapter_err
LocApiAdapter::setAPN(char*, int): default implementation invoked
09-06 13:25:21.662: D/GCM(2565): GcmService start Intent {
act=android.net.conn.CONNECTIVITY_CHANGE flg=0x8000010
cmp=com.google.android.gms/.gcm.GcmService (has extras) }
android.net.conn.CONNECTIVITY_CHANGE
09-06 13:25:22.102: D/ConnectivityService(526):
handleInetConditionHoldEnd: net=1, condition=100, published condition=100
09-06 13:30:01.245: V/DigitalWidgetViewsFactory(6453): DigitalWidget sets
next alarm string to null
09-06 13:36:19.083: I/ActivityManager(526): No longer want
com.google.android.talk (pid 26303): empty for 1801s
09-06 13:36:31.455: V/BackupManagerService(526): Running a backup pass
09-06 13:36:31.455: V/BackupManagerService(526): clearing pending backups
09-06 13:36:31.455: V/PerformBackupTask(526): Beginning backup of 1 targets
09-06 13:36:31.485: V/BackupServiceBinder(526): doBackup() invoked
09-06 13:36:31.485: D/PerformBackupTask(526): invokeAgentForBackup on @pm@
09-06 13:36:31.495: I/PerformBackupTask(526): no backup data written; not
calling transport
09-06 13:36:31.506: D/PerformBackupTask(526): starting agent for backup of
BackupRequest{pkg=com.android.providers.settings}
09-06 13:36:31.506: D/BackupManagerService(526): awaiting agent for
ApplicationInfo{4202bfe0 com.android.providers.settings}
09-06 13:36:31.506: D/BackupManagerService(526): agentConnected
pkg=com.android.providers.settings
agent=android.app.backup.BackupAgent$BackupServiceBinder@42081138
09-06 13:36:31.506: I/BackupManagerService(526): got agent
android.app.backup.BackupAgent$BackupServiceBinder@42081138
09-06 13:36:31.506: D/PerformBackupTask(526): invokeAgentForBackup on
com.android.providers.settings
09-06 13:36:31.516: V/BackupServiceBinder(526): doBackup() invoked
09-06 13:36:31.526: W/SettingsBackupAgent(526): Couldn't backup
/data/misc/wifi/ipconfig.txt
09-06 13:36:31.526: I/PerformBackupTask(526): no backup data written; not
calling transport
09-06 13:36:31.526: I/PerformBackupTask(526): Backup pass finished.
09-06 13:39:59.999: I/ActivityManager(526): No longer want
com.google.android.music:main (pid 26385): empty for 1849s
09-06 13:40:00.099: W/ActivityManager(526): Scheduling restart of crashed
service com.google.android.music/.playback.MusicPlaybackService in 5000ms
09-06 13:40:05.134: I/ActivityManager(526): Start proc
com.google.android.music:main for service
com.google.android.music/.playback.MusicPlaybackService: pid=27303
uid=10041 gids={50041, 3003, 1015, 1028}
09-06 13:40:05.214: I/MusicStore(27303): Database version: 70
09-06 13:40:05.274: D/dalvikvm(27303): GC_CONCURRENT freed 315K, 4% free
9097K/9448K, paused 3ms+9ms, total 39ms
09-06 13:40:05.274: D/dalvikvm(27303): WAIT_FOR_CONCURRENT_GC blocked 2ms
09-06 13:40:05.284: D/dalvikvm(27303): WAIT_FOR_CONCURRENT_GC blocked 5ms
09-06 13:40:05.364: D/SystemUtils(27303): getSystemProperty: lpa.decode=null
09-06 13:40:05.364: D/CacheService(27303): onCreate
09-06 13:40:05.374: D/CacheService(27303): onBind
09-06 13:40:05.384: I/LocalDevicePlayback(27303): Streaming client created.
09-06 13:40:06.445: D/dalvikvm(27303): GC_CONCURRENT freed 181K, 3% free
9337K/9580K, paused 4ms+4ms, total 30ms
09-06 13:40:06.535: I/MediaStoreImporter(27303): Update: incremental Added
music: 0 Updated music: 0 Deleted music: 0 Created playlists: 0 Updated
playlists: 0 Deleted playlists: 0 Inserted playlist items: 0 Deleted
playlist items: 0 Removed orphaned playlist items: 0
09-06 13:40:10.459: I/MusicLeanback(27303): Conditions not met for
autocaching.
09-06 13:40:10.459: I/MusicLeanback(27303): Stop autocaching.
09-06 13:40:20.549: D/GCM(2565): Ignoring attempt to send heartbeat on
dead connection.
09-06 13:40:59.997: I/ActivityManager(526): No longer want
android.process.acore (pid 26550): empty for 1807s
09-06 13:45:01.283: V/DigitalWidgetViewsFactory(6453): DigitalWidget sets
next alarm string to null
09-06 13:48:16.403: I/EventLogService(2565): Aggregate from 1378470317827
(log), 1378469896229 (data)
09-06 13:48:16.533: I/ServiceDumpSys(2565): dumping service [account]
09-06 13:50:23.497: I/jdwp(24586): Ignoring second debugger -- accepting
and dropping
09-06 13:50:23.507: I/jdwp(20948): Ignoring second debugger -- accepting
and dropping
09-06 13:50:34.378: D/dalvikvm(526): GC_CONCURRENT freed 3407K, 27% free
23292K/31488K, paused 11ms+8ms, total 146ms
09-06 13:52:43.224: D/ChildProcessLauncher(5790): Setting up connection to
process: slot=2
09-06 13:52:43.224: I/ActivityManager(526): Start proc
com.android.chrome:sandboxed_process2 for service
com.android.chrome/org.chromium.content.app.SandboxedProcessService2:
pid=27469 uid=99002 gids={}
09-06 13:52:43.244: I/ChildProcessService(27469): Creating new
ChildProcessService pid=27469
09-06 13:52:43.254: D/ChildProcessLauncher(5790): on connect callback,
pid=27469 context=2105709408
09-06 13:52:43.254: I/LibraryLoader(27469): loading: chromeview
09-06 13:52:43.304: I/LibraryLoader(27469): loaded: chromeview
09-06 13:52:43.304: I/chromium(27469): [INFO:library_loader_hooks.cc(72)]
Chromium logging enabled: level = 0, default verbosity = 0
09-06 13:52:43.314: D/TraceEvent(27469): View tag enabled: false
09-06 13:52:43.334: I/chromium(27469):
[INFO:child_process_service.cc(132)] ChildProcessService: Exiting child
process.
09-06 13:52:43.344: W/ChildProcessConnection(5790): onServiceDisconnected
(crash?): pid=27469
09-06 13:52:43.344: D/ChildProcessLauncher(5790): stopping child
connection: pid=27469
09-06 13:52:43.344: I/ActivityManager(526): Process
com.android.chrome:sandboxed_process2 (pid 27469) has died.
09-06 13:52:43.344: W/ActivityManager(526): Scheduling restart of crashed
service
com.android.chrome/org.chromium.content.app.SandboxedProcessService2 in
5000ms

No comments:

Post a Comment