运行释放时错误夸大地图片段



我读了许多类似的主题,并尝试了所有接受的答案,但没有任何效果。当我作为调试时运行时,我的应用程序正常工作,但是当我生成.apk文件时,将其安装在手机上时,它崩溃了。

我有错误

无法启动活动componentInfo {vn.com.ttsoft.dhd/vn.com.ttsoft.dhd.mapsactivity}:android.view.inflateException:binary xml xml xml文件行#1:类片段

线setContentView(R.layout.activity_maps);

引起的错误

我正如某人在另一个问题中所说的那样,将其添加到了我的清单中。但这行不起作用。

    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

我的活动扩展了碎片:

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
@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);

这是我的activity_maps.xml

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="vn.com.ttsoft.dhd.MapsActivity" />

我的手机运行Android 7.1 Nougat。有人知道解决方案吗?

i将类Path更新为com.android.tools.build:gradle:3.0.1,并且有效!以前的版本是2.3.3。

现在,当"重建项目"时,我会遇到错误,但是当我"生成签名的APK"并在手机上安装此.APK文件时,它可以正常工作。这有多奇怪!

最新更新