无法解析符号GOOGLE_PLAY_SERVICE_UPDATE_CODE

时间:2016-05-24 07:28:54

标签: android google-play-services

我在尝试使用Google Play服务时遇到此问题,即使我在build.gragle文件中包含playservices,并在清单文件中包含此代码。

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

这是我的build.gradle文件

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "xyz.in.googleplayservice"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':libs:ViewPagerIndicator')
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.google.android.gms:play-services-maps:9.0.0'
compile 'com.google.android.gms:play-services-location:9.0.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.2.0'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.google.firebase:firebase-messaging:9.0.0'
}
apply plugin: 'com.google.gms.google-services'

我的活动,其中包含此

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.splashactivity);
    alert = (LinearLayout)findViewById(R.id.alert);
    mGoogleApiAvailability = GoogleApiAvailability.getInstance();
    try {
        int status = mGoogleApiAvailability.isGooglePlayServicesAvailable(getApplicationContext());
        if (status != ConnectionResult.SUCCESS) {
            if(mGoogleApiAvailability.isUserResolvableError(status)) {
                mGoogleApiAvailability.getErrorDialog(this, status,0
                        , new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                AlertDialog.Builder builder = new AlertDialog.Builder(SplashActivity.this);
                                builder.setMessage("Are you want to update ?")
                                        .setTitle("Google play service Out of date.Google play services need to be Updated, tou are unable to use this app without updating your google services.")
                                        .setNegativeButton("No", new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                dialog.cancel();
                                                finish();
                                            }
                                        })
                                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                dialog.cancel();
                                                Intent termcondlink = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.google.android.gms&hl=en"));
                                                startActivity(termcondlink);
                                            }
                                        }).show();
                            }
                        }).show();
            }
        }
    } catch (Exception e){
        Log.d("error",e.toString());
    }
    mSharedPreferences = getSharedPreferences(SharedPrefUtil.PREFERENCES,MODE_PRIVATE);
    final Context context = this ;
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Log.d("run","after 2 sec");
            if ( UtilFunctions.isNetworkAvailable(context)){
                isNetworkActive();
            }
            else {
                if (!UtilFunctions.isNetworkAvailable(context)){
                    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
                    LayoutInflater layoutInflater = LayoutInflater.from(context);
                    View view = layoutInflater.inflate(R.layout.disconnected_network, null);
                    builder.setView(view);
                    Button Tryagain = (Button)view.findViewById(R.id.tryagain);
                    builder.setCancelable(false);
                    final Dialog dialog = builder.create();
                    dialog.show();
                    Tryagain.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            dialog.cancel();
                            if (!UtilFunctions.isNetworkAvailable(context)){
                                dialog.show();
                            } else {
                                isNetworkActive();
                            }
                        }
                    });
                }
            }
        }
    }, SPLASH_TIME_OUT);
}

0 个答案:

没有答案