I have got this error
NoClassDefFoundError: com.google.android.gms.R$styleable
I read a lot of tutorials, but it did not help me.
My xml file :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
My Activity is:
public class FlatOnMap extends Activity {
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
try {
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
@Override
protected void onResume() {
super.onResume();
initilizeMap();
}
}
My Manifest is:
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17"/>
<permission
android:name="ua.khuta.ALHANAi.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="ua.khuta.ALHANAi.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
>
<activity android:name=".MyActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
android:screenOrientation="portrait"
>
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchResultsActivity"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SearchResultsActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
>
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
<activity android:name=".FlatInfo"/>
<activity android:name=".FlatOnMap"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="myApiKey"/>
</application>
</manifest>
My Solution: I have uppdated my google play servises, and import it again, but i does not add .jar file. 1. Import Module -> google_play_servises_lib project 2. + Add library -> google_play_servises_lib
I see some potential issues:
com.google.android.gms.R
somewhere in your
code and not the one that belongs to your app.<permission>
on your manifest is obsolete; not needed anymore.<uses-permission android:name="ua.khuta.ALHANAi.permission.MAPS_RECEIVE"/>
is obsoleteYou are missing this inside your <application>
:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
You have declared an Activity
(MyActivity
) as a MAIN
and LAUNCHER
twice in your AndroidManifest
; remove one of the <intent-filter>...</intent-filter>
:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>