You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

导入mixare源码至Android Studio 3.1遇Cannot resolve symbol 'maps'错误

Fixing "Cannot resolve symbol 'maps'" for com.google.android.maps imports in Android Studio 3.1

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:


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 Classv2 Replacement
com.google.android.maps.GeoPointcom.google.android.gms.maps.model.LatLng
MapActivityExtend AppCompatActivity and use SupportMapFragment
MapControllerUse GoogleMap.moveCamera() or adjust settings via GoogleMap.getUiSettings()
MapViewcom.google.android.gms.maps.MapView
Overlay/OverlayItemUse MarkerOptions to create markers, or custom GroundOverlay
ProjectionGoogleMap.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.


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:

  1. Find a copy of maps.jar (from old Android SDK Extras, typically for Android 4.4.2 or earlier).
  2. Place the jar in your project's libs folder, right-click it, and select "Add as Library".
  3. Add this line inside the <application> tag in AndroidManifest.xml:
<uses-library android:name="com.google.android.maps" android:required="true" />
  1. 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

火山引擎 最新活动