检查谷歌播放服务apk

时间:2017-02-13 15:47:08

标签: java android google-maps android-gradle android-manifest

我一直在使用android studio 2.2.3我在检查谷歌播放服务时遇到问题我的物理设备上启用了apk我有这个例外我还包括multiDexEnabled这是gradle(app)但是我仍然是无法获取我在java代码中包含的Toast消息,以检查我是否已成功启用Google Play服务。 请帮忙。

这是我的例外。

错误:任务':app:transformClassesWithDexForDebug'执行失败。

  

com.android.build.api.transform.TransformException:   com.android.ide.common.process.ProcessException:

java.util.concurrent.ExecutionException:

com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536

的Manifest.xml

package="com.mapgoogle.googlemap">

    

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

<application
    android:allowBackup="true"

    android:icon="@mipmap/ic_launcher"

    android:label="@string/app_name"

    android:supportsRtl="true"

    android:theme="@style/AppTheme">

    <activity android:name=".MainActivity">

        <intent-filter>

            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

        </intent-filter>
    </activity>

android:value="api_key"/>

    <meta-data android:name="com.google.android.gms.version"

        android:value="@integer/google_play_services_version"/>

</application>

的gradle(APP)

申请插件:&#39; com.android.application&#39;

android {

compileSdkVersion 25

buildToolsVersion "24.0.3"

defaultConfig {

    applicationId "com.mapgoogle.googlemap"

    minSdkVersion 14

    targetSdkVersion 25

    versionCode 1

    versionName "1.0"

    testInstrumentationRunner 

&#34; android.support.test.runner.AndroidJUnitRunner&#34;

    multiDexEnabled true

}

buildTypes {

    release {

        minifyEnabled false

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 

&#39; proguard-rules.pro&#39;

    }
}

}

依赖项{

compile fileTree(include: ['*.jar'], dir: 'libs')


androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 

{

    exclude group: 'com.android.support', module: 'support-annotations'

})

compile 'com.android.support:appcompat-v7:25.1.1'

testCompile 'junit:junit:4.12'

compile 'com.google.android.gms:play-services:10.0.1'

}

MainActivity.java

打包com.mapgoogle.googlemap;

导入android.app.Dialog;

import android.support.v7.app.AppCompatActivity;

导入android.os.Bundle;

导入android.telecom.Connection;

导入android.widget.Toast;

导入com.google.android.gms.common.ConnectionResult;

导入com.google.android.gms.common.GooglePlayServicesUtil;

导入com.google.android.gms.maps.GoogleMap;

公共类MainActivity扩展了AppCompatActivity {

GoogleMap mMap;

private static final int Dialog_erroe=9001;

@Override

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
   // setContentView(R.layout.activity_main);

    if(serviceok()){
        setContentView(R.layout.activity_map);

        Toast.makeText(this,"Ready to map",Toast.LENGTH_SHORT).show();

}else{
        setContentView(R.layout.activity_main);

    }

}

public boolean serviceok(){

    int isAvaiable= 

GooglePlayServicesUtil.isGooglePlayServicesAvailable(本);

    if(isAvaiable== ConnectionResult.SUCCESS) {
    }

    else if(GooglePlayServicesUtil.isUserRecoverableError(isAvaiable)){
        Dialog 

对话框= GooglePlayServicesUtil.getErrorDialog(isAvaiable,为此,Dialog_erroe);

        dialog.show();

    }else{

        Toast.makeText(this,"Can't connect to 

互联网&#34;,Toast.LENGTH_SHORT).show();

    }

return false;

}

}

1 个答案:

答案 0 :(得分:0)

此例外与Google Play服务无关。

您必须启用multidex才能超过65k方法限制。

查看THIS问题了解详情