Android Manifest change force closes app - android

I added a class to my working app. I want the new class to be the first page to load, its called dashboard.class. I added it to the manifest and now the app force closes when you try to load it. I also went and removed the entry in the manifest and the app worked again. Please tell me what I am doing wrong
<activity
android:name="com.magicbuddy.gamble.Dashboard"
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.magicbuddy.gamble.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.MagicBuddy.Gamble.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
The dashboard is the new class I added. When I remove it and reset MainActivity to LAUNCHER and MAIN, the app will work just fine again.
I tried the posted solutions of removing the intent-filter and it is still crashing. Here is the logcat **Also thank you guys for your replys
01-31 13:56:38.709: D/AndroidRuntime(1995): Shutting down VM
01-31 13:56:38.709: W/dalvikvm(1995): threadid=1: thread exiting with uncaught exception (group=0xb2eda288)
01-31 13:56:38.709: E/AndroidRuntime(1995): FATAL EXCEPTION: main
01-31 13:56:38.709: E/AndroidRuntime(1995): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.magicbuddy.gamble/com.magicbuddy.gamble.Dashboard}: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.app.ActivityThread.access$600(ActivityThread.java:130)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.os.Looper.loop(Looper.java:137)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-31 13:56:38.709: E/AndroidRuntime(1995): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 13:56:38.709: E/AndroidRuntime(1995): at java.lang.reflect.Method.invoke(Method.java:511)
01-31 13:56:38.709: E/AndroidRuntime(1995): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-31 13:56:38.709: E/AndroidRuntime(1995): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-31 13:56:38.709: E/AndroidRuntime(1995): at dalvik.system.NativeStart.main(Native Method)
01-31 13:56:38.709: E/AndroidRuntime(1995): Caused by: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button
01-31 13:56:38.709: E/AndroidRuntime(1995): at com.magicbuddy.gamble.Dashboard.onCreate(Dashboard.java:25)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.app.Activity.performCreate(Activity.java:5008)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
01-31 13:56:38.709: E/AndroidRuntime(1995): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
I added a class that has only 4 buttons on it and each button has an image. That is what I want to load first but this is the logcat error when I try to make that happen

According to the logcat the Exception is:
java.lang.ClassCastException: android.widget.ImageButton cannot be
cast to android.widget.Button
This is happening in the onCreate() method of your Dashboard Activity. You are casting an ImageButton to a Button. The problem is not in the manifest but in the class itself.

Try removing the intent-filter from your MainActivity. You really only need to define intent filters when trying to control what types of intents access into your activity, but if that is only going to be called upon by your Dashboard activity as I think it is, then you don't need to include the intent filter as it is part of the same package

Related

java.lang.ClassNotFoundException: Didn't find class "com.millennialmedia.android.VideoPlayer"

I recently moved to MoPub and it all appears to be working well except for I have started getting this exception saying that com.millennialmedia.android.VideoPlayer can not be found. I looked and it isn't on the Millennial jar (I just got the latest from their site). Also my AndroidManifest mentions that class and Android Studio also says it can't be found.
This is what I have there:
<activity android:name="com.millennialmedia.android.MMActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation|keyboard" />
<activity android:name="com.millennialmedia.android.VideoPlayer" android:configChanges="keyboardHidden|orientation|keyboard" />
On Android Studio the VideoPlayer part is red.
This is the exception I got:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{mypackage/com.millennialmedia.android.VideoPlayer}: java.lang.ClassNotFoundException: Didn't find class "com.millennialmedia.android.VideoPlayer" on path: /data/app/mypackage-1.apk
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.millennialmedia.android.VideoPlayer" on path: /data/app/mypackage-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(NativeStart.java)
Looking at the latest Millennial Media documentation, it looks like
com.millennialmedia.android.VideoPlayer
isn't included. This may be an update that needs to be made.
Alice

Errors in a testing android project

I'm trying to run this code (android app):
manifest file:
<<<<<<< Original
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testamish"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Results"
android:label="#string/title_activity_results" >
</activity>
<activity
android:name=".SpinnerDemo"
android:label="#string/title_activity_spinner_demo" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<activity android:name="com.example.testamish.MainActivity"
android:label="#string/title_activity_main"
>
</activity>
</application>
</manifest>
>>>>>>> Added
However, when trying to launch this on a virtual device, I get those errors and I don't get why (code has no errors/warnings):
10-17 17:07:22.685: E/Trace(819): error opening trace file: No such file or directory (2)
10-17 17:07:23.430: D/AndroidRuntime(819): Shutting down VM
10-17 17:07:23.430: W/dalvikvm(819): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
10-17 17:07:23.445: E/AndroidRuntime(819): FATAL EXCEPTION: main
10-17 17:07:23.445: E/AndroidRuntime(819): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.testamish/com.example.testamish.MainActivity}: java.lang.ClassNotFoundException: com.example.testamish.MainActivity
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.os.Looper.loop(Looper.java:137)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.reflect.Method.invokeNative(Native Method)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.reflect.Method.invoke(Method.java:511)
10-17 17:07:23.445: E/AndroidRuntime(819): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-17 17:07:23.445: E/AndroidRuntime(819): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-17 17:07:23.445: E/AndroidRuntime(819): at dalvik.system.NativeStart.main(Native Method)
10-17 17:07:23.445: E/AndroidRuntime(819): Caused by: java.lang.ClassNotFoundException: com.example.testamish.MainActivity
10-17 17:07:23.445: E/AndroidRuntime(819): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-17 17:07:23.445: E/AndroidRuntime(819): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
10-17 17:07:23.445: E/AndroidRuntime(819): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
10-17 17:07:23.445: E/AndroidRuntime(819): ... 11 more
Thanks for your help!
Solution
Remove this from you Manifest (from the original one!):
<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>
And add this four line to the Activity, you want to start on launch:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Details
In Android, the data&actions between activities is driven by Intents. When you want to launch an app, it's kind an action between the Launcher app, and your app. It's also an Intent, when you start the Gallery, to choose an image for Facebook, or to start the Twitter app, to share something.
You can define in the Manifest.xml, for each Activity of your app, to which Intents to catch. You defined a MainActivity in your Manifest, and set to catch the android.intent.action.MAIN and android.intent.category.LAUNCHER intents. These two Intents responds, to start the app from the Launcher.
So the emulator was finding for your MainActivity, 'cause it read from you Manifest, to start that. But cannot found it, so throw an exception.

Android google map

I am try to add Google MAP Api v2 in my application.but I am getting exception. Exception is
java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
Here is my xml class
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
this is my main class
public class MainActivity extends Activity {
private GoogleMap _googleMap=null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try
{
//loading map
initilizeMap();
_googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
_googleMap.setMyLocationEnabled(true);
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if(_googleMap==null)
{
_googleMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
if (_googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
initilizeMap();
}
}
this is my logcat
01-31 14:20:55.603: E/AndroidRuntime(311): FATAL EXCEPTION: main
01-31 14:20:55.603: E/AndroidRuntime(311): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demo/com.example.demo.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.os.Looper.loop(Looper.java:123)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.reflect.Method.invoke(Method.java:521)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-31 14:20:55.603: E/AndroidRuntime(311): at dalvik.system.NativeStart.main(Native Method)
01-31 14:20:55.603: E/AndroidRuntime(311): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.Activity.setContentView(Activity.java:1647)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.example.demo.MainActivity.onCreate(MainActivity.java:22)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-31 14:20:55.603: E/AndroidRuntime(311): ... 11 more
01-31 14:20:55.603: E/AndroidRuntime(311): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.demo-2.apk]
01-31 14:20:55.603: E/AndroidRuntime(311): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
You should use SupportMapFragment instead of MapFragment.
Change
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
to
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Also change
_googleMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
to
_googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
R.id.map)).getMap();
And also If you're using fragments on older devices (pre Honeycomb) you should always extend your Activity from FragmentActivity.
and also check
Add the Google Play services version to your app's manifest
Edit your application's AndroidManifest.xml file, and add the
following declaration within the element. This embeds the version of
Google Play services that the app was compiled with.
You just need to add <meta-data> under <application> tag into your AndroidManifest.xml
....<application>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
This is because latest google play services requires a version name, which is to be mentioned using <meta-data .. /> inside AndroidManifest.xml
Extend your MainActivity from FragmentActivity.
Refer this :
Inflating Google Maps v2 fragment causes ClassNotFoundException
If you are using Fragments your MainActivity must extends FragmentActivity:
public class MainActivity extends FragmentActivity {
//Stuff
}
If you are using the Support-Library so you can use your Fragments in lower Android API Levels use This:
public class MainActivity extends android.support.v4.app.FragmentActivity{
//Stuff
}
And use the SupportFragmentMap in your XML:
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
In your xml try to change from
android:name="com.google.android.gms.maps.MapFragment"
to
android:name="com.google.android.gms.maps.SupportMapFragment"
Check if this work.

Google Maps Android API v2 and Eclipse

I am new in Google Map and so many things aren't clear enough to me for that reason.So i expect some expert's direction on this regard.I read This Guide and did everything what it says.I use google map api v2 and get a map key.Then i make a sample project following that link and select target version android 2.2(while running the project).But a list of error occurs after running then example in eclipse android emulator.My logcat view shows:
01-31 00:51:59.226: W/dalvikvm(329): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-31 00:51:59.236: E/AndroidRuntime(329): FATAL EXCEPTION: main
01-31 00:51:59.236: E/AndroidRuntime(329): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.googleMapApp/com.googleMapApp.LocationProfileManagerActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.os.Looper.loop(Looper.java:123)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-31 00:51:59.236: E/AndroidRuntime(329): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 00:51:59.236: E/AndroidRuntime(329): at java.lang.reflect.Method.invoke(Method.java:521)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-31 00:51:59.236: E/AndroidRuntime(329): at dalvik.system.NativeStart.main(Native Method)
01-31 00:51:59.236: E/AndroidRuntime(329): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.Activity.setContentView(Activity.java:1647)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.googleMapApp.LocationProfileManagerActivity.onCreate(LocationProfileManagerActivity.java:14)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-31 00:51:59.236: E/AndroidRuntime(329): ... 11 more
01-31 00:51:59.236: E/AndroidRuntime(329): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.googleMapApp-1.apk]
01-31 00:51:59.236: E/AndroidRuntime(329): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-31 00:51:59.236: E/AndroidRuntime(329): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-31 00:51:59.236: E/AndroidRuntime(329): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
My Manifest.xml is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.googleMapApp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<permission
android:name="com.googleMapApp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.googleMapApp.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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"/>
<!-- Require OpenGL ES version 2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".LocationProfileManagerActivity"
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="myMapKey"/>
</application>
</manifest>
My main.xml is:
<?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"
class="com.google.android.gms.maps.MapFragment"/>
My activity.java is:
package com.googleMapApp;
import android.app.Activity;
import android.os.Bundle;
public class LocationProfileManagerActivity extends Activity {
/** Called when the activity is first created. */
//private GoogleMap map;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}
}
Sorry for this lengthy description,but i want to show you exactly what i did.I think as a newcomer i did a lot of mistake on this way.so i expect someone will guide me that.
You are using features only available in later APIs, namely Fragment. If you want to compile to support 2.2, you need to include the Support Library in your project. You will also have to make the following changes to use support fragments instead of regular fragments --
In main.xml, change
class="com.google.android.gms.maps.MapFragment"/>
to
class="com.google.android.gms.maps.SupportMapFragment"/>
and in your activity.java, change
public class LocationProfileManagerActivity extends Activity {
to
public class LocationProfileManagerActivity extends FragmentActivity {
you need to make two changes
Since as you are sdk version is below 12, need to make following change
1)
main.xml
Replace
class="com.google.android.gms.maps.MapFragment"/>
with
class="com.google.android.gms.maps.SupportMapFragment"/>
2) activity.java
Need to extend FragmentActivity instead of Activity
If you want to test in emulator , then download the google_play_services_apk and install it in emulator.
Maps API v2 cannot be run in an emulator because of its dependency on Google Play Services, which is bundled in the Google Play Store .apk. It can be hacked together though, you can read about it here on the first Google result for "Google maps v2 emulator". Also you can still use V1 for a limited time, you can get started here.

Force Down error in MapView

i want to open a map when i click a button but unfortunately my app forces down...this is my logcat:
01-31 18:11:49.465: VERBOSE/InputDevice(2836): ID[0]=0(0) Up(1=>0)
01-31 18:11:49.606: WARN/dalvikvm(6111): Class resolved by unexpected DEX: Lkostas/menu/olympiakos/GoogleMaps;(0x486356d8):0x22f5d8 ref [Lcom/google/android/maps/MapActivity;] Lcom/google/android/maps/MapActivity;(0x486356d8):0x21dca0
01-31 18:11:49.606: WARN/dalvikvm(6111): (Lkostas/menu/olympiakos/GoogleMaps; had used a different Lcom/google/android/maps/MapActivity; during pre-verification)
01-31 18:11:49.606: WARN/dalvikvm(6111): Unable to resolve superclass of Lkostas/menu/olympiakos/GoogleMaps; (67)
01-31 18:11:49.606: WARN/dalvikvm(6111): Link of class 'Lkostas/menu/olympiakos/GoogleMaps;' failed
01-31 18:11:49.610: DEBUG/AndroidRuntime(6111): Shutting down VM
01-31 18:11:49.610: WARN/dalvikvm(6111): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): FATAL EXCEPTION: main
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): java.lang.NoClassDefFoundError: kostas.menu.olympiakos.GoogleMaps
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at kostas.menu.olympiakos.DialogActivity$1.onItemClick(DialogActivity.java:47)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at android.widget.ListView.performItemClick(ListView.java:3672)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at android.os.Handler.handleCallback(Handler.java:587)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at android.os.Handler.dispatchMessage(Handler.java:92)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at android.os.Looper.loop(Looper.java:123)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at java.lang.reflect.Method.invoke(Method.java:521)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at dalvik.system.NativeStart.main(Native Method)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at dalvik.system.DexFile.defineClass(Native Method)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:209)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:203)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-31 18:11:49.641: ERROR/AndroidRuntime(6111): ... 13 more
01-31 18:11:49.660: WARN/ActivityManager(2836): Force finishing activity kostas.menu.olympiakos/.DialogActivity
thats the way i m calling the map activity:
Intent newActivity111 = new Intent(DialogActivity.this, GoogleMaps.class);
startActivity(newActivity111);
Somehow, your device or emulator has a different implementation of com.google.android.maps.MapActivity than what your compiler used. That should not be possible under normal circumstances. It suggests that you have seriously messed up your build process, such as manually adding the Maps add-on JAR to your build path rather than just setting a Maps-enabled target.
Not too sure whether your problem is related to the libraries available.
Map library is not part of the Standard Android library. Hence you need to declare it in the Manifest file.
Follow the link: http://developer.android.com/resources/tutorials/views/hello-mapview.html
Since the library is not available your Activity "GoogleMaps" which extends MapActivity doesn't get loaded into the system.
All the questions and answers related to getting the Fatal Exception java.lang.NoClassDefFoundError when using a MapActivity did not help me. CommonsWare's response gave me a hint that helped me arrive at my solution.
When I copied my project to a new environment, my setup did not include the Google Maps library. I added the maps.jar file manually into my project and was able to link the application successfully but when I attempted to start the activity that derived from MapActivity I got the fatal exception.
I removed the reference to the maps.jar library. I then noticed I was building against the Android 2.2 SDK. I did not have the Google APIs SDK installed. After downloading and installing the Google APIs SDK, and specifying this SDK as my target, my problem went away.

Categories

Resources