Google Map API v2 inflator fails on old phones - android

I have just implemented a map in the application, and it runs flawlessly in a Galaxy S3. Testing my app with an old phone HTC Sense with API8 the app throws a inflator problem. I think it may be related to either the OS or OGL2. isGooglePlayServicesAvailable(this) returns a correct value. Help me here, please:
Activity.java
public class MyActivity extends Activity
{
#Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.initializeInterface();
}
private void initializeInterface() {
final int available = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
this.setContentView(R.layout.main);
}
}
main.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
class="com.google.android.gms.maps.MapFragment"
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/footer"
android:layout_below="#id/header" />
manifest.xml
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.stuff.permission.MAPS_RECEIVE" />
<permission
android:name="com.stuff.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:icon="#drawable/icon"
android:label="#string/application_name" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/map_api_key_device"/>
<activity
android:name=".MyActivity"
android:configChanges="orientation"
android:launchMode="singleTop"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Error
12-13 12:14:13.865: E/My ERROR(22878): Binary XML file line #85: Error inflating class fragment
12-13 12:14:13.875: E/android.view.LayoutInflater.createViewFromTag(22878): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
12-13 12:14:13.895: E/android.view.LayoutInflater.rInflate(22878): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
12-13 12:14:13.915: E/android.view.LayoutInflater.inflate(22878): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
12-13 12:14:13.915: E/android.view.LayoutInflater.inflate(22878): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-13 12:14:13.935: E/android.view.LayoutInflater.inflate(22878): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-13 12:14:13.945: E/com.android.internal.policy.impl.PhoneWindow.setContentView(22878): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
12-13 12:14:13.945: E/android.app.Activity.setContentView(22878): at android.app.Activity.setContentView(Activity.java:1654)

It has to do with the fact that you are trying to use native API Level 11 fragments on an API Level 8 device. Switch to FragmentActivity and SupportMapFragment if you wish to have your code work on earlier versions than Android 3.0.

I solved this problem by adding the v13 libraries from /extras/android/compatibility/v13 and changing my Activity to FragmentActivity and MapFragment to SupportMapFragment.

for me help app project -> right click -> properties -> android -> project build target -> and chack earlier android release. (with google api)
if you dont have, download one by SDK manager

Related

I'm getting error when running my app using android 4.4 and 8.1 (api level 19 & 27) on tablets/mobile phones

This ClassNotFound exception came when I run it on android 4.4 devices, I wonder how did it happen, because I have already registered all of my activities under my manifest file, but still this error is occurring again and it makes me confused.
Please can anyone suggest me what is wrong with my code:
Here is error :
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.Forewarn.ForewarnApp.activities.Splash Activity" on path: DexPathList[[zip file "/data/app/com.Forewarn.ForewarnApp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.Forewarn.ForewarnApp-2, /system/lib]]
Here is manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.Forewarn.ForewarnApp">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission
android:name="android.permission.MODIFY_PHONE_STATE"
tools:ignore="ProtectedPermissions" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<configuration>
<release>
true
</release>
</configuration>
<permission
android:name="com.Forewarn.ForewarnApp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.Forewarn.ForewarnApp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:name=".activities.SoteriaApplication"
android:allowBackup="false"
android:icon="#drawable/ic_launcherr"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".activities.SplashActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name=".activities.SignInActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.SignUpActivity" />
<activity android:name=".activities.ForgotPasswordActivity" />
<activity android:name=".activities.SerachResultsActivity" />
<activity android:name=".activities.DetailsPageActivity" />
<activity android:name=".activities.PropertyDetailsActivity" />
<activity android:name=".activities.BankurptsDetailsActivity" />
<activity android:name=".activities.SampleActivity" />
<activity android:name=".activities.ActivityCallLog" />
<activity android:name=".activities.SettingsActivity" />
<activity android:name=".activities.VehicleDetailsActivity" />
<activity android:name=".activities.ResultsActivity" />
<activity android:name=".activities.OthersActivity" />
<activity android:name=".activities.NoRecordsActivity" />
<activity android:name=".activities.MoreRecordsActivity" />
<activity
android:name=".activities.CriminalDetailsActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.CriminalSampleActivity" />
<activity
android:name=".activities.OtpActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.AddressesDetailsActivity" />
<activity
android:name=".activities.PhonesHistoryDetailsActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.ContactsReaderActivity" />
<activity
android:name=".activities.FingerprintTermsAndConditionsActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.ChangePasswordActivity" />
<activity
android:name=".activities.TermsandConditionsActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".activities.PdfPasswordActivity"></activity>
</application>
</manifest>
and btw i put my minsdkversion = 19
maxsdkversion = 27
and error getting app crashed on android 8.1.0 (api level 27) devices also.
here is my application class code :
public class SoteriaApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
AccountUtils.assignContext(this);
MultiDex.install(this);
}
}
btw i tried with instant run disabling method: now i get verify error : like this :
FATAL EXCEPTION: main
Process: com.Forewarn.ForewarnApp, PID: 1060
java.lang.VerifyError: com/Forewarn/ForewarnApp/activities/SignInActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Sound Like a Multidex issue. In your Application Class activities.SoteriaApplication Add this
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
app.gradle
android {
defaultConfig {
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
Enable Multidex in Gradle too
NB : Use android:name=".activities.SoteriaApplication" only if This is Your Custom Appplication Class
Also Try Clean And Rebuild the Project and Run Application without Instant Run. Check Whether problem is resolved
Do one thing-:
Go to File on top menu->Setting->Build Execution->Instant run->If its enabled then try disabling that.
Update2(After reading your updated question and error log)
I have seen that you have verifier log , so let me describe it hope that you can get some clue. Here is this discussion in detail.
This error indicates that the verifier, included in the Java Virtual Machine (JVM), detected a class file that despite well formed, it contains some type of internal inconsistency or faces a security problem.
The VerifyError class extends the LinkageError class, which is used to
indicate those error cases, where a class has a dependency on some
other class and that class has incompatibly changed after the
compilation. Furthermore, the LinkageError class extends the Error
class, which is used to indicate those serious problems that an
application should not catch. A method may not declare such errors in
its throw clause, because these errors are abnormal conditions that
shall never occur.
Finally, the VerifyError exists since the 1.0 version of Java.
For me this could be your case. Consider this SO question and check your dependencies. Clean your project. or even restart your system. I do believe it is not cleaning your project rightly.
Update1
I have the same problem. How I solved it is by adding following line in build.gradle file dependencies.
compile 'com.android.support:multidex:1.0.2'
then in my Application class i extend it with "extends MultiDexApplication" I made sure to add this in onCreate method . like
public class SoteriaApplication extends MultiDexApplication {
//Please extend your application class with MultiDexApplication
#Override
public void onCreate() {
super.onCreate();
AccountUtils.assignContext(this);
MultiDex.install(this);
}}
Please extend you application class with MultiDexApplication class.
If you have done the MultiDex work mentioned by #A.s.ALI and #Tomin B Azhakathu and still have the ClassNotFoundException. Then you should look up if the com.Forewarn.ForewarnApp.activities.SplashActivity is in the main dex(You can drag your apk just in the Android Studio and confirm it). If com.Forewarn.ForewarnApp.activities.SplashActivity is in the main dex, and still throw the exception just let me know, thx.

google map version 2 does not work with fragment

I do not know, what i am doing wrong in either my manifest, activity or xml to load map version 2,
i found multiple exceptions if you see my concise logcat,
E/AndroidRuntime(16522): FATAL EXCEPTION: main
E/AndroidRuntime(16522): java.lang.RuntimeException: Unable to start activityComponentInfo{com.production.MyApp/com.project.MyApp.AddEvent.AddEventMapActivity}:
android.view.InflateException: Binary XML file line #7: Error inflating class fragment
E/AndroidRuntime(16522): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
E/AndroidRuntime(16522): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
E/AndroidRuntime(16522): at android.app.Activity.setContentView(Activity.java:1892)
E/AndroidRuntime(16522): at com.project.MyApp.AddEvent.AddEventMapActivity.onCreate(AddEventMapActivity.java:20)
E/AndroidRuntime(16522): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
E/AndroidRuntime(16522): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
E/AndroidRuntime(16522): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
E/AndroidRuntime(16522): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
E/AndroidRuntime(16522): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
while manifest looks like,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.production.MyApp"
android:versionCode="3"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<permission
android:name=" com.production.MyApp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name=" com.production.MyApp.permission.MAPS_RECEIVE" />
<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.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:name="com.project.MyApp.MyApplication"
android:enabled="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="no issue with api_key here" />
and xml,
<?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:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
while i am extending FragmentActivity,
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_layout);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
You need to add the below to manifest file
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Place this at the end of your manifest, after your Map API key meta-data tag.
Check out HERE
It's a new requirement added from the last revision 13 update to google-play-services.
You need to add the following in your manifest
...
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
This information can be found in the logcat error msg.
And also on google play services website

Error Fatal Exception: main & Inflating Class Fragment

I am following this tutorial , i used the original files provided in the tutorial but facing same problem.searched for many pre asked questions but could not find way to repair my error.I m having error of "Unfortunately app has stopped" I got errors in logcat as follow.
Logcat of my project
11-30 17:35:36.852: E/Trace(836): error opening trace file: No such file or directory (2)
11-30 17:35:37.432: D/AndroidRuntime(836): Shutting down VM
11-30 17:35:37.432: W/dalvikvm(836): threadid=1: thread exiting with uncaught exception
(group=0x40a13300)
11-30 17:35:37.452: E/AndroidRuntime(836): FATAL EXCEPTION: main
11-30 17:35:37.452: E/AndroidRuntime(836): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gmap/com.example.gmap.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class fragment
.java file as follows
public class MainActivity extends FragmentActivity
implements OnMapClickListener {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
mMap.setOnMapClickListener(this);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public void onMapClick(LatLng position) {
mMap.addMarker(new MarkerOptions()
.position(position)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));
}
}
Manifest file as follow
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gmap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<!-- You must insert your own Google Maps for Android API v2 key in here. -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="I inserted key obtained" />
<activity
android:name="com.example.gmap.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Your Java code seems to be correct. Try to remove the implements onClickListener and onClick method just for a try. Your manifest needs some changing. I suggest adding these elements:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.nurakanbpo.mygenie.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.nurakanbpo.mygenie.MAPS_RECEIVE" />
Your minSdkVersion is 13 for which you dont need supportmapfragment. You can use mapfragment.
Also since revision 13 of google play services was released you need to add this element to your you application tag:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />

Google Play Service library and Google Maps

I try to create a simple GoogleMap by Using Google Play Service and Google Maps API. But all the times I get errors...
I´m working with IntelliJ 12.1, here my full Code:
RecorderMap.java
package com.example.GPSApp;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class RecorderMap extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
}
}
map.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.maps.SupportMapFragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.GPSApp"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="16" />
<permission
android:name="com.example.GPSApp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application android:label="#string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".RecorderMap"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="XXX" />
</application>
</manifest>
I think the Problem is how I include the GooGlePlayService... I´ve tried to add as module, as libary as External Libary but I don't know how to include and to use it right... :(
EDIT:
LogCat
08-28 07:41:59.869: ERROR/AndroidRuntime(23080): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.GPSApp/com.example.GPSApp.RecorderMap}: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.gms.maps.SupportMapFragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.gms.maps.SupportMapFragment
at android.view.LayoutInflater.createView(LayoutInflater.java:508)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:210)
at android.app.Activity.setContentView(Activity.java:1660)
at com.example.GPSApp.RecorderMap.onCreate(RecorderMap.java:18)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
... 11 more
Caused by: java.lang.NoSuchMethodException: SupportMapFragment(Context,AttributeSet)
at java.lang.Class.getMatchingConstructor(Class.java:643)
at java.lang.Class.getConstructor(Class.java:472)
at android.view.LayoutInflater.createView(LayoutInflater.java:480)
... 20 more
****EDIT2**
Problem solved by using this: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable**
The only thing I find missing in your RecorderMap.java file is that you haven't imported the SupportFragment class. So add this line to it
import com.google.android.gms.maps.SupportMapFragment;
If that doesn't work, then check out the following.
From what you are saying, it means you have already installed the google play services. If not, then try installing it using this link http://developer.android.com/google/play-services/setup.html
After that, referencing the google play services library should be as easy as editing your build.gradle file. The current version of android studio makes this possible. Under dependencies in your build.gradle file, add the following code
compile 'com.google.android.gms:play-services:3.1.36'
You seem to have your API key intact.
Finally, remember you need to test your app on an actual android device and not an emulator. The android API version 2 is not yet able to display maps on emulators.
I think this should be okay for your app to work.

while using Google Maps Android API v2 got error Signature not valid. Found:

I'm creating sample application to use Google Maps Android API v2.
I tried on Samsung Galaxy Ace GT-S5830i, but instead of Map, I'm seeing
And logcat is
Signature not valid. Found:
MIIDDTCCAfWgAwIBAgIEEhX+gTANBgkqhkiG9w0BAQsFADA3MQswCQYDVQQGEwJVUzEQMA4GA1UE
ChMHQW5kcm9pZDEWMBQGA1UEAxMNQW5kcm9pZCBEZWJ1ZzAeFw0xMzAyMjUxMTEwNDRaFw00MzAy
MTgxMTEwNDRaMDcxCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdBbmRyb2lkMRYwFAYDVQQDEw1BbmRy
b2lkIERlYnVnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApqChoDnHsDfsxa7n2Kv9
2av0G0tm+kS1uP4T6fA8cO6jB3qB5EHFR6+5UO+k4laHW2WzOJbyhhtFE5eOTS4Zt5qo4FX/hsc/
Zi7dDX/Y13b+4qajhLoGYqVjM00eQc2qF58TTnbQ3lTERxaofYL2qI3j2KcVODFMksinL9lt3RTD
V3MXy7KDLcuSvoVZxXn1L0O9rkTbZicmleK4wLDzI+lTpuXngAuQ4MBH1wEWwqMhJg6/J06t5axU
ea2UVv7ZtYg8KPMEiQEApCbdAHtQsmqcsEQZtJAqFtj7KEQ7wTSgnpDRix4N5C9QlwUtKSlOCIlk
ueUPVBypKf/SWIgF6QIDAQABoyEwHzAdBgNVHQ4EFgQURyMuspjlLaDj8LhEb5UyYqQgWQYwDQYJ
KoZIhvcNAQELBQADggEBAA9IXLEAQTD+VEt9l8JQDEOFv8WqIdQisvmJCfJjN98faarvf6RRA+v3
HF2VFlZPaUu/HBeOH8MI7u+gNuRtZGYWn1eC/qfP0W31MQoNaN4ocsF+tL9INzpd89/u6Ya5Kove
r0E0tpJFBgdtDPYcPBjQ6tYAqmhnmPIJftGHLNQbil4ocK/PkqgxGlwQN7WrCNjDewb0twz7hZBx
Ig4OsnfdgPTYGlR+LyTzUd9/KyqaLHivRAI+y/xGDz6lOfGH7bDOPi/hDm0bkhC1y1J7L9+FiGWb
dmi+Co9Jlf1f3vyTtD7kr3h0K0C3MsNWtybVqmVvgImoLt/lPbjNJahVrds=
Google Play services signature invalid.
Can't open keycharmap file
Error loading keycharmap file
Using default keymap
My manifest code
<?xml version="1.0" encoding="utf-8"?>
<permission
android:name="com.example.testmap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.testmap.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.example.testmap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDTsWrO0j24sbp4E5qhoHhd6nyOQM5lErc" />
<activity
android:name="com.example.testmap.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
my xml file code
<?xml version="1.0" encoding="utf-8"?>
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
My activity code
package com.example.testmap;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.final_main);
GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
//map.getMinZoomLevel();
}
}
And clicking on ok button gives force close with Logcat
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1374)
at android.app.Activity.startActivityForResult(Activity.java:2827)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
at android.app.Activity.startActivity(Activity.java:2933)
at com.google.android.gms.internal.e$2.onClick(Unknown Source)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Also when I UN-comment last line map.getMinZoomLevel(); , I get null pointer exception on the line.
Check if you have enabled offline work for gradle: Goto File > Settings > Gradle
Deselect Offline Work if its checked.
Then confirm if you have latest version of google services mentioned as dependencies in project level build.gradle:
classpath 'com.google.gms:google-services:2.1.0'
You can find latest version here: https://jcenter.bintray.com/com/android/tools/build/gradle/
Clean and build the project after gradle sync completes.
ouThese steps solved a similar issue I'd with Google Maps and also solved the first error you mentioned Signature Not Valid
If your device runs on Android M, you may want to verify your code for location access following this answer.
I was also getting same exception and I fixed it.
Note: I am working on google analytics and was getting this exception. But my app was not crashing I was getting this in Logs. you can also try this solution.
add this in project level gradle file.
classpath 'com.google.gms:google-services:2.1.0'
and this one for module level gradle file.
compile 'com.google.android.gms:play-services:8.4.0'
and move `below plugin at the end of file (at last line) of module level gradle file.
apply plugin: 'com.google.gms.google-services'

Categories

Resources