导入mixare源码至Android Studio 3.1遇Cannot resolve symbol 'maps'错误
The error you're hitting comes down to one key issue: the com.google.android.maps classes belong to the deprecated Google Maps Android API v1, which Google stopped supporting years ago. Android Studio 3.1 doesn't include this outdated library by default, hence the unresolved symbols.
Here are two ways to resolve this:
Recommended: Migrate to Google Maps Android API v2
Maps v1 is obsolete, so moving to v2 is the only sustainable fix. Here's how to adapt your mixare code:
1. Update your Module-level build.gradle
Remove any old Maps v1 references and add the v2 dependency. For Android Studio 3.1, use a compatible version (e.g., the 17.x series):
dependencies { // Replace old Maps v1 dependencies with this implementation 'com.google.android.gms:play-services-maps:17.0.1' // Add location services if mixare needs them implementation 'com.google.android.gms:play-services-location:17.1.0' }
2. Adjust your AndroidManifest.xml
- Delete old Maps v1 API key entries and permissions.
- Add these v2-specific lines:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application ...> <!-- Replace with your new Maps v2 API key from Google Cloud Console --> <meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_V2_API_KEY" /> </application>
3. Refactor code to use v2 classes
Swap out deprecated v1 imports with their modern equivalents:
| v1 Class | v2 Replacement |
|---|---|
com.google.android.maps.GeoPoint | com.google.android.gms.maps.model.LatLng |
MapActivity | Extend AppCompatActivity and use SupportMapFragment |
MapController | Use GoogleMap.moveCamera() or adjust settings via GoogleMap.getUiSettings() |
MapView | com.google.android.gms.maps.MapView |
Overlay/OverlayItem | Use MarkerOptions to create markers, or custom GroundOverlay |
Projection | GoogleMap.getProjection() |
Quick code example:
Instead of extending MapActivity, use a fragment-based approach:
public class MixareMapActivity extends AppCompatActivity implements OnMapReadyCallback { private GoogleMap mMap; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); } @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker (replaces OverlayItem) LatLng target = new LatLng(48.8566, 2.3522); mMap.addMarker(new MarkerOptions().position(target).title("Paris")); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, 14)); } }
4. Check for updated mixare versions
Mixare might have a newer branch or fork that already supports Maps v2. Checking the project's repository could save you hours of manual refactoring.
Not Recommended: Add Maps v1 Library Manually
If you absolutely must stick with v1 (note: this won't work on Android 8.0+ and Google no longer issues v1 API keys), follow these steps:
- Find a copy of
maps.jar(from old Android SDK Extras, typically for Android 4.4.2 or earlier). - Place the jar in your project's
libsfolder, right-click it, and select "Add as Library". - Add this line inside the
<application>tag inAndroidManifest.xml:
<uses-library android:name="com.google.android.maps" android:required="true" />
- In Android Studio's SDK Manager, enable "Google APIs" for an older SDK version (e.g., Android 4.4.2).
This is a temporary workaround at best—v1 is completely unsupported, so avoid using it for any new or updated projects.
内容的提问来源于stack exchange,提问作者EnDelt64




