Android Error: SDK23 v SDK19 - java.lang.NoClassDefFoundError: com.google.android.gms.R$string
Android Error: SDK23 v SDK19 - java.lang.NoClassDefFoundError: com.google.android.gms.R$string
我的 Android 应用程序使用 Google 映射并为 SDK23 和 SDK19 设备编译得很好。它 运行 在 SDK23 (LG G4) 上没问题,但生成此错误 SDK19 设备 (Samsung Galaxy 4) => java.lang.NoClassDefFoundError:com.google.android.gms.R$string
这些是我的依赖项:
Android Studio Dependencies
我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.volkerpetersen.sailingrace">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"></uses-feature>
<application
android:name=".GlobalParameters"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".start_timerActivity"
android:label="@string/title_activity_start_timer"
android:parentActivityName=".MainActivity"
android:windowSoftInputMode="stateHidden"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.volkerpetersen.sailingrace.MainActivity" />
</activity>
<activity
android:name=".start_raceActivity"
android:label="@string/title_activity_start_race"
android:parentActivityName=".MainActivity"
android:theme="@android:style/Theme.Holo.NoActionBar" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.volkerpetersen.sailingrace.MainActivity" />
</activity>
<activity
android:name=".start_mapActivity"
android:label="@string/title_activity_start_map"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.volkerpetersen.sailingrace.MainActivity" />
</activity>
<activity
android:name=".SailingRacePreferences"
android:screenOrientation="portrait"
android:label="@string/title_activity_setting"
android:noHistory="true"
android:parentActivityName=".MainActivity"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.volkerpetersen.sailingrace.MainActivity" />
</activity>
<receiver android:name=".SailTimerAPI"></receiver>
<!--
The API key for Google Maps-based APIs is defined as a string resource using the <meta-data> tag
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDzCAa-hibdRJ-NdOnIRK-IG5uN2U3kv9c" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- original code replaced with above
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
-->
</application>
当我搜索此错误时,我找不到 solution/answer 为什么我的应用程序 compiles/runs 在 SDK23 下正常,但在 SDK19 下生成此 运行-time 错误。
任何帮助将不胜感激!
请尝试清理您的项目,然后从您的应用程序中删除 Gradle 最后两个依赖项:play-services gcm 和 identities
终于解决了这个问题
我需要将清单从
编译 'com.google.android.gms:play-services:8.4.0'
到旧版本
编译 'com.google.android.gms:play-services:8.3.0' 以确保与两台设备上的设备软件兼容。
应用程序现在可以在 SDK19 和 SDK23 上运行 phone。感谢 Mounir 为我指明了正确的方向。非常感谢!
我的 Android 应用程序使用 Google 映射并为 SDK23 和 SDK19 设备编译得很好。它 运行 在 SDK23 (LG G4) 上没问题,但生成此错误 SDK19 设备 (Samsung Galaxy 4) => java.lang.NoClassDefFoundError:com.google.android.gms.R$string
这些是我的依赖项: Android Studio Dependencies
我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.volkerpetersen.sailingrace">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"></uses-feature>
<application
android:name=".GlobalParameters"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".start_timerActivity"
android:label="@string/title_activity_start_timer"
android:parentActivityName=".MainActivity"
android:windowSoftInputMode="stateHidden"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.volkerpetersen.sailingrace.MainActivity" />
</activity>
<activity
android:name=".start_raceActivity"
android:label="@string/title_activity_start_race"
android:parentActivityName=".MainActivity"
android:theme="@android:style/Theme.Holo.NoActionBar" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.volkerpetersen.sailingrace.MainActivity" />
</activity>
<activity
android:name=".start_mapActivity"
android:label="@string/title_activity_start_map"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.volkerpetersen.sailingrace.MainActivity" />
</activity>
<activity
android:name=".SailingRacePreferences"
android:screenOrientation="portrait"
android:label="@string/title_activity_setting"
android:noHistory="true"
android:parentActivityName=".MainActivity"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.volkerpetersen.sailingrace.MainActivity" />
</activity>
<receiver android:name=".SailTimerAPI"></receiver>
<!--
The API key for Google Maps-based APIs is defined as a string resource using the <meta-data> tag
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDzCAa-hibdRJ-NdOnIRK-IG5uN2U3kv9c" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- original code replaced with above
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
-->
</application>
当我搜索此错误时,我找不到 solution/answer 为什么我的应用程序 compiles/runs 在 SDK23 下正常,但在 SDK19 下生成此 运行-time 错误。
任何帮助将不胜感激!
请尝试清理您的项目,然后从您的应用程序中删除 Gradle 最后两个依赖项:play-services gcm 和 identities
终于解决了这个问题
我需要将清单从 编译 'com.google.android.gms:play-services:8.4.0' 到旧版本 编译 'com.google.android.gms:play-services:8.3.0' 以确保与两台设备上的设备软件兼容。
应用程序现在可以在 SDK19 和 SDK23 上运行 phone。感谢 Mounir 为我指明了正确的方向。非常感谢!