I am a beginner in android development and i tried to make a small app. it was working fine but, then i started fiddling with the AndroidManifest file, but anyway i had to restore it from the backup i already created.
But now the app starts but just to show the first activity, and then it says "UNFORTUNATELY, APP TITLE HAS STOPPED".
I have tried the following:
1. Trying to find error in AndroidMainfest.
2. Project->Clean
3. Searching stackoverflow
But nothing seems to work
This is my console
[2013-06-28 12:18:07 - start] Uploading start.apk onto device 'emulator-5554'
[2013-06-28 12:18:08 - start] Installing start.apk...
[2013-06-28 12:18:14 - start] Success!
[2013-06-28 12:18:14 - start] Failed to install start.apk on device 'emulator-5554': device not found
[2013-06-28 12:18:14 - start] com.android.ddmlib.InstallException: device not found
[2013-06-28 12:18:14 - start] Launch canceled!
and my Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.start"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
android:configChanges="orientation|keyboardHidden|screenSize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".StartingPointActivity"
android:configChanges="orientation|keyboardHidden|screenSize" >
<intent-filter>
<action android:name="com.davinci.STARTINGPOINTACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:configChanges="orientation|keyboardHidden|screenSize" >
<intent-filter>
<action android:name="com.davinci.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
my logcat output
06-26 20:36:41.007: D/dalvikvm(2673): Not late-enabling CheckJNI (already on)
06-26 20:36:41.567: E/Trace(2673): error opening trace file: No such file or directory (2)
06-26 20:36:42.377: D/dalvikvm(2673): GC_FOR_ALLOC freed 58K, 7% free 2497K/2676K, paused 29ms, total 33ms
06-26 20:36:42.377: I/dalvikvm-heap(2673): Grow heap (frag case) to 3.563MB for 1058416-byte allocation
06-26 20:36:42.507: D/dalvikvm(2673): GC_FOR_ALLOC freed 2K, 5% free 3528K/3712K, paused 123ms, total 123ms
06-26 20:36:42.797: D/dalvikvm(2673): GC_CONCURRENT freed 1K, 5% free 3528K/3712K, paused 6ms+32ms, total 290ms
06-26 20:36:43.317: D/gralloc_goldfish(2673): Emulator without GPU emulation detected.
06-26 20:36:45.407: D/dalvikvm(2673): GC_FOR_ALLOC freed 13K, 4% free 3637K/3772K, paused 32ms, total 38ms
06-26 20:36:45.407: I/dalvikvm-heap(2673): Grow heap (frag case) to 4.274MB for 635812-byte allocation
06-26 20:36:45.487: D/dalvikvm(2673): GC_CONCURRENT freed 3K, 4% free 4255K/4396K, paused 4ms+3ms, total 72ms
06-26 20:36:45.487: D/dalvikvm(2673): WAIT_FOR_CONCURRENT_GC blocked 16ms
06-26 20:36:45.777: E/ArrayAdapter(2673): You must supply a resource ID for a TextView
06-26 20:36:45.777: D/AndroidRuntime(2673): Shutting down VM
06-26 20:36:45.787: W/dalvikvm(2673): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-26 20:36:45.927: E/AndroidRuntime(2673): FATAL EXCEPTION: main
06-26 20:36:45.927: E/AndroidRuntime(2673): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:386)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ListView.makeAndAddView(ListView.java:1831)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ListView.fillDown(ListView.java:674)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ListView.fillFromTop(ListView.java:735)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ListView.layoutChildren(ListView.java:1652)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.AbsListView.onLayout(AbsListView.java:1994)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.View.layout(View.java:14008)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.View.layout(View.java:14008)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.View.layout(View.java:14008)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.View.layout(View.java:14008)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewGroup.layout(ViewGroup.java:4373)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.Choreographer.doFrame(Choreographer.java:532)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.os.Handler.handleCallback(Handler.java:725)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.os.Handler.dispatchMessage(Handler.java:92)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.os.Looper.loop(Looper.java:137)
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-26 20:36:45.927: E/AndroidRuntime(2673): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 20:36:45.927: E/AndroidRuntime(2673): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 20:36:45.927: E/AndroidRuntime(2673): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-26 20:36:45.927: E/AndroidRuntime(2673): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-26 20:36:45.927: E/AndroidRuntime(2673): at dalvik.system.NativeStart.main(Native Method)
06-26 20:36:45.927: E/AndroidRuntime(2673): Caused by: java.lang.ClassCastException: android.widget.TwoLineListItem cannot be cast to android.widget.TextView
06-26 20:36:45.927: E/AndroidRuntime(2673): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:379)
06-26 20:36:45.927: E/AndroidRuntime(2673): ... 37 more
and splash.java
package com.example.start;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity {
MediaPlayer song;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
song = MediaPlayer.create(Splash.this,R.raw.chimesound);
song.start();
Thread timer = new Thread()
{
public void run(){
try{
sleep(2000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openStatingPointActivity = new Intent("com.davinci.MENU");
startActivity(openStatingPointActivity);
}
}
};
timer.start();
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
song.release();
finish();
}
}
menu.java
package com.example.start;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Menu extends ListActivity{
String Classes[]= {"Ëxample1","StartingPointActivity","example1","example2","example3"};
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_2, Classes));
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String activityName = Classes[position];
try
{
Class ourClass = Class.forName("com.example.start." + activityName);
Intent ourIntent = new Intent(Menu.this,ourClass);
startActivity(ourIntent);
}
catch (ClassNotFoundException e){
e.printStackTrace();
}
}
}
Please HELP !
try installing your apk by command prompt. Open cmd and write
adb install start.apk
which is in your bin folder of your project.
Don't forget to go bin directory before this command.i.e.
cd C:/path/to/your/bin
Related
I can't show alert dialog. Everything is right until I set the method dialog.show(), then I can't open my application. Without this method everything is fine.
I declared two global objects:
AlertDialog.Builder builder;
AlertDialog dialog;
Then in MainActivity, I build a dialog by builder and create it.
builder = new AlertDialog.Builder(this.getApplicationContext());
builder.setMessage("We're sorry, but on Your device accelerometer isn't available")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which)
{
MainActivity.this.finish();
}
});
dialog = builder.create();
To this moment everything works and there's no any exceptions, but when I want to show the dialog, some exceptions appear and I can't run this application:
dialog.show(); //this method doesn't work and causes problems
What did I do wrong?
EDIT:
Exceptions:
06-26 20:49:03.540: D/dalvikvm(4085): GC_FOR_ALLOC freed 38K, 8% free 2499K/2712K, paused 42ms, total 45ms
06-26 20:49:03.580: I/dalvikvm-heap(4085): Grow heap (frag case) to 6.146MB for 3712016-byte allocation
06-26 20:49:03.700: D/dalvikvm(4085): GC_FOR_ALLOC freed 2K, 4% free 6121K/6340K, paused 112ms, total 112ms
06-26 20:49:03.770: D/dalvikvm(4085): GC_CONCURRENT freed <1K, 4% free 6121K/6340K, paused 6ms+16ms, total 71ms
06-26 20:49:04.460: D/gralloc_goldfish(4085): Emulator without GPU emulation detected.
06-26 20:49:42.030: E/Trace(4138): error opening trace file: No such file or directory (2)
06-26 20:49:42.900: D/dalvikvm(4138): GC_FOR_ALLOC freed 41K, 8% free 2499K/2716K, paused 66ms, total 68ms
06-26 20:49:42.940: I/dalvikvm-heap(4138): Grow heap (frag case) to 6.146MB for 3712016-byte allocation
06-26 20:49:43.050: D/dalvikvm(4138): GC_FOR_ALLOC freed 2K, 4% free 6121K/6344K, paused 107ms, total 107ms
06-26 20:49:43.120: D/dalvikvm(4138): GC_CONCURRENT freed <1K, 4% free 6121K/6344K, paused 5ms+5ms, total 70ms
06-26 20:49:43.540: D/dalvikvm(4138): GC_FOR_ALLOC freed 3638K, 53% free 3483K/7300K, paused 36ms, total 37ms
06-26 20:49:43.621: D/AndroidRuntime(4138): Shutting down VM
06-26 20:49:43.630: W/dalvikvm(4138): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-26 20:49:43.640: E/AndroidRuntime(4138): FATAL EXCEPTION: main
06-26 20:49:43.640: E/AndroidRuntime(4138): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.accelerometertest/com.example.accelerometertest.MainActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.os.Looper.loop(Looper.java:137)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-26 20:49:43.640: E/AndroidRuntime(4138): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 20:49:43.640: E/AndroidRuntime(4138): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 20:49:43.640: E/AndroidRuntime(4138): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-26 20:49:43.640: E/AndroidRuntime(4138): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-26 20:49:43.640: E/AndroidRuntime(4138): at dalvik.system.NativeStart.main(Native Method)
06-26 20:49:43.640: E/AndroidRuntime(4138): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.view.ViewRootImpl.setView(ViewRootImpl.java:571)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:246)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.Dialog.show(Dialog.java:281)
06-26 20:49:43.640: E/AndroidRuntime(4138): at com.example.accelerometertest.MainActivity.onCreate(MainActivity.java:67)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.Activity.performCreate(Activity.java:5104)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-26 20:49:43.640: E/AndroidRuntime(4138): ... 11 more
change
builder = new AlertDialog.Builder(this.getApplicationContext());
to (As long as thisis your MainActivity )
builder = new AlertDialog.Builder(this);
I know this is a duplicate question, but solutions from previous post doesn't worked for
me. Thats why am asking this question.
I am trying to implement Google Map V2 in Android App, I got below error
06-26 19:24:51.035: E/AndroidRuntime(7679): FATAL EXCEPTION: main
06-26 19:24:51.035: E/AndroidRuntime(7679): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.titutorial.mapdemo/com.titutorial.mapdemo.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.access$600(ActivityThread.java:140)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.os.Looper.loop(Looper.java:137)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.main(ActivityThread.java:4898)
06-26 19:24:51.035: E/AndroidRuntime(7679): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 19:24:51.035: E/AndroidRuntime(7679): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 19:24:51.035: E/AndroidRuntime(7679): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
06-26 19:24:51.035: E/AndroidRuntime(7679): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
06-26 19:24:51.035: E/AndroidRuntime(7679): at dalvik.system.NativeStart.main(Native Method)
06-26 19:24:51.035: E/AndroidRuntime(7679): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-26 19:24:51.035: E/AndroidRuntime(7679): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Activity.setContentView(Activity.java:1924)
06-26 19:24:51.035: E/AndroidRuntime(7679): at com.titutorial.mapdemo.MainActivity.onCreate(MainActivity.java:12)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Activity.performCreate(Activity.java:5206)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
06-26 19:24:51.035: E/AndroidRuntime(7679): ... 11 more
06-26 19:24:51.035: E/AndroidRuntime(7679): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Fragment.instantiate(Fragment.java:584)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Fragment.instantiate(Fragment.java:552)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Activity.onCreateView(Activity.java:4849)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
06-26 19:24:51.035: E/AndroidRuntime(7679): ... 20 more
06-26 19:24:51.035: E/AndroidRuntime(7679): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
06-26 19:24:51.035: E/AndroidRuntime(7679): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-26 19:24:51.035: E/AndroidRuntime(7679): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-26 19:24:51.035: E/AndroidRuntime(7679): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-26 19:24:51.035: E/AndroidRuntime(7679): at android.app.Fragment.instantiate(Fragment.java:574)
06-26 19:24:51.035: E/AndroidRuntime(7679): ... 23 more
I followed below tutorial,
https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
I did below things
Install Google Play services
Created a new app in Google Console, and got Google Map API key
Created new app in eclipse and added permission and Google Map API key in AndroidManifest.xml
Added Google Play Services library to App
Add a Map to the App (main.xml)
Set targeted API level 17
in my 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"/>
here is my complete source code
https://github.com/railskarthi/MapDemo
After API 11+, I think you now have have to replace your MapFragment by SupportMapFragment. It would be something like:
<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"/>
Take a look here for further information. Let me know how are you going with.
I have download your project from git and after checking i found that you have missed a line which is required to display map Fragment.
Replace your main activity code with the following code:-
public class MainActivity extends FragmentActivity {
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
}
This could happen also if you did not define API_KEY for google maps in your manifest file.
It looks like this:
`....
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="<your key>" />
....`
Create your key in Google Developer Console
Please add these line in your manifest file
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your Goolge API key" />
I have an android application and am trying to test the installation by downloading from a URL. The app is developed by me and I can load the app into emulator using eclipse and run it properly.
I uploaded the apk to webserver and point the emulators android browser to the location http://localhost:9080/myapp.apk. Emulator downloads the app properly. When I try to click on the downloaded file to install, it throws an error saying Unfortunately the process android.process.media has stopped. I am not sure how to proceed further to resolve this issue
Emulator Configuration: Android avd running on API 14, ICS 4.0.0 with 1GB sdcard.iso
Appreciate any insights.
Logcat shows the following:
07-10 19:17:19.195: I/qtaguid(380): Untagging socket 65 failed errno=-2
07-10 19:17:19.195: W/NetworkManagementSocketTagger(380): untagSocket(65) failed with errno -2
07-10 19:17:19.624: D/dalvikvm(80): GC_CONCURRENT freed 398K, 10% free 12133K/13383K, paused 10ms+10ms
07-10 19:17:20.174: D/dalvikvm(147): GC_CONCURRENT freed 699K, 31% free 11440K/16455K, paused 4ms+8ms
07-10 19:17:20.734: D/dalvikvm(147): GC_CONCURRENT freed 535K, 32% free 11325K/16455K, paused 3ms+7ms
07-10 19:17:21.025: D/dalvikvm(80): GC_EXPLICIT freed 105K, 10% free 12084K/13383K, paused 5ms+11ms
07-10 19:17:21.484: D/dalvikvm(380): GC_CONCURRENT freed 373K, 5% free 10112K/10631K, paused 4ms+5ms
07-10 19:17:24.464: W/KeyguardViewMediator(80): verifyUnlock called when not externally disabled
07-10 19:17:24.594: W/dalvikvm(380): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Landroid/drm/DrmManagerClient;
07-10 19:17:24.604: D/AndroidRuntime(380): Shutting down VM
07-10 19:17:24.614: W/dalvikvm(380): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
07-10 19:17:24.654: E/AndroidRuntime(380): FATAL EXCEPTION: main
07-10 19:17:24.654: E/AndroidRuntime(380): java.lang.ExceptionInInitializerError
07-10 19:17:24.654: E/AndroidRuntime(380): at com.android.providers.downloads.DownloadDrmHelper.getOriginalMimeType(DownloadDrmHelper.java:97)
07-10 19:17:24.654: E/AndroidRuntime(380): at com.android.providers.downloads.DownloadReceiver.openDownload(DownloadReceiver.java:153)
07-10 19:17:24.654: E/AndroidRuntime(380): at com.android.providers.downloads.DownloadReceiver.handleNotificationBroadcast(DownloadReceiver.java:104)
07-10 19:17:24.654: E/AndroidRuntime(380): at com.android.providers.downloads.DownloadReceiver.onReceive(DownloadReceiver.java:74)
07-10 19:17:24.654: E/AndroidRuntime(380): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2118)
07-10 19:17:24.654: E/AndroidRuntime(380): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
07-10 19:17:24.654: E/AndroidRuntime(380): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-10 19:17:24.654: E/AndroidRuntime(380): at android.os.Handler.dispatchMessage(Handler.java:99)
07-10 19:17:24.654: E/AndroidRuntime(380): at android.os.Looper.loop(Looper.java:137)
07-10 19:17:24.654: E/AndroidRuntime(380): at android.app.ActivityThread.main(ActivityThread.java:4340)
07-10 19:17:24.654: E/AndroidRuntime(380): at java.lang.reflect.Method.invokeNative(Native Method)
07-10 19:17:24.654: E/AndroidRuntime(380): at java.lang.reflect.Method.invoke(Method.java:511)
07-10 19:17:24.654: E/AndroidRuntime(380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-10 19:17:24.654: E/AndroidRuntime(380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-10 19:17:24.654: E/AndroidRuntime(380): at dalvik.system.NativeStart.main(Native Method)
07-10 19:17:24.654: E/AndroidRuntime(380): Caused by: java.lang.UnsatisfiedLinkError: Library drmframework_jni not found; tried [/vendor/lib/libdrmframework_jni.so, /system/lib/libdrmframework_jni.so]
07-10 19:17:24.654: E/AndroidRuntime(380): at java.lang.Runtime.loadLibrary(Runtime.java:393)
07-10 19:17:24.654: E/AndroidRuntime(380): at java.lang.System.loadLibrary(System.java:535)
07-10 19:17:24.654: E/AndroidRuntime(380): at android.drm.DrmManagerClient.<clinit>(DrmManagerClient.java:56)
07-10 19:17:24.654: E/AndroidRuntime(380): ... 15 more
07-10 19:17:24.804: W/InputManagerService(80): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#41647c30
07-10 19:17:25.044: I/WindowManager(80): createSurface Window{415ef168 paused=false}: DRAW NOW PENDING
Apparently its a bug in Android as pointed by #SevaAlekseyev above
code.google.com/p/android/issues/detail?id=21173
I was able to install by clicking on the app from downloads
Resolved in 4.1 (API 16). I get the same error because of an unsatisfied link error, libdrmframework_jni.so. Works well on a device.
When I click Settings in my application's menu, app crash instantly. I don't have idea how to repair it.
I am new to Android and I learn from Hello, Android book.
Application files below:
PrefsFragment.java:
package org.example.sudoku;
import android.os.Bundle;
import android.preference.PreferenceFragment;
public class PrefsFragment extends PreferenceFragment {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
res/xml/preferences.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
android:key="music"
android:title="#string/music_title"
android:summary="#string/music_summary"
android:defaultValue="true" />
<CheckBoxPreference
android:key="hints"
android:title="#string/hints_title"
android:summary="#string/hints_summary"
android:defaultValue="true" />
</PreferenceScreen>
Logcat:
06-26 16:14:26.600: W/dalvikvm(2827): threadid=1: thread exiting with uncaught exception (group=0x40a041f8)
06-26 16:14:26.610: E/AndroidRuntime(2827): FATAL EXCEPTION: main
06-26 16:14:26.610: E/AndroidRuntime(2827): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.example.sudoku/org.example.sudoku.PrefsFragment}: java.lang.ClassCastException: org.example.sudoku.PrefsFragment cannot be cast to android.app.Activity
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1993)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.access$600(ActivityThread.java:132)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.os.Looper.loop(Looper.java:137)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.main(ActivityThread.java:4575)
06-26 16:14:26.610: E/AndroidRuntime(2827): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 16:14:26.610: E/AndroidRuntime(2827): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 16:14:26.610: E/AndroidRuntime(2827): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
06-26 16:14:26.610: E/AndroidRuntime(2827): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
06-26 16:14:26.610: E/AndroidRuntime(2827): at dalvik.system.NativeStart.main(Native Method)
06-26 16:14:26.610: E/AndroidRuntime(2827): Caused by: java.lang.ClassCastException: org.example.sudoku.PrefsFragment cannot be cast to android.app.Activity
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
06-26 16:14:26.610: E/AndroidRuntime(2827): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1984)
06-26 16:14:26.610: E/AndroidRuntime(2827): ... 11 more
The problem is that you need to extend PreferenceActivity, not PreferenceFragment.
PreferenceActivity extends ListActivity, which extends Activity, while PreferenceFragment extends Fragment.
That's why you have the ClassCast Exception.
How did you access to your PreferenceFragment ?
Is it contained in a FragmentActivity ?
You cannot call directly a Fragment with startActivity();
06-26 17:07:09.898: E/AndroidRuntime(380): FATAL EXCEPTION: main
06-26 17:07:09.898: E/AndroidRuntime(380): java.lang.NoClassDefFoundError: org.mythrii.email.Mail
06-26 17:07:09.898: E/AndroidRuntime(380): at org.mythrii.email.Email$1.onClick(Email.java:19)
06-26 17:07:09.898: E/AndroidRuntime(380): at android.view.View.performClick(View.java:2485)
06-26 17:07:09.898: E/AndroidRuntime(380): at android.view.View$PerformClick.run(View.java:9080)
06-26 17:07:09.898: E/AndroidRuntime(380): at android.os.Handler.handleCallback(Handler.java:587)
06-26 17:07:09.898: E/AndroidRuntime(380): at android.os.Handler.dispatchMessage(Handler.java:92)
06-26 17:07:09.898: E/AndroidRuntime(380): at android.os.Looper.loop(Looper.java:123)
06-26 17:07:09.898: E/AndroidRuntime(380): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-26 17:07:09.898: E/AndroidRuntime(380): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 17:07:09.898: E/AndroidRuntime(380): at java.lang.reflect.Method.invoke(Method.java:507)
06-26 17:07:09.898: E/AndroidRuntime(380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-26 17:07:09.898: E/AndroidRuntime(380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-26 17:07:09.898: E/AndroidRuntime(380): at dalvik.system.NativeStart.main(Native Method)
The solution to this problem is to create a folder named "libs" in the project directory and copying all the external jar files there.
For further explanation, you can refer to this link.
http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
I think what you face is that your code compiles , but # run time it crashes . How do i solve this , create a libs folder in your project inside eclipse(if its not exist) and add the jar file that contains the org.mythrii.email.Mail class inside the libs folder , Then run you app .