4 votes

Obtenir l'exception avec google play services (Google Places API Android) avec 10.2.0

J'utilise les services google play de l'api google places. Lorsque j'ai mis à jour google play services 10.0.1 à 10.2.0 dans le fichier build.gradle, j'ai obtenu l'exception suivante à la ligne :-.

mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
            .enableAutoManage(getActivity(), this)
            .addApi(Places.GEO_DATA_API)
            .build();

Et avec la version 10.0.1, cela ne fonctionne pas non plus.

Exception :-

java.lang.NoSuchFieldError: No static field GOOGLE_PLAY_SERVICES_VERSION_CODE of type I in class Lcom/google/android/gms/common/zzc; or its superclasses (declaration of 'com.google.android.gms.common.zzc' appears in /data/app/com.xyz.app-1/base.apk)
    at com.google.android.gms.common.GoogleApiAvailability.<clinit>(Unknown Source)
    at com.google.android.gms.common.api.GoogleApiClient$Builder.<init>(Unknown Source)
    at com.techmobia.fourmoles.ui.bookteetime.BookTimeFragment.onCreate(BookTeeTimeFragment.java:102)
    at android.support.v4.app.Fragment.performCreate(Fragment.java:2177)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1244)
    at android.support.v4.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1080)
    at android.support.v4.app.FragmentTransition.calculateFragments(FragmentTransition.java:971)
    at android.support.v4.app.FragmentTransition.startTransitions(FragmentTransition.java:95)
    at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2143)
    at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
    at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1979)
    at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:626)
    at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
    at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
    at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
    at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
    at android.view.View.measure(View.java:18809)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
    at android.view.View.measure(View.java:18809)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
    at android.view.View.measure(View.java:18809)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
    at android.view.View.measure(View.java:18809)
    at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1081)
    at android.view.View.measure(View.java:18809)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
    at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
    at android.view.View.measure(View.java:18809)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
    at android.view.View.measure(View.java:18809)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
    at android.view.View.measure(View.java:18809)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
    at android.view.View.measure(View.java:18809)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
    at com.android.internal.policy.PhoneWindow$DecorView.onMe

2voto

Rajat Sharma Points 761

J'ai résolu le problème après avoir nettoyé et construit le projet.

0voto

Dima Rostopira Points 3183

Essayez d'ajouter ce qui suit meta-data à l'intérieur de application dans votre AndroidManifest.xml

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

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X