我已经下载了AOSP源代码并为Raspberry pi构建它。一旦我在/ packages / apps下添加了应用程序源代码,并尝试构建获取我在下面发布的错误。我在Android.Manifest文件中添加了google apis 和所有依赖。它也在Android工作室模拟器中工作。 帮我解决这个问题....
/home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:16: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:17: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:18: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:19: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:20: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:21: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:22: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:23: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:24: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:25: The import com.google.android cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:35: OnMapReadyCallback cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:37: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:41: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:42: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:43: Polyline cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:51: SupportMapFragment cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:51: SupportMapFragment cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:87: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:88: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:89: LatLng cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:89: LatLng cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:90: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:90: CameraUpdateFactory cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:91: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:91: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:91: MarkerOptions cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:105: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:114: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:115: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:115: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:120: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:121: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:121: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:126: Polyline cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:127: Polyline cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:127: Polyline cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:136: Polyline cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:137: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:138: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:141: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:141: CameraUpdateFactory cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:141: LatLng cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:145: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:145: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:145: MarkerOptions cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:146: BitmapDescriptorFactory cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:148: LatLng cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:149: Marker cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:149: GoogleMap cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:149: MarkerOptions cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:150: BitmapDescriptorFactory cannot be resolved
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:152: LatLng cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:154: PolylineOptions cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:154: PolylineOptions cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:159: List<LatLng> cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:160: List<LatLng> cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:162: Polyline cannot be resolved to a type
ERROR: /home/sogu270240/raspberry/packages/apps/speedometer/src/com/example/sogu270240/MapsActivity.java:162: GoogleMap cannot be resolved to a type
这是我用过的Java文件
package com.example.sogu270240;
import android.Manifest;
import android.app.ProgressDialog;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
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;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import Modules.DirectionFinder;
import Modules.DirectionFinderListner;
import Modules.Route;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, DirectionFinderListner {
private GoogleMap mMap;
private Button btnFindPath;
private EditText etOrigin;
private EditText etDestination;
private List<Marker> originMarkers = new ArrayList<>();
private List<Marker> destinationMarkers = new ArrayList<>();
private List<Polyline> polylinePaths = new ArrayList<>();
private ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
btnFindPath = (Button) findViewById(R.id.btnFindPath);
etOrigin = (EditText) findViewById(R.id.etOrigin);
etDestination = (EditText) findViewById(R.id.etDestination);
btnFindPath.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendRequest();
}
});
}
private void sendRequest() {
String origin = etOrigin.getText().toString();
String destination = etDestination.getText().toString();
if (origin.isEmpty()) {
Toast.makeText(this, "Please enter origin address!", Toast.LENGTH_SHORT).show();
return;
}
if (destination.isEmpty()) {
Toast.makeText(this, "Please enter destination address!", Toast.LENGTH_SHORT).show();
return;
}
try {
new DirectionFinder(this, origin, destination).execute();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng bengaluru= new LatLng(12.846479, 77.680413);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(bengaluru, 18));
originMarkers.add(mMap.addMarker(new MarkerOptions()
.title("")
.position(bengaluru)));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
mMap.setMyLocationEnabled(true);
}
@Override
public void onDirectionFinderStart() {
progressDialog = ProgressDialog.show(this, "Please wait.",
"Finding direction..!", true);
if (originMarkers != null) {
for (Marker marker : originMarkers) {
marker.remove();
}
}
if (destinationMarkers != null) {
for (Marker marker : destinationMarkers) {
marker.remove();
}
}
if (polylinePaths != null) {
for (Polyline polyline:polylinePaths ) {
polyline.remove();
}
}
}
@Override
public void onDirectionFinderSuccess(List<Route> routes) {
progressDialog.dismiss();
polylinePaths = new ArrayList<>();
originMarkers = new ArrayList<>();
destinationMarkers = new ArrayList<>();
for (Route route : routes) {
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(route.startLocation, 16));
((TextView) findViewById(R.id.tvDuration)).setText(route.duration.text);
((TextView) findViewById(R.id.tvDistance)).setText(route.distance.text);
originMarkers.add(mMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.start_blue))
.title(route.startAddress)
.position(route.startLocation)));
destinationMarkers.add(mMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.end_green))
.title(route.endAddress)
.position(route.endLocation)));
PolylineOptions polylineOptions = new PolylineOptions().
geodesic(true).
color(Color.BLUE).
width(10);
for (int i = 0; i < route.points.size(); i++)
polylineOptions.add(route.points.get(i));
polylinePaths.add(mMap.addPolyline(polylineOptions));
}
}
}
Android.mk看起来像,
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/appcompat/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/gridlayout/res
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_TAGS := optional
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat:android.support.v7.gridlayout
#LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += googleplayservices:libs/google-play-services.jar \
# googleplayservices_lib:libs/google-play-services_lib.jar
LOCAL_STATIC_JAVA_LIBRARIES := libarity android-support-v4 guava
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
#LOCAL_STATIC_JAVA_LIBRARIES += googleplayservices
#LOCAL_STATIC_JAVA_LIBRARIES += googleplayservices_lib
#LOCAL_STATIC_JAVA_LIBRARIES += libgoogleplay
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
LOCAL_PACKAGE_NAME := speedometer
#include $(BUILD_MULTI_PREBUILT)
include $(BUILD_PACKAGE)
~
~
~