Eclipse의 Windows에서 완벽하게 작동하는 프로젝트가 있습니다. 대부분의 작업이 이제 Mac에서 이루어 지므로 Mac 용 Eclipse로 전환하고 있습니다.
프로젝트 전체에서 모든 빌드 경로 오류를 수정했으며, "this_xml_name을 확인할 수 없거나 필드가 아닙니다"만 남아 있습니다. 이론적으로 R 파일을 빌드 할 때 오류가 발생합니다.
그러나 이것은 단일 파일에서만 나타나는이 문제가 처음 발생했으며 ID 또는 레이아웃이 아닙니다. R.layout, R.id, R.menu 및 R.drawable에서 발생합니다. 내 프로젝트 전체의 다른 모든 참조는 완벽하게 괜찮으며 링크 된 파일의 각 R. 참조에서 오류 만 발견됩니다.
MapActivity.java
package com.example.android;
import java.util.Timer;
import java.util.TimerTask;
import android.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
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;
public class MapActivity extends FragmentActivity {
FragmentActivity activity = this;
private static final int GPS_ERRORDIALOG_REQUEST = 9001;
protected GoogleMap mMap;
String locAddr;
String locName;
Double locLongitude;
Double locLatitude;
final Handler handler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (servicesOK()) {
setContentView(R.layout.activity_map);
if (initMap()) {
Bundle extras = getIntent().getExtras();
if (extras != null) {
locAddr = extras.getString("address");
locName = extras.getString("name");
locLongitude = extras.getDouble("longitude");
locLatitude = extras.getDouble("latitude");
activity.setTitle(locName);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable()
{
public void run()
{
LatLng coordinates = new LatLng(locLatitude, locLongitude);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(coordinates, 14.0f));
Marker marker = mMap.addMarker(new MarkerOptions()
.position(coordinates)
.title(locName)
.snippet(locAddr)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_marker)));
marker.showInfoWindow();
/*mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker arg0) {
Intent intent = new Intent(MapActivity.this, DetailsActivity.class);
intent.putExtra("userkey", "MattCoker");
intent.putExtra("geolat", "29.7530");
intent.putExtra("geolong", "geozip");
intent.putExtra("clientid", "0");
intent.putExtra("siteid", "0");
startActivity(intent);
}
});*/
}
});
}
}, 3000);
} else {
Toast.makeText(activity, "Something went wrong displaying this location!", Toast.LENGTH_LONG).show();
}
}
}
else {
setContentView(R.layout.no_available_maps);
}
//Show the Up button in the action bar.
setupActionBar();
}
/**
* Set up the {@link android.app.ActionBar}.
*/
private void setupActionBar() {
activity.getActionBar().setDisplayHomeAsUpEnabled(true);
}
public boolean servicesOK() {
int isAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
if (isAvailable == ConnectionResult.SUCCESS) {
return true;
}
else if (GooglePlayServicesUtil.isUserRecoverableError(isAvailable)) {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvailable, activity, GPS_ERRORDIALOG_REQUEST);
dialog.show();
}
else {
Toast.makeText(activity, "Can't connect to Google Play Services", Toast.LENGTH_SHORT).show();
}
return false;
}
private boolean initMap() {
if (mMap == null) {
SupportMapFragment mapFrag = null;
mapFrag = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mMap = mapFrag.getMap();
}
return (mMap != null);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
// Associate searchable configuration with the SearchView
/*SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView =
(SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));*/
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int selectedMenuItem = item.getItemId();
if (selectedMenuItem == R.id.action_settings) {
Intent settingsIntent = new Intent(activity, SettingsActivity.class);
startActivity(settingsIntent);
return true;
} else if (selectedMenuItem == R.id.send_feedback) {
Intent sendFeedback = new Intent(android.content.Intent.ACTION_SEND);
sendFeedback.setType("message/rfc822");
sendFeedback.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"[email protected]"});
sendFeedback.putExtra(android.content.Intent.EXTRA_SUBJECT, "Feedback on example...");
startActivity(Intent.createChooser(sendFeedback, "Send Email"));
//TODO: Create Feedback Activity to send email
return true;
}
return false;
}
}
리소스 파일에 오류가 있으면 R.java
생성되지 않습니다. 이러한 오류를 수정하고 정리하고 빌드하십시오.
가지고있는 코드 살펴보기
import android.R;
다음으로 교체
import com.example.android.R;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다