I have issues as I was following this tutorial https://www.youtube.com/watch?v=vQ__ECAEAS0 , how to implement Google maps v2 in android project, I did exactly like in tutorial just in new activity and then i try to open new activity , The application is crashing each time: Sorry new to android...
Creating new activity:
public void openMap(View view) {
Intent intent = new Intent(this, MapMain.class);
startActivity(intent);
}
XML:
<Button
android:id="#+id/bMapas"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_above="#+id/buttonSettings"
android:layout_toLeftOf="#+id/textpowererdBy"
android:background="#drawable/st_nohow_b"
android:onClick="openMap"
android:text="#string/map" />
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nl.test.app"
android:versionCode="1"
android:versionName="1.0" >
<permission android:name="nl.test.app.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<uses-permission android:name="nl.test.app.permission.MAPS_RECEIVE" />
<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" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainMenu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MapMain"
android:label="#string/title_activity_map_main" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAnNGd2_lI-3-wS0XR06czsjDQNTAATQXF" />
</application>
</manifest>
LogCat
08-12 13:31:25.536: E/AndroidRuntime(440): FATAL EXCEPTION: main
08-12 13:31:25.536: E/AndroidRuntime(440): java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.test.app/nl.test.app.MapMain}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.ActivityThread.access$500(ActivityThread.java:122)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.os.Looper.loop(Looper.java:132)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.ActivityThread.main(ActivityThread.java:4123)
08-12 13:31:25.536: E/AndroidRuntime(440): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 13:31:25.536: E/AndroidRuntime(440): at java.lang.reflect.Method.invoke(Method.java:491)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-12 13:31:25.536: E/AndroidRuntime(440): at dalvik.system.NativeStart.main(Native Method)
08-12 13:31:25.536: E/AndroidRuntime(440): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
08-12 13:31:25.536: E/AndroidRuntime(440): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:688)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:223)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.Activity.setContentView(Activity.java:1786)
08-12 13:31:25.536: E/AndroidRuntime(440): at nl.test.app.MapMain.onCreate(MapMain.java:16)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.Activity.performCreate(Activity.java:4397)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
08-12 13:31:25.536: E/AndroidRuntime(440): ... 11 more
08-12 13:31:25.536: E/AndroidRuntime(440): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 5089000 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" />
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.maps.internal.u.I(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.maps.internal.u.H(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.maps.SupportMapFragment$b.jz(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.dynamic.a.a(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
08-12 13:31:25.536: E/AndroidRuntime(440): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:660)
08-12 13:31:25.536: E/AndroidRuntime(440): ... 21 more
One thing I notice imidatly is that you don't have this part in you Manifest file:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Google Maps API V2 will not run without this meta-data section in your Manifest file.
If this is not working still after making this change, try to go over this blog post I wrote on this topic:
Google Maps API V2 Guide
You can as well go over this tutorial to make sure you are getting the key and setting up the API Console the right way:
Google Maps API V2 Key Guide
Related
I want to start the navigation drawer activity when pressing a button.
Here's my code:-
public void logdinScreen(View view) {
codeM = (EditText)findViewById(R.id.editText2);
if(codeM.getText().toString().equals("0000"))
{
//Toast.makeText(getBaseContext(),"LogedIn",Toast.LENGTH_LONG).show();
Intent intent2 = new Intent(OTPScreen.this,HomeScreen.class);
startActivity(intent2);
}
}
Android Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.harpreet.btp_project" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
<activity
android:name=".OTPScreen"
android:label="#string/title_activity_otpscreen" >
</activity>
<activity
android:name=".HomeScreen"
android:label="#string/title_activity_home_screen" >
</activity>
</application>
</manifest>
logcat:-
05-23 01:08:23.999 3326-3326/? D/dalvikvm﹕ Late-enabling CheckJNI
05-23 01:08:24.059 3326-3326/? E/Trace﹕ error opening trace file: No such file or directory (2)
05-23 01:08:24.059 3326-3326/? D/ActivityThread﹕ setTargetHeapUtilization:0.25
05-23 01:08:24.059 3326-3326/? D/ActivityThread﹕ setTargetHeapIdealFree:8388608
05-23 01:08:24.059 3326-3326/com.example.harpreet.btp_project D/ActivityThread﹕ setTargetHeapConcurrentStart:2097152
05-23 01:08:24.239 3326-3326/com.example.harpreet.btp_project D/dalvikvm﹕ GC_FOR_ALLOC freed 70K, 35% free 12967K/19779K, paused 21ms, total 22ms
05-23 01:08:24.259 3326-3326/com.example.harpreet.btp_project I/dalvikvm-heap﹕ Grow heap (frag case) to 29.330MB for 8294416-byte allocation
05-23 01:08:24.289 3326-3328/com.example.harpreet.btp_project D/dalvikvm﹕ GC_CONCURRENT freed 1K, 25% free 21066K/27911K, paused 12ms+1ms, total 35ms
05-23 01:08:24.429 3326-3326/com.example.harpreet.btp_project D/libEGL﹕ loaded /system/lib/egl/libEGL_adreno200.so
05-23 01:08:24.449 3326-3326/com.example.harpreet.btp_project D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_adreno200.so
05-23 01:08:24.459 3326-3326/com.example.harpreet.btp_project D/libEGL﹕ loaded /system/lib/egl/libGLESv2_adreno200.so
05-23 01:08:24.469 3326-3326/com.example.harpreet.btp_project I/Adreno200-EGL﹕ <qeglDrvAPI_eglInitialize:299>: EGL 1.4 QUALCOMM build: (Merge)
Build Date: 07/09/13 Tue
Local Branch: AU_41
Remote Branch:
Local Patches:
Reconstruct Branch:
05-23 01:08:24.529 3326-3326/com.example.harpreet.btp_project D/OpenGLRenderer﹕ Enabling debug mode 0
05-23 01:08:39.009 3326-3326/com.example.harpreet.btp_project D/AndroidRuntime﹕ Shutting down VM
05-23 01:08:39.009 3326-3326/com.example.harpreet.btp_project W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x413e2378)
05-23 01:08:39.029 3326-3326/com.example.harpreet.btp_project E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.harpreet.btp_project/com.example.harpreet.btp_project.HomeScreen}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4787)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.harpreet.btp_project.HomeScreen.onCreate(HomeScreen.java:39)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4787)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.harpreet.btp_project.NavigationDrawerFragment.onCreateView(NavigationDrawerFragment.java:100)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:924)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1116)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1218)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2170)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.callActivityOnCreateView(AppCompatDelegateImplV7.java:816)
at android.support.v7.app.AppCompatDelegateImplV11.callActivityOnCreateView(AppCompatDelegateImplV11.java:72)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:804)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.harpreet.btp_project.HomeScreen.onCreate(HomeScreen.java:39)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4787)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
The app is working untill i press that button. When i comment the intent part and uncomment the Toast part, it is working perfect.
Am i doing it wrong?
Good evening and good week. We run this script from tutorial but my crash concept does not make an error in the code. nor to the errors refer to a particular line code. Please for your help.
Tutorial: http://gabesechansoftware.com/location-tracking/
01-26 15:36:06.751: I/Process(10528): Sending signal. PID: 10528 SIG: 9
01-26 15:36:18.251: D/AndroidRuntime(10613): Shutting down VM
01-26 15:36:18.251: W/dalvikvm(10613): threadid=1: thread exiting with uncaught exception (group=0x2b542210)
01-26 15:36:18.251: E/AndroidRuntime(10613): FATAL EXCEPTION: main
01-26 15:36:18.251: E/AndroidRuntime(10613): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{pack/pack.MainActivity}: java.lang.ClassNotFoundException: pack.MainActivity
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1891)
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.app.ActivityThread.access$600(ActivityThread.java:127)
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.os.Handler.dispatchMessage(Handler.java:99)
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.os.Looper.loop(Looper.java:137)
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.app.ActivityThread.main(ActivityThread.java:4441)
01-26 15:36:18.251: E/AndroidRuntime(10613): at java.lang.reflect.Method.invokeNative(Native Method)
01-26 15:36:18.251: E/AndroidRuntime(10613): at java.lang.reflect.Method.invoke(Method.java:511)
01-26 15:36:18.251: E/AndroidRuntime(10613): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-26 15:36:18.251: E/AndroidRuntime(10613): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-26 15:36:18.251: E/AndroidRuntime(10613): at dalvik.system.NativeStart.main(Native Method)
01-26 15:36:18.251: E/AndroidRuntime(10613): Caused by: java.lang.ClassNotFoundException: pack.MainActivity
01-26 15:36:18.251: E/AndroidRuntime(10613): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-26 15:36:18.251: E/AndroidRuntime(10613): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-26 15:36:18.251: E/AndroidRuntime(10613): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-26 15:36:18.251: E/AndroidRuntime(10613): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
01-26 15:36:18.251: E/AndroidRuntime(10613): ... 11 more
01-26 15:41:18.281: I/Process(10613): Sending signal. PID: 10613 SIG: 9
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.pack"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="24" />
<permission
android:name="my.pack.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="my.pack.permission.MAPS_RECEIVE"/>
<uses-permission android:name="permission_name"/>
<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="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<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" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="My api key"/>
<activity
android:name=".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>
You full activity name (package + class) is not the same in manifest and code. There's pack.MainActivity declared in manifest but it is not found in code.
I am trying to run Google maps API v2 on emulator. It says "unfortunately app has stoped" Here is my manifest.xml code. There is a huge number of errors. In the first line it gives error to define android.allowBackup which I have done on application tag.Please help me solve them.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<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="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permissionandroid:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
<!-- <meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" /> -->
<activity
android:name="com.myapp.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="My key"/>
</application>
</manifest>
----------------------------------------------------------------------------------------------
MainActivity.java
package myapp;
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 {
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
map = mapFrag.getMap();
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
}
------------------------------------------------------------------------------------
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
-----------------------------------------------------------------
Logcat
E/Trace(690): error opening trace file: No such file or directory (2)
E/AndroidRuntime(690): FATAL EXCEPTION: main
E/AndroidRuntime(690): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{myapp/myapp.MainActivity}:android.view.InflateException: Binary XML file line #2:
Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:06:56.709: E/AndroidRuntime(690): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.
java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
AndroidRuntime(690): ... 11 more
AndroidRuntime(690): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's
AndroidManifest.xml does not have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:06:56.709: E/AndroidRuntime(690): ... 23 more
09-01 15:07:53.868: E/Trace(734): error opening trace file: No such file or directory (2)
09-01 15:07:54.479: E/AndroidRuntime(734): FATAL EXCEPTION: main
09-01 15:07:54.479: E/AndroidRuntime(734): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:07:54.479: E/AndroidRuntime(734): Caused by:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.
setContentView(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
E/AndroidRuntime(734): ... 11 more
E/AndroidRuntime(734): Caused by: java.lang.IllegalStateException: The meta-data tag in your
app's AndroidManifest.xml does not have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:07:54.479: E/AndroidRuntime(734): ... 23 more
error opening trace file: No such file or directory (2)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:12:22.938: E/AndroidRuntime(811): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:12:22.938: E/AndroidRuntime(811): ... 11 more
09-01 15:12:22.938: E/AndroidRuntime(811): Caused by: java.lang.IllegalStateException: The meta-
data tag in your app's AndroidManifest.xml does not have the right value. Expected 5089000
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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:19:34.508: E/Trace(826): error opening trace file: No such file or directory (2)
09-01 15:19:35.118: E/AndroidRuntime(826): FATAL EXCEPTION: main
09-01 15:19:35.118: E/AndroidRuntime(826): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}: android.view.InflateException:
Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:19:35.118: E/AndroidRuntime(826): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:19:35.118: E/AndroidRuntime(826): ... 11 more
09-01 15:19:35.118: E/AndroidRuntime(826): Caused by: java.lang.IllegalStateException:
The meta- data tag in your app's AndroidManifest.xml does not
have the right value. Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailabl
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:27:57.068: E/Trace(865): error opening trace file: No such file or directory (2)
09-01 15:27:57.748: E/AndroidRuntime(865): FATAL EXCEPTION: main
09-01 15:27:57.748: E/AndroidRuntime(865): java.lang.RuntimeException:
Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
android.app.ActivityThread.access$600(ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4745)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
dalvik.system.NativeStart.main(Native Method)
09-01 15:27:57.748: E/AndroidRuntime(865): Caused by: android.view.InflateException: Binary XML
file line #2: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
android.view.LayoutInflater.inflate(LayoutInflater.java:466)
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
android.app.Activity.setContentView(Activity.java:1867)
android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
android.support.v7.app.ActionBarActivityDelegateICS.setContentView
(ActionBarActivityDelegateICS.java:110)
android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
myapp.MainActivity.onCreate(MainActivity.java:14)
android.app.Activity.performCreate(Activity.java:5008)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-01 15:27:57.748: E/AndroidRuntime(865): ... 11 more
09-01 15:27:57.748: E/AndroidRuntime(865): Caused by: java.lang.IllegalStateException:
The meta- data tag in your app's AndroidManifest.xml does not have the right value.
Expected 5089000 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" />
com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source)
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
(Unknown Source)
com.google.android.gms.maps.internal.u.I(Unknown Source)
com.google.android.gms.maps.internal.u.H(Unknown Source)
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
com.google.android.gms.maps.MapFragment$b.jz(Unknown Source)
com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
com.google.android.gms.dynamic.a.a(Unknown Source)
com.google.android.gms.dynamic.a.onInflate(Unknown Source)
com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
android.app.Activity.onCreateView(Activity.java:4663)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-01 15:27:57.748: E/AndroidRuntime(865): ... 23 more
mmmh... Change
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
to
<meta-data android:name="com.google.android.gms.version" android:value="5089000" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.myapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.myapp."Your activity name""
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Your map key" />
</application>
</manifest>
Add the below permission to your Manifest.xml
<permission android:name="com.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
and replaca the below line:
<uses-permissionandroid:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
via
<uses-permission android:name="com.myapp.providers.gsf.permission.
READ_GSERVICES"/>
Hi I am trying to run an android app. Where my goal was to display a radar graph based on user preferences for that I have used the webview and sending the username to php file.
But Now I was getting an error stating that "java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.newairways/com.example.newairways.communication}: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity"
I Have tried my level best to solve this but I could able to it. and in error it was stated the communication class was not mentioned So I have also mentioned but I required the radar part to display. So Please help me in solving this.
Here is my logcat
08-04 19:59:21.861: D/gralloc_goldfish(654): Emulator without GPU emulation detected.
08-04 19:59:22.071: W/TextLayoutCache(654): computeValuesWithHarfbuzz -- need to force to single run
08-04 19:59:32.541: D/dalvikvm(654): GC_CONCURRENT freed 177K, 3% free 14296K/14599K, paused 7ms+7ms
08-04 19:59:36.962: W/TextLayoutCache(654): computeValuesWithHarfbuzz -- need to force to single run
08-04 19:59:45.762: W/SingleClientConnManager(654): Invalid use of SingleClientConnManager: connection still allocated.
08-04 19:59:45.762: W/SingleClientConnManager(654): Make sure to release the connection before allocating another one.
08-04 19:59:45.811: I/System.out(654): Response : User Found
08-04 19:59:45.811: I/System.out(654): ---IF---
08-04 19:59:46.682: D/dalvikvm(654): GC_CONCURRENT freed 214K, 3% free 14607K/14919K, paused 6ms+8ms
08-04 19:59:46.831: D/dalvikvm(654): GC_FOR_ALLOC freed 13K, 2% free 14946K/15239K, paused 52ms
08-04 19:59:50.781: D/AndroidRuntime(654): Shutting down VM
08-04 19:59:50.781: W/dalvikvm(654): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
08-04 19:59:50.831: E/AndroidRuntime(654): FATAL EXCEPTION: main
08-04 19:59:50.831: E/AndroidRuntime(654): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.newairways/com.example.newairways.communication}: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.os.Looper.loop(Looper.java:137)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-04 19:59:50.831: E/AndroidRuntime(654): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 19:59:50.831: E/AndroidRuntime(654): at java.lang.reflect.Method.invoke(Method.java:511)
08-04 19:59:50.831: E/AndroidRuntime(654): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-04 19:59:50.831: E/AndroidRuntime(654): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-04 19:59:50.831: E/AndroidRuntime(654): at dalvik.system.NativeStart.main(Native Method)
08-04 19:59:50.831: E/AndroidRuntime(654): Caused by: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-04 19:59:50.831: E/AndroidRuntime(654): ... 11 more
08-04 20:06:29.651: D/gralloc_goldfish(707): Emulator without GPU emulation detected.
08-04 20:06:29.802: W/TextLayoutCache(707): computeValuesWithHarfbuzz -- need to force to single run
08-04 20:06:35.271: D/dalvikvm(707): GC_CONCURRENT freed 133K, 2% free 14335K/14599K, paused 7ms+6ms
08-04 20:06:47.093: W/TextLayoutCache(707): computeValuesWithHarfbuzz -- need to force to single run
08-04 20:06:55.241: W/SingleClientConnManager(707): Invalid use of SingleClientConnManager: connection still allocated.
08-04 20:06:55.241: W/SingleClientConnManager(707): Make sure to release the connection before allocating another one.
08-04 20:06:55.352: D/dalvikvm(707): GC_CONCURRENT freed 298K, 3% free 14484K/14855K, paused 6ms+8ms
08-04 20:06:55.441: I/System.out(707): Response : User Found
08-04 20:06:55.512: I/System.out(707): ---IF---
08-04 20:06:56.211: D/dalvikvm(707): GC_FOR_ALLOC freed 70K, 3% free 14754K/15111K, paused 46ms
08-04 20:06:56.334: D/dalvikvm(707): GC_FOR_ALLOC freed 3K, 3% free 15023K/15367K, paused 50ms
08-04 20:07:00.851: D/AndroidRuntime(707): Shutting down VM
08-04 20:07:00.851: W/dalvikvm(707): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
08-04 20:07:00.901: E/AndroidRuntime(707): FATAL EXCEPTION: main
08-04 20:07:00.901: E/AndroidRuntime(707): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.newairways/com.example.newairways.communication}: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.os.Looper.loop(Looper.java:137)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-04 20:07:00.901: E/AndroidRuntime(707): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 20:07:00.901: E/AndroidRuntime(707): at java.lang.reflect.Method.invoke(Method.java:511)
08-04 20:07:00.901: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-04 20:07:00.901: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-04 20:07:00.901: E/AndroidRuntime(707): at dalvik.system.NativeStart.main(Native Method)
08-04 20:07:00.901: E/AndroidRuntime(707): Caused by: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-04 20:07:00.901: E/AndroidRuntime(707): ... 11 more
Here is my manifesto file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newairways"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.newairways.login"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.newairways.menu"
android:label="#string/app_name" >
</activity>s
<activity
android:name="com.example.newairways.bar"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.radar"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.measure"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.plan"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.day0"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.goaltest"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.relationship"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.start"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.discipline"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.skills"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.knowledge"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.emotions"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.adaptation"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.leadership"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.lifequality"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.Globalvars"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.newairways.communication"
android:label="#string/app_name" >
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Does your activity extend android.app.activity ? Is the activity mentioned in the manifest file. Is the base package and fully qualified name of the activity class correct??
I am newbie on Android Google Maps API and I was trying to develop a small app using the API. I use as a reference the Google documentation form: https://developers.google.com/maps/documentation/android/ and I follow all the step with caution. When I build it and install it on to my device (Android 2.3.6) the app crash. I follow all the instructions to sign the app and get the API key for this specific app, tried all the step of the documentation several times without any good results. Please, can someone help me with this? I there something missing?
Thank you!
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.application.uprm_map"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<permission
android:name="com.application.uprm_map.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.application.uprm_map.permission.MAPS_RECEIVE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<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-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.application.uprm_map.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="<my own key>"/>
</application>
</manifest>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
MainActivity.java
package com.application.uprm_map;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Exeptions:
03-05 02:29:27.645: D/dalvikvm(32056): GC_EXTERNAL_ALLOC freed 42K, 49% free 2748K/5379K, external 0K/0K, paused 21ms
03-05 02:29:27.650: D/AndroidRuntime(32056): Shutting down VM
03-05 02:29:27.650: W/dalvikvm(32056): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
03-05 02:29:27.655: E/AndroidRuntime(32056): FATAL EXCEPTION: main
03-05 02:29:27.655: E/AndroidRuntime(32056): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.application.uprm_map/com.application.uprm_map.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.os.Looper.loop(Looper.java:130)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.app.ActivityThread.main(ActivityThread.java:3691)
03-05 02:29:27.655: E/AndroidRuntime(32056): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 02:29:27.655: E/AndroidRuntime(32056): at java.lang.reflect.Method.invoke(Method.java:507)
03-05 02:29:27.655: E/AndroidRuntime(32056): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
03-05 02:29:27.655: E/AndroidRuntime(32056): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
03-05 02:29:27.655: E/AndroidRuntime(32056): at dalvik.system.NativeStart.main(Native Method)
03-05 02:29:27.655: E/AndroidRuntime(32056): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-05 02:29:27.655: E/AndroidRuntime(32056): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:234)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.app.Activity.setContentView(Activity.java:1679)
03-05 02:29:27.655: E/AndroidRuntime(32056): at com.application.uprm_map.MainActivity.onCreate(MainActivity.java:11)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
03-05 02:29:27.655: E/AndroidRuntime(32056): ... 11 more
03-05 02:29:27.655: E/AndroidRuntime(32056): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.application.uprm_map-1.apk]
03-05 02:29:27.655: E/AndroidRuntime(32056): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-05 02:29:27.655: E/AndroidRuntime(32056): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-05 02:29:27.655: E/AndroidRuntime(32056): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
03-05 02:29:27.655: E/AndroidRuntime(32056): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
03-05 02:29:27.655: E/AndroidRuntime(32056): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
03-05 02:29:27.655: E/AndroidRuntime(32056): ... 19 more
03-05 02:29:29.660: I/dalvikvm(32056): threadid=4: reacting to signal 3
03-05 02:29:29.665: I/dalvikvm(32056): Wrote stack traces to '/data/anr/traces.txt'
First thing as you are having the API level 8 or below so you have to use the SupportMapFragment instead of MapFragment as below in your layout file.
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
Second thing you have to extend the FragmentActivity instead of Activity :
public class MainActivity extends FragmentActivity {
Do the above changes and then run your application.