After Google Play Service update to version 13 I got an error

后端 未结 8 1248
小蘑菇
小蘑菇 2020-11-22 06:02

How can I resolve this error?

Caused by: java.lang.illegalargumentexception 11-01 11:08:12.845: E/AndroidRuntime(28885): Caused by: java.lang.Illega

相关标签:
8条回答
  • 2020-11-22 06:23

    I imported my existing project from Eclipse to Android Studio, In Eclipse project Integers.xml was containing hardcoded value as following

    <integer name="google_play_services_version">5089000</integer>
    

    causing version conflict with latest version of Play Services being built by Android Studio. after removing this line from Integers.xml it started working for me.

    0 讨论(0)
  • 2020-11-22 06:25

    Just make sure to add the below two meta-data tags to 'your' application's AndroidManifest.xml

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

    This solution worked for me.

    0 讨论(0)
  • 2020-11-22 06:40

    You need to add the following in your manifest:

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

    EDIT:

    This information can be found in the logcat error msg as well as on Setting Up Google Play Services (Thanks Brais Gabin)

    0 讨论(0)
  • 2020-11-22 06:41

    @Benoit'a answer has exact solution i am answering with additional knowledge:

    1. one way as Benoit answered is add following inside application tag of AndroidManifest.xml

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

    2. we can directly add the version code like

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

    4030500 is version code which is stored inside

    google-play-services_lib>res>values>version.xml

    Like

    <integer name="google_play_services_version">4030500</integer>
    

    Conclusion: Latest google play services requires a version name, which is to be mentioned using <meta-data .. /> inside AndroidManifest.xml

    Note: I would strongly recommend to use 1st way

    0 讨论(0)
  • 2020-11-22 06:41

    A few things changed since you asked that question. If you're using Google Play services 7.0 or newer, Gradle will automatically merge manifests and include the required meta-data for you.

    Citing Ian Lake:

    (...) Google Play services 7.0 also has one other time saving feature if you're using Gradle: it automatically includes the

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

    entry in your AndroidManifest.xml for you - no need to manually add it! Perfect example of simple Manifest merging where libraries can add required meta-data, receivers, permissions, and anything else they made need - one less thing to forget!

    Note: this does not apply to the full play-services or play-services-all-wear AARs - only the granular AARs have this built in.

    0 讨论(0)
  • 2020-11-22 06:42

    Add <meta-data>after closing <application> tag. This solved my problem

    0 讨论(0)
提交回复
热议问题