This project has a number (433) saved in a database, which is accessed through a servlet and then should be sent to the Android app. Before I added AsyncTask the app would sometimes retrieve the data (should be 433) from the servlet and sometimes not. Upon clicking the homePage button, the mainActivity screen should appear and display the data. I added AsyncTask hoping it would work consistently, but now all I get is the text "Light Data= " but no data (should say "Light Data= 433). The servlet connects to the database fine, so I know the issue lies within the app. I'd really appreciate code that relates to my project, thankyou.
HomePage:
package com.example.clearlight;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class HomePage extends Activity {
private Button ScheduleBtn;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.homepage);
ScheduleBtn = (Button) findViewById(R.id.home_btn);
ScheduleBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(HomePage.this, MainActivity.class);
HomePage.this.startActivity(myIntent);
}
});
}
}
MainActivity:
package com.example.clearlight;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;
import android.widget.Toast;
import java.net.URL;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import android.os.StrictMode;
import android.util.Log;
public class MainActivity extends Activity {
TextView txt;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
setContentView(R.layout.relative);
class LongOperation extends AsyncTask<String, Void, String> {
#Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
String result=null;
URL url = null;
DefaultHttpClient httpclient = null;
try {
String registrationUrl = "http://10.0.2.2/SensorInfo/GetLightData?sensor=light";
url = new URL(registrationUrl);
HttpGet getRequest = new HttpGet(registrationUrl);
ResponseHandler<String> handler = new BasicResponseHandler();
httpclient = new DefaultHttpClient();
// request data from server
result = httpclient.execute(getRequest, handler);
Log.d("MyApp", "Data from server is "+ result);
}
catch (Exception ex) {Log.e("error",ex.toString());
ex.printStackTrace();
}
return result;
}
#Override
protected void onPostExecute(String result)
{
TextView text1 = (TextView)MainActivity.this.findViewById(R.id.text);
//Sets the new text to TextView (runtime click event)//*******
text1.setText("Light Data= " + result);
Toast.makeText(MainActivity.this, "Light Data:" + result, Toast.LENGTH_SHORT).show(); //MESSAGE BOX
}
}
}
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.clearlight"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.clearlight.MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.clearlight.HomePage"
android:label="#string/homepage"
android:parentActivityName="com.example.clearlight.MainActivity" >
<!-- Moved the intent filter to HomePage -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.clearlight.MainActivity" />
</activity>
</application>
</manifest>
Logcat:
03-20 01:08:20.433: D/Launcher.Model(418): Reload apps on config change. curr_mcc:310 prevmcc:0 03-20 01:08:20.473: E/StrictMode(401): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. 03-20 01:08:20.473: E/StrictMode(401): java.lang.Throwable: Explicit termination method 'close' not called 03-20 01:08:20.473: E/StrictMode(401): at dalvik.system.CloseGuard.open(CloseGuard.java:184) 03-20 01:08:20.473: E/StrictMode(401): at android.database.CursorWindow.(CursorWindow.java:137) 03-20 01:08:20.473: E/StrictMode(401): at android.database.CursorWindow.(CursorWindow.java:41) 03-20 01:08:20.473: E/StrictMode(401): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:681) 03-20 01:08:20.473: E/StrictMode(401): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:679) 03-20 01:08:20.473: E/StrictMode(401): at android.database.BulkCursorDescriptor.readFromParcel(BulkCursorDescriptor.java:75) 03-20 01:08:20.473: E/StrictMode(401): at android.database.BulkCursorDescriptor$1.createFromParcel(BulkCursorDescriptor.java:34) 03-20 01:08:20.473: E/StrictMode(401): at android.database.BulkCursorDescriptor$1.createFromParcel(BulkCursorDescriptor.java:30) 03-20 01:08:20.473: E/StrictMode(401): at android.content.ContentProviderProxy.query(ContentProviderNative.java:369) 03-20 01:08:20.473: E/StrictMode(401): at android.content.ContentResolver.query(ContentResolver.java:370) 03-20 01:08:20.473: E/StrictMode(401): at android.content.CursorLoader.loadInBackground(CursorLoader.java:65) 03-20 01:08:20.473: E/StrictMode(401): at android.content.CursorLoader.loadInBackground(CursorLoader.java:43) 03-20 01:08:20.473: E/StrictMode(401): at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:301) 03-20 01:08:20.473: E/StrictMode(401): at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:68) 03-20 01:08:20.473: E/StrictMode(401): at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:56) 03-20 01:08:20.473: E/StrictMode(401): at android.os.AsyncTask$2.call(AsyncTask.java:287) 03-20 01:08:20.473: E/StrictMode(401): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 03-20 01:08:20.473: E/StrictMode(401): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 03-20 01:08:20.473: E/StrictMode(401): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 03-20 01:08:20.473: E/StrictMode(401): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 03-20 01:08:20.473: E/StrictMode(401): at java.lang.Thread.run(Thread.java:856) 03-20 01:08:20.484: D/Launcher.Model(418): going to save icon bitmap for info=ShortcutInfo(title=Settingsintent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.settings/.Settings }id=6 type=0 container=-100 screen=3 cellX=2 cellY=3 spanX=1 spanY=1 isGesture=false dropPos=null) 03-20 01:08:20.534: E/StrictMode(401): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. 03-20 01:08:20.534: E/StrictMode(401): java.lang.Throwable: Explicit termination method 'close' not called 03-20 01:08:20.534: E/StrictMode(401): at dalvik.system.CloseGuard.open(CloseGuard.java:184) 03-20 01:08:20.534: E/StrictMode(401): at android.content.ContentResolver$CursorWrapperInner.(ContentResolver.java:1835) 03-20 01:08:20.534: E/StrictMode(401): at android.content.ContentResolver.query(ContentResolver.java:392) 03-20 01:08:20.534: E/StrictMode(401): at android.content.CursorLoader.loadInBackground(CursorLoader.java:65) 03-20 01:08:20.534: E/StrictMode(401): at android.content.CursorLoader.loadInBackground(CursorLoader.java:43) 03-20 01:08:20.534: E/StrictMode(401): at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:301) 03-20 01:08:20.534: E/StrictMode(401): at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:68) 03-20 01:08:20.534: E/StrictMode(401): at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:56) 03-20 01:08:20.534: E/StrictMode(401): at android.os.AsyncTask$2.call(AsyncTask.java:287) 03-20 01:08:20.534: E/StrictMode(401): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 03-20 01:08:20.534: E/StrictMode(401): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 03-20 01:08:20.534: E/StrictMode(401): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 03-20 01:08:20.534: E/StrictMode(401): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 03-20 01:08:20.534: E/StrictMode(401): at java.lang.Thread.run(Thread.java:856) 03-20 01:08:20.534: W/CursorWrapperInner(401): Cursor finalized without prior close() 03-20 01:08:20.563: W/CursorWrapperInner(401): Cursor finalized without prior close() 03-20 01:08:20.614: D/AlertService(401): No fired or scheduled alerts 03-20 01:08:20.704: D/dalvikvm(418): GC_CONCURRENT freed 328K, 5% free 10193K/10631K, paused 17ms+7ms, total 95ms 03-20 01:08:20.723: D/Launcher.Model(418): going to save icon bitmap for info=ShortcutInfo(title=Messagingintent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.mms/.ui.ConversationList }id=12 type=0 container=-101 screen=3 cellX=3 cellY=0 spanX=1 spanY=1 isGesture=false dropPos=null) 03-20 01:08:20.833: D/Launcher.Model(418): going to save icon bitmap for info=ShortcutInfo(title=Peopleintent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.contacts/.activities.PeopleActivity }id=10 type=0 container=-101 screen=1 cellX=1 cellY=0 spanX=1 spanY=1 isGesture=false dropPos=null) 03-20 01:08:20.893: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 0ms 03-20 01:08:21.083: D/dalvikvm(163): GC_EXPLICIT freed 222K, 47% free 10043K/18887K, paused 25ms+10ms, total 187ms 03-20 01:08:21.113: D/Launcher.Model(418): going to save icon bitmap for info=ShortcutInfo(title=Phoneintent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.contacts/.activities.DialtactsActivity }id=8 type=0 container=-101 screen=0 cellX=0 cellY=0 spanX=1 spanY=1 isGesture=false dropPos=null) 03-20 01:08:21.203: D/Launcher.Model(418): going to save icon bitmap for info=ShortcutInfo(title=Browserintent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.browser/.BrowserActivity }id=14 type=0 container=-101 screen=4 cellX=4 cellY=0 spanX=1 spanY=1 isGesture=false dropPos=null) 03-20 01:08:21.293: D/Launcher.Model(418): going to save icon bitmap for info=ShortcutInfo(title=Cameraintent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.camera/.Camera }id=4 type=0 container=-100 screen=2 cellX=0 cellY=3 spanX=1 spanY=1 isGesture=false dropPos=null) 03-20 01:08:21.713: I/PackageManager(163): Running dexopt on: com.example.clearlight 03-20 01:08:22.373: D/EmailProvider(570): Creating EmailProviderBody database 03-20 01:08:22.623: D/dalvikvm(375): GC_CONCURRENT freed 359K, 6% free 8370K/8839K, paused 17ms+45ms, total 174ms 03-20 01:08:22.943: D/EmailProvider(570): Creating EmailProvider database 03-20 01:08:23.623: D/dalvikvm(637): DexOpt: load 310ms, verify+opt 1126ms, 788740 bytes 03-20 01:08:23.833: D/EmailProvider(570): fromDatabase accounts: 0 03-20 01:08:23.844: D/EmailProvider(570): ending toDatabase transaction; copyCount = 0 03-20 01:08:23.873: D/EmailProvider(570): ending fromDatabase transaction; copyCount = 0 03-20 01:08:24.653: I/Email(570): Onetime initialization: completed. 03-20 01:08:24.964: D/dalvikvm(163): GC_CONCURRENT freed 452K, 47% free 10034K/18887K, paused 33ms+15ms, total 129ms 03-20 01:08:24.964: D/PackageManager(163): New package installed in /data/app/com.example.clearlight-1.apk 03-20 01:08:25.804: I/ActivityManager(163): Force stopping package com.example.clearlight uid=10037 03-20 01:08:25.954: W/ResourceType(418): Attempt to retrieve bag 0x7f0d0017 which is invalid or in a cycle. 03-20 01:08:25.954: W/ResourceType(418): Attempt to retrieve bag 0x7f0d0017 which is invalid or in a cycle. 03-20 01:08:25.954: W/ResourceType(418): Attempt to retrieve bag 0x7f0d0017 which is invalid or in a cycle. 03-20 01:08:25.954: W/ResourceType(418): Attempt to retrieve bag 0x7f0d0017 which is invalid or in a cycle. 03-20 01:08:25.954: W/ResourceType(418): Attempt to retrieve bag 0x7f0d0017 which is invalid or in a cycle. 03-20 01:08:26.294: D/AlertService(401): 0 Action = android.intent.action.PROVIDER_CHANGED 03-20 01:08:26.294: D/AlertService(401): Beginning updateAlertNotification 03-20 01:08:26.424: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 0ms 03-20 01:08:26.554: I/AccountTypeManager(501): Loaded meta-data for 1 account types, 0 accounts in 78ms(wall) 5ms(cpu) 03-20 01:08:26.604: I/Choreographer(418): Skipped 1623 frames! The application may be doing too much work on its main thread. 03-20 01:08:26.735: D/PackageManager(163): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged 03-20 01:08:26.754: I/InputReader(163): Reconfiguring input devices. changes=0x00000010 03-20 01:08:26.764: D/PackageManager(163): generateServicesMap(android.content.SyncAdapter): 4 services unchanged 03-20 01:08:26.764: D/BackupManagerService(163): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.clearlight flg=0x8000010 (has extras) } 03-20 01:08:26.984: D/gralloc_goldfish(418): Emulator without GPU emulation detected. 03-20 01:08:26.994: V/BackupManagerService(163): addPackageParticipantsLocked: #1 03-20 01:08:27.124: W/InputMethodManagerService(163): Found no subtypes in a system IME: com.android.inputmethod.pinyin 03-20 01:08:27.205: D/dalvikvm(418): GC_FOR_ALLOC freed 414K, 5% free 10364K/10887K, paused 55ms, total 104ms 03-20 01:08:27.224: I/dalvikvm-heap(418): Grow heap (frag case) to 11.564MB for 1463056-byte allocation 03-20 01:08:27.334: D/dalvikvm(418): GC_FOR_ALLOC freed 30K, 5% free 11763K/12359K, paused 104ms, total 104ms 03-20 01:08:27.434: D/dalvikvm(418): GC_CONCURRENT freed <1K, 5% free 11763K/12359K, paused 17ms+21ms, total 106ms 03-20 01:08:27.564: D/dalvikvm(521): GC_CONCURRENT freed 225K, 4% free 8180K/8455K, paused 955ms+42ms, total 2035ms 03-20 01:08:27.694: E/SQLiteLog(521): (1) no such table: files 03-20 01:08:27.804: D/dalvikvm(163): GC_EXPLICIT freed 548K, 47% free 10010K/18887K, paused 1038ms+24ms, total 1380ms 03-20 01:08:27.804: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 198ms 03-20 01:08:27.814: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 511ms 03-20 01:08:27.814: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 444ms 03-20 01:08:27.824: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 415ms 03-20 01:08:27.834: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 413ms 03-20 01:08:27.834: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 372ms 03-20 01:08:27.834: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 372ms 03-20 01:08:27.834: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 369ms 03-20 01:08:27.844: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 371ms 03-20 01:08:27.844: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 369ms 03-20 01:08:27.844: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 327ms 03-20 01:08:27.844: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 324ms 03-20 01:08:27.944: D/ExchangeService(587): !!! EAS ExchangeService, onStartCommand, startingUp = true, running = false 03-20 01:08:27.944: D/dalvikvm(36): WAIT_FOR_CONCURRENT_GC blocked 0ms 03-20 01:08:27.964: I/ActivityManager(163): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=649 uid=10015 gids={1015, 1028} 03-20 01:08:28.074: D/dalvikvm(36): GC_EXPLICIT freed 37K, 4% free 7964K/8259K, paused 6ms+8ms, total 132ms 03-20 01:08:28.084: D/dalvikvm(36): WAIT_FOR_CONCURRENT_GC blocked 0ms 03-20 01:08:28.174: D/dalvikvm(418): GC_FOR_ALLOC freed 2K, 5% free 11765K/12359K, paused 312ms, total 346ms 03-20 01:08:28.204: D/dalvikvm(36): GC_EXPLICIT freed <1K, 4% free 7964K/8259K, paused 24ms+5ms, total 121ms 03-20 01:08:28.204: I/dalvikvm-heap(418): Grow heap (frag case) to 12.932MB for 1463056-byte allocation 03-20 01:08:28.214: D/dalvikvm(36): WAIT_FOR_CONCURRENT_GC blocked 0ms 03-20 01:08:28.344: E/Trace(649): error opening trace file: No such file or directory (2) 03-20 01:08:28.364: D/dalvikvm(36): GC_EXPLICIT freed <1K, 4% free 7964K/8259K, paused 15ms+5ms, total 145ms 03-20 01:08:28.454: D/dalvikvm(418): GC_CONCURRENT freed <1K, 5% free 13193K/13831K, paused 31ms+8ms, total 243ms 03-20 01:08:28.454: D/dalvikvm(418): WAIT_FOR_CONCURRENT_GC blocked 195ms 03-20 01:08:28.484: I/ActivityThread(649): Pub com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider 03-20 01:08:28.615: D/dalvikvm(163): WAIT_FOR_CONCURRENT_GC blocked 1152ms 03-20 01:08:28.714: I/ActivityManager(163): Displayed com.android.launcher/com.android.launcher2.Launcher: +26s665ms (total
+37s591ms) 03-20 01:08:28.787: I/ARMAssembler(35): generated scanline__00000077:03515104_00009002_00000000 [127 ipp] (149 ins) at [0x4124a4b8:0x4124a70c] in 917426 ns 03-20 01:08:29.199: I/ARMAssembler(35): generated scanline__00000077:03010104_00008002_00000000 [ 89 ipp] (110 ins) at [0x4124a710:0x4124a8c8] in 809441 ns 03-20 01:08:29.394: D/dalvikvm(277): GC_FOR_ALLOC freed 9816K, 53% free 9024K/18887K, paused 702ms, total 748ms 03-20 01:08:29.414: I/dalvikvm-heap(277): Grow heap (frag case) to 15.888MB for 7372816-byte allocation 03-20 01:08:29.584: D/dalvikvm(277): GC_CONCURRENT freed 132K, 15% free 16091K/18887K, paused 50ms+18ms, total 176ms 03-20 01:08:29.864: D/dalvikvm(277): GC_FOR_ALLOC freed <1K, 15% free 16091K/18887K, paused 47ms, total 47ms 03-20 01:08:29.894: I/dalvikvm-heap(277): Grow heap (frag case) to 18.688MB for 3072016-byte allocation 03-20 01:08:30.024: D/dalvikvm(277): GC_CONCURRENT freed 0K, 13% free 19091K/21895K, paused 20ms+19ms, total 126ms 03-20 01:08:30.024: D/dalvikvm(277): WAIT_FOR_CONCURRENT_GC blocked 107ms 03-20 01:08:30.504: D/AndroidRuntime(250): Shutting down VM 03-20 01:08:30.524: D/dalvikvm(250): GC_CONCURRENT freed 97K, 78% free 453K/2048K, paused 1ms+2ms, total 15ms 03-20 01:08:30.524: D/jdwp(250): Got wake-up signal, bailing out of select 03-20 01:08:30.524: D/dalvikvm(250): Debugger has detached; object registry had 1 entries 03-20 01:08:30.534: I/AndroidRuntime(250): NOTE: attach of thread 'Binder_3' failed 03-20 01:08:30.794: I/InputReader(163): Reconfiguring input devices. changes=0x00000010 03-20 01:08:30.844: D/PackageManager(163): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged 03-20 01:08:30.864: I/InputReader(163): Reconfiguring input devices. changes=0x00000010 03-20 01:08:30.894: D/PackageManager(163): generateServicesMap(android.content.SyncAdapter): 4 services unchanged 03-20 01:08:31.024: D/PackageManager(163): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged 03-20 01:08:31.064: D/PackageManager(163): generateServicesMap(android.content.SyncAdapter): 4 services unchanged 03-20 01:08:31.264: I/AccountTypeManager(501): Loaded meta-data for 1 account types, 0 accounts in 30ms(wall) 6ms(cpu) 03-20 01:08:31.294: I/AccountTypeManager(501): Loaded meta-data for 1 account types, 0 accounts in 24ms(wall) 7ms(cpu) 03-20 01:08:31.564: D/AndroidRuntime(668): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 03-20 01:08:31.564: D/AndroidRuntime(668): CheckJNI is ON 03-20 01:08:31.644: D/dalvikvm(668): Trying to load lib libjavacore.so 0x0 03-20 01:08:31.664: D/dalvikvm(668): Added shared lib libjavacore.so 0x0 03-20 01:08:31.734: D/dalvikvm(668): Trying to load lib libnativehelper.so 0x0 03-20 01:08:31.734: D/dalvikvm(668): Added shared lib libnativehelper.so 0x0 03-20 01:08:31.904: D/dalvikvm(163): GC_CONCURRENT freed 404K, 48% free 10005K/18887K, paused 116ms+20ms, total 388ms 03-20 01:08:32.254: D/dalvikvm(501): GC_CONCURRENT freed 203K, 4% free 8205K/8519K, paused 98ms+21ms, total 963ms 03-20 01:08:32.564: D/AlertService(401): No fired or scheduled alerts 03-20 01:08:32.834: D/dalvikvm(469): GC_CONCURRENT freed 232K, 4% free 8181K/8519K, paused 90ms+7ms, total 540ms 03-20 01:08:33.074: I/Choreographer(418): Skipped 1563 frames! The application may be doing too much work on its main thread. 03-20 01:08:33.094: D/AndroidRuntime(668): Calling main entry com.android.commands.am.Am 03-20 01:08:33.164: I/ActivityManager(163): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.clearlight/.HomePage u=0} from pid 668 03-20 01:08:33.214: D/PermissionCache(35): checking android.permission.READ_FRAME_BUFFER for uid=1000 => granted (1103 us) 03-20 01:08:33.224: W/WindowManager(163): Failure taking screenshot for (246x410) to layer 21005 03-20 01:08:33.234: D/AndroidRuntime(668): Shutting down VM 03-20 01:08:33.274: D/dalvikvm(668): GC_CONCURRENT freed 98K, 77% free 483K/2048K, paused 2ms+3ms, total 32ms 03-20 01:08:33.284: I/AndroidRuntime(668): NOTE: attach of thread 'Binder_3' failed 03-20 01:08:33.404: I/ContactDirectoryManager(375): deleted 0 stale rows which don't have any relevant directory 03-20 01:08:33.604: D/dalvikvm(682): Not late-enabling CheckJNI (already on) 03-20 01:08:33.635: I/ActivityManager(163): Start proc com.example.clearlight for activity com.example.clearlight/.HomePage: pid=682 uid=10037 gids={3003, 1028} 03-20 01:08:34.093: E/Trace(682): error opening trace file: No such file or directory (2) 03-20 01:08:34.314: I/ARMAssembler(35): generated scanline__00000077:03515104_00009001_00000000 [131 ipp] (153 ins) at [0x4124a8d0:0x4124ab34] in 736260 ns 03-20 01:08:34.754: D/gralloc_goldfish(682): Emulator without GPU emulation detected. 03-20 01:08:34.824: I/ActivityManager(163): Displayed com.example.clearlight/.HomePage: +1s253ms 03-20 01:08:35.484: I/ContactDirectoryManager(375): Discovered 0 contact directories in 7915ms 03-20 01:08:35.484: I/Launcher(418): setLoadOnResume 03-20 01:08:35.564: I/Launcher(418): setLoadOnResume 03-20 01:08:35.615: W/RecognitionManagerService(163): no available voice recognition services found 03-20 01:08:35.634: I/ContactsDatabaseHelper(375): Switching to locale en_US 03-20 01:08:35.785: D/dalvikvm(418): GREF has increased to 201 03-20 01:08:35.804: I/Launcher(418): setLoadOnResume 03-20 01:08:35.804: I/Launcher(418): setLoadOnResume 03-20 01:08:35.983: W/ActivityManager(163): Permission denied: checkComponentPermission() owningUid=1000 03-20 01:08:35.983: W/BroadcastQueue(163): Permission Denial: broadcasting Intent { act=android.appwidget.action.APPWIDGET_UPDATE_OPTIONS flg=0x10 cmp=com.android.settings/.widget.SettingsAppWidgetProvider (has extras) } from android (pid=418, uid=10014) is not exported from uid 1000 due to receiver com.android.settings/com.android.settings.widget.SettingsAppWidgetProvider 03-20 01:08:36.003: I/Launcher(418): setLoadOnResume 03-20 01:08:36.074: E/WVMExtractor(38): Failed to open libwvm.so 03-20 01:08:36.213: D/dalvikvm(418): GC_CONCURRENT freed 1906K, 14% free 12996K/15047K, paused 36ms+14ms, total 145ms 03-20 01:08:36.613: I/ActivityManager(163): Start proc com.android.quicksearchbox for broadcast com.android.quicksearchbox/.CorporaUpdateReceiver: pid=700 uid=10006 gids={3003, 1028} 03-20 01:08:36.773: E/Trace(700): error opening trace file: No such file or directory (2) 03-20 01:08:36.903: I/ActivityThread(700): Pub com.android.quicksearchbox.google: com.android.quicksearchbox.google.GoogleSuggestionProvider 03-20 01:08:36.993: I/ActivityThread(700): Pub com.android.quicksearchbox.shortcuts: com.android.quicksearchbox.ShortcutsProvider 03-20 01:08:37.363: I/Choreographer(418): Skipped 126 frames! The application may be doing too much work on its main thread. 03-20 01:08:37.373: E/WVMExtractor(38): Failed to open libwvm.so 03-20 01:08:38.434: I/Launcher(418): setLoadOnResume 03-20 01:08:38.454: I/Launcher(418): setLoadOnResume 03-20 01:08:38.543: E/WVMExtractor(38): Failed to open libwvm.so 03-20 01:08:38.603: E/MetadataRetrieverClient(38): failed to extract an album art 03-20 01:08:39.003: D/dalvikvm(375): GC_CONCURRENT freed 387K, 6% free 8414K/8903K, paused 31ms+5ms, total 110ms 03-20 01:08:39.263: I/ContactsDatabaseHelper(375): Locale change completed in 3621ms 03-20 01:08:39.263: I/ContactsDatabaseHelper(375): Switching to locale en_US 03-20 01:08:39.763: I/ContactsDatabaseHelper(375): Locale change completed in 501ms 03-20 01:08:39.773: I/ContactsProvider(375): Upgrading aggregation algorithm 03-20 01:08:39.803: I/ContactAggregator(375): Marked all visible contacts for aggregation: 0 raw contacts, 21 ms 03-20 01:08:39.833: I/ContactsProvider(375): Aggregation algorithm upgraded for 0 raw contacts in 59ms 03-20 01:08:40.263: I/ContactsFTS(375): Rebuild contact search index in 340ms, 0 contacts 03-20 01:08:40.533: D/dalvikvm(375): GC_CONCURRENT freed 447K, 7% free 8413K/8967K, paused 75ms+104ms, total 241ms 03-20 01:08:41.633: I/ActivityManager(163): START {cmp=com.example.clearlight/.MainActivity u=0} from pid 682 03-20 01:08:41.633: W/WindowManager(163): Failure taking screenshot for (246x410) to layer 21010 03-20 01:08:42.063: I/ActivityManager(163): Displayed com.example.clearlight/.MainActivity: +418ms 03-20 01:08:43.843: D/dalvikvm(163): GC_CONCURRENT freed 281K, 47% free 10128K/18887K, paused 123ms+10ms, total 225ms
Related
Unable to fetch a value from the Firestore database. Trying to retrieve the value of the mobile number as and when the value of flat and block matches the entry in the database. Below is the code I am using. I have also attached the issues that are registered in LogCat file. Please check and help.
public class Test extends AppCompatActivity {
Button btn;
private FirebaseFirestore firestore;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
firestore = FirebaseFirestore.getInstance();
btn = (Button) findViewById(R.id.button3);
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
getmobile();
//makecall();
}
});
}
private void makecall(){
Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);
intent.setData(Uri.parse("tel:9890910640"));
startActivity(intent);
}
private void getmobile() {
firestore.collection("users").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
#Override
public void onSuccess(QuerySnapshot documentSnapshots) {
String a = "101";
String b = "F1A";
for(DocumentSnapshot document: documentSnapshots){
if(document.getString("flat")==a&&document.getString("block")==b){
String mobilefromdatabase = document.get("mobile").toString();
Toast.makeText(Test.this, "mobile" + mobilefromdatabase, Toast.LENGTH_LONG).show();
break;
}
}
}
});
}
}
Logcat Details
05-05 03:59:26.721 8805-8805/? E/libprocessgroup: failed to make and chown /acct/uid_10058: Read-only file system
05-05 03:59:26.721 8805-8805/? W/Zygote: createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
05-05 03:59:26.722 8805-8805/? I/art: Not late-enabling -Xcheck:jni (already on)
05-05 03:59:26.770 8805-8805/com.example.myrwaapp I/MultiDex: VM with version 2.1.0 has multidex support
05-05 03:59:26.770 8805-8805/com.example.myrwaapp I/MultiDex: Installing application
05-05 03:59:26.770 8805-8805/com.example.myrwaapp I/MultiDex: VM has multidex support, MultiDex support library is disabled.
05-05 03:59:26.842 8805-8805/com.example.myrwaapp V/FA: Registered activity lifecycle callback
05-05 03:59:26.857 8805-8831/com.example.myrwaapp W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-05 03:59:26.861 8805-8805/com.example.myrwaapp I/FirebaseInitProvider: FirebaseApp initialization successful
05-05 03:59:26.907 8805-8834/com.example.myrwaapp W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
05-05 03:59:26.925 8805-8834/com.example.myrwaapp I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
05-05 03:59:26.986 8805-8805/com.example.myrwaapp W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-05 03:59:27.010 8805-8805/com.example.myrwaapp V/FA: onActivityCreated
05-05 03:59:27.047 8805-8805/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
05-05 03:59:27.047 8805-8805/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
05-05 03:59:27.048 8805-8830/com.example.myrwaapp V/FA: App measurement collection enabled
05-05 03:59:27.049 8805-8830/com.example.myrwaapp V/FA: App measurement enabled for app package, google app id: com.example.myrwaapp, 1:649640616763:android:9025242f82dd4767798d1e
05-05 03:59:27.052 8805-8830/com.example.myrwaapp I/FA: App measurement initialized, version: 21028
05-05 03:59:27.052 8805-8830/com.example.myrwaapp I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
05-05 03:59:27.052 8805-8830/com.example.myrwaapp I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.myrwaapp
05-05 03:59:27.052 8805-8830/com.example.myrwaapp D/FA: Debug-level message logging enabled
05-05 03:59:27.077 8805-8830/com.example.myrwaapp V/FA: Connecting to remote service
05-05 03:59:27.089 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:27.143 8805-8830/com.example.myrwaapp V/FA: Activity resumed, time: 8622127
05-05 03:59:27.145 8805-8830/com.example.myrwaapp I/FA: Tag Manager is not found and thus will not be used
05-05 03:59:27.151 8805-8838/com.example.myrwaapp D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-05 03:59:27.154 8805-8805/com.example.myrwaapp D/Atlas: Validating map...
05-05 03:59:27.159 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:27.159 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:27.188 8805-8838/com.example.myrwaapp I/OpenGLRenderer: Initialized EGL, version 1.4
05-05 03:59:27.188 8805-8838/com.example.myrwaapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
05-05 03:59:27.215 8805-8838/com.example.myrwaapp D/EGL_emulation: eglCreateContext: 0xa2003100: maj 2 min 0 rcv 2
05-05 03:59:27.240 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:27.243 8805-8838/com.example.myrwaapp D/OpenGLRenderer: Enabling debug mode 0
05-05 03:59:27.294 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:27.738 8805-8830/com.example.myrwaapp D/FA: Connected to remote service
05-05 03:59:27.738 8805-8830/com.example.myrwaapp V/FA: Processing queued up service tasks: 4
05-05 03:59:32.795 8805-8830/com.example.myrwaapp V/FA: Inactivity, disconnecting from the service
05-05 03:59:38.884 8805-8830/com.example.myrwaapp V/FA: Recording user engagement, ms: 11740
05-05 03:59:38.886 8805-8830/com.example.myrwaapp V/FA: Connecting to remote service
05-05 03:59:38.892 8805-8830/com.example.myrwaapp V/FA: Activity paused, time: 8633867
05-05 03:59:38.894 8805-8805/com.example.myrwaapp V/FA: onActivityCreated
05-05 03:59:38.913 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:38.913 8805-8830/com.example.myrwaapp V/FA: Activity resumed, time: 8633895
05-05 03:59:38.926 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:38.926 8805-8830/com.example.myrwaapp V/FA: Connection attempt already in progress
05-05 03:59:38.993 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.034 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.051 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.177 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.222 8805-8830/com.example.myrwaapp D/FA: Connected to remote service
05-05 03:59:39.222 8805-8830/com.example.myrwaapp V/FA: Processing queued up service tasks: 4
05-05 03:59:39.224 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:39.335 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:44.247 8805-8830/com.example.myrwaapp V/FA: Inactivity, disconnecting from the service
05-05 03:59:48.704 8805-8838/com.example.myrwaapp D/EGL_emulation: eglMakeCurrent: 0xa2003100: ver 2 0 (tinfo 0xb4233e90)
05-05 03:59:48.871 8805-8849/com.example.myrwaapp W/DynamiteModule: Local module descriptor class for providerinstaller not found.
05-05 03:59:48.877 8805-8849/com.example.myrwaapp I/DynamiteModule: Considering local module providerinstaller:0 and remote module providerinstaller:0
05-05 03:59:48.877 8805-8849/com.example.myrwaapp W/ProviderInstaller: Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
05-05 03:59:48.881 8805-8849/com.example.myrwaapp W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
05-05 03:59:48.881 8805-8849/com.example.myrwaapp W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
05-05 03:59:48.942 8805-8849/com.example.myrwaapp W/linker: libconscrypt_gmscore_jni.so: unused DT entry: type 0x6ffffffe arg 0x13dc
05-05 03:59:48.942 8805-8849/com.example.myrwaapp W/linker: libconscrypt_gmscore_jni.so: unused DT entry: type 0x6fffffff arg 0x2
05-05 03:59:48.948 8805-8849/com.example.myrwaapp V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 284 native methods...
05-05 03:59:48.963 8805-8820/com.example.myrwaapp I/art: Background sticky concurrent mark sweep GC freed 976(49KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 8MB/8MB, paused 5.861ms total 31.265ms
05-05 03:59:48.992 8805-8849/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
05-05 03:59:48.992 8805-8849/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
05-05 03:59:48.992 8805-8849/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
05-05 03:59:48.992 8805-8849/com.example.myrwaapp I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
05-05 03:59:49.002 8805-8849/com.example.myrwaapp I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
First of all, String comparison in Java, should not be performed using == operator, as it will always compare the address of the objects from the memory and not the actual values. String comparison should be done using equals() method.
Moreover, if you need an AND operation, you should not get all documents that exist within the users collection and make the comparison on the client. For that, you should use a query that looks exactly like this:
String a = "101";
String b = "F1A";
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference usersRef = rootRef.collection("users");
Query query = usersRef.whereEqualTo("flat", a).whereEqualTo("block", b);
query.get().addOnSuccessListener(/* ... */);
In this way, you are going to get only the documents where the flat property holds the value of 101 AND the value of block holds F1A. As I think that only one apartment has that constraint, you'll be billed with only one read operation.
I have a phonegap hybrid app with Facebook connect plugin. First time when I login then the FB login works but after I logout and then again try to login via Facebook then the app crashes with the following Logcat results :
Plugin URL :
https://github.com/jeduan/cordova-plugin-facebook4
06-18 21:31:50.071 3129-3219/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9b2370a0
06-18 21:31:50.096 3129-3129/? I/Choreographer: Skipped 39 frames! The application may be doing too much work on its main thread.
06-18 21:31:50.104 3129-3234/? D/EGL_emulation: eglMakeCurrent: 0x9e677300: ver 2 0 (tinfo 0xaa366e80)
06-18 21:31:50.356 3129-3129/? D/CordovaActivity: Incoming Result. Request code = 64206
06-18 21:31:50.356 3129-3129/? D/CordovaInterfaceImpl: Sending activity result to plugin
06-18 21:31:50.356 3129-3129/? D/ConnectPlugin: activity result in plugin: requestCode(64206), resultCode(-1)
06-18 21:31:50.372 3129-3129/? D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
06-18 21:31:50.372 3129-3129/? D/com.facebook.FacebookSdk: getGraphApiVersion: v3.0
06-18 21:31:50.378 3129-3129/? D/CordovaActivity: Resumed the activity.
06-18 21:31:50.379 3129-3129/? W/com.facebook.appevents.AppEventsLogger: activateApp events are being logged automatically. There's no need to call activateApp explicitly, this is safe to remove.
06-18 21:31:50.551 3129-3219/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x98eed520
06-18 21:31:51.043 3129-3129/? D/AndroidRuntime: Shutting down VM
--------- beginning of crash
06-18 21:31:51.044 3129-3129/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sqlchild.app1, PID: 3129
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.indexOf(int)' on a null object reference
at libcore.net.UriCodec.decode(UriCodec.java:153)
at java.net.URLDecoder.decode(URLDecoder.java:60)
at org.apache.cordova.facebook.ConnectPlugin.makeGraphCall(ConnectPlugin.java:751)
at org.apache.cordova.facebook.ConnectPlugin.access$200(ConnectPlugin.java:55)
at org.apache.cordova.facebook.ConnectPlugin$2$1.onCompleted(ConnectPlugin.java:111)
at com.facebook.GraphRequest$1.onCompleted(GraphRequest.java:301)
at com.facebook.GraphRequest$5.run(GraphRequest.java:1380)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-18 21:31:51.052 1667-2063/? W/ActivityManager: Force finishing activity com.sqlchild.app1/.MainActivity
06-18 21:31:51.067 1259-1321/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 589824
[ 06-18 21:31:51.097 1667: 2063 D/ ]
HostConnection::get() New Host Connection established 0x9aa0cc00, tid 2063
[ 06-18 21:31:51.099 1667: 2063 W/ ]
Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1
06-18 21:31:51.113 1259-1259/? E/EGL_emulation: tid 1259: eglCreateSyncKHR(1881): error 0x3004 (EGL_BAD_ATTRIBUTE)
06-18 21:31:51.199 1667-1667/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12502 waiters=0 for 133ms
06-18 21:31:51.289 1667-1677/? I/art: Background partial concurrent mark sweep GC freed 36018(2MB) AllocSpace objects, 1(20KB) LOS objects, 33% free, 7MB/11MB, paused 3.358ms total 105.317ms
06-18 21:31:51.381 1667-1729/? I/OpenGLRenderer: Initialized EGL, version 1.4
06-18 21:31:51.390 1667-1729/? D/EGL_emulation: eglCreateContext: 0xa07fc120: maj 2 min 0 rcv 2
06-18 21:31:51.414 1667-1729/? D/EGL_emulation: eglMakeCurrent: 0xa07fc120: ver 2 0 (tinfo 0xa0ea42f0)
06-18 21:31:51.484 1667-1729/? D/EGL_emulation: eglMakeCurrent: 0xa07fc120: ver 2 0 (tinfo 0xa0ea42f0)
06-18 21:31:51.691 1667-3205/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
06-18 21:31:51.698 1667-1683/? W/ActivityManager: Activity pause timeout for ActivityRecord{21fdafb u0 com.sqlchild.app1/.MainActivity t8 f}
06-18 21:31:51.877 1667-3206/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityStack$ActivityStackHandler.handleMessage(android.os.Message) from ActivityStack.java:283 waiters=0 for 175ms
06-18 21:31:51.896 1667-1683/? I/ActivityManager: Killing 2545:com.android.keychain/1000 (adj 15): empty #17
06-18 21:31:52.070 2029-2239/? D/EGL_emulation: eglMakeCurrent: 0xae594600: ver 2 0 (tinfo 0xae5924b0)
06-18 21:31:59.062 3129-3129/? I/Process: Sending signal. PID: 3129 SIG: 9
06-18 21:31:59.075 1667-1729/? D/EGL_emulation: eglMakeCurrent: 0xa07fc120: ver 2 0 (tinfo 0xa0ea42f0)
06-18 21:31:59.079 1667-1729/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9e8d1360
06-18 21:31:59.128 1667-3206/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 104)
06-18 21:31:59.130 1667-1721/? W/InputDispatcher: channel '7f56d84 com.sqlchild.app1/com.sqlchild.app1.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
06-18 21:31:59.130 1667-1721/? E/InputDispatcher: channel '7f56d84 com.sqlchild.app1/com.sqlchild.app1.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-18 21:31:59.129 1667-3206/? W/InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 3129 uid 10061
06-18 21:31:59.132 1667-1721/? W/InputDispatcher: channel 'e76402c com.sqlchild.app1/com.facebook.FacebookActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
06-18 21:31:59.133 1667-1721/? E/InputDispatcher: channel 'e76402c com.sqlchild.app1/com.facebook.FacebookActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-18 21:31:59.153 1667-3206/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 104)
06-18 21:31:59.168 1667-1680/? I/WindowState: WIN DEATH: Window{e76402c u0 com.sqlchild.app1/com.facebook.FacebookActivity}
06-18 21:31:59.169 1667-1680/? W/InputDispatcher: Attempted to unregister already unregistered input channel 'e76402c com.sqlchild.app1/com.facebook.FacebookActivity (server)'
06-18 21:31:59.174 1667-2280/? D/GraphicsStats: Buffer count: 3
06-18 21:31:59.207 1667-1681/? I/ActivityManager: Process com.sqlchild.app1 (pid 3129) has died
06-18 21:31:59.257 1667-3110/? I/WindowState: WIN DEATH: Window{7f56d84 u0 com.sqlchild.app1/com.sqlchild.app1.MainActivity}
06-18 21:31:59.257 1667-3110/? W/InputDispatcher: Attempted to unregister already unregistered input channel '7f56d84 com.sqlchild.app1/com.sqlchild.app1.MainActivity (server)'
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 3 years ago.
I am executing a very basic task of opening another activity using a button. The code seems to be error-free but the app crashes without even showing the main activity. This happens on both the emulator as well as my device.
When the app has no function, i.e. when the app has just buttons which do nothing, the app works fine. But if I try to make them do anything(intent to open another activity, or to play with their visibility) the app crashes.
The logcat is as follows:
11-12 13:55:56.627 2962-2962/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
11-12 13:55:56.628 2962-2962/? D/AndroidRuntime: CheckJNI is ON
11-12 13:55:56.672 2962-2962/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
11-12 13:55:56.754 2962-2962/? E/memtrack: Couldn't load memtrack module (No such file or directory)
11-12 13:55:56.754 2962-2962/? E/android.os.Debug: failed to load memtrack module: -2
11-12 13:55:56.755 2962-2962/? I/Radio-JNI: register_android_hardware_Radio DONE
11-12 13:55:56.761 2962-2962/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
11-12 13:55:56.772 2962-2962/? I/art: System.exit called, status: 0
11-12 13:55:56.772 2962-2962/? I/AndroidRuntime: VM exiting with result code 0.
11-12 13:55:57.068 2977-2977/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
11-12 13:55:57.069 2977-2977/? D/AndroidRuntime: CheckJNI is ON
11-12 13:55:57.129 2977-2977/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
11-12 13:55:57.199 2977-2977/? E/memtrack: Couldn't load memtrack module (No such file or directory)
11-12 13:55:57.199 2977-2977/? E/android.os.Debug: failed to load memtrack module: -2
11-12 13:55:57.200 2977-2977/? I/Radio-JNI: register_android_hardware_Radio DONE
11-12 13:55:57.205 2977-2977/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
11-12 13:55:57.216 2977-2977/? I/art: System.exit called, status: 0
11-12 13:55:57.220 2977-2977/? I/AndroidRuntime: VM exiting with result code 0.
11-12 13:55:59.484 2987-2987/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
11-12 13:55:59.487 2987-2987/? D/AndroidRuntime: CheckJNI is ON
11-12 13:55:59.522 2987-2987/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
11-12 13:55:59.602 2987-2987/? E/memtrack: Couldn't load memtrack module (No such file or directory)
11-12 13:55:59.602 2987-2987/? E/android.os.Debug: failed to load memtrack module: -2
11-12 13:55:59.603 2987-2987/? I/Radio-JNI: register_android_hardware_Radio DONE
11-12 13:55:59.615 2987-2987/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
11-12 13:55:59.643 2987-2987/? D/AndroidRuntime: Shutting down VM
11-12 13:56:01.407 2999-2999/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
11-12 13:56:01.408 2999-2999/? D/AndroidRuntime: CheckJNI is ON
11-12 13:56:01.465 2999-2999/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
11-12 13:56:01.542 2999-2999/? E/memtrack: Couldn't load memtrack module (No such file or directory)
11-12 13:56:01.542 2999-2999/? E/android.os.Debug: failed to load memtrack module: -2
11-12 13:56:01.543 2999-2999/? I/Radio-JNI: register_android_hardware_Radio DONE
11-12 13:56:01.553 2999-2999/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
--------- beginning of system
11-12 13:56:01.562 1585-1920/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.dell.crash/.MainActivity} from uid 0 on display 0
11-12 13:56:01.579 2147-2341/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_close com.google.android.apps.gsa.speech.audio.u#20f33e2
11-12 13:56:01.605 3007-3007/? I/art: Not late-enabling -Xcheck:jni (already on)
11-12 13:56:01.606 2147-2347/com.google.android.googlequicksearchbox:search I/HotwordRecognitionRnr: Stopping hotword detection.
11-12 13:56:01.606 2147-2699/com.google.android.googlequicksearchbox:search I/HotwordRecognitionRnr: Hotword detection finished
11-12 13:56:01.610 1585-1598/system_process I/ActivityManager: Start proc 3007:com.example.dell.crash/u0a64 for activity com.example.dell.crash/.MainActivity
11-12 13:56:01.604 2999-2999/? D/AndroidRuntime: Shutting down VM
[ 11-12 13:56:01.697 1585: 1608 D/ ]
HostConnection::get() New Host Connection established 0x7f8480e69e40, tid 1608
11-12 13:56:01.728 3007-3007/com.example.dell.crash W/System: ClassLoader referenced unknown path: /data/app/com.example.dell.crash-1/lib/x86_64
11-12 13:56:01.729 3007-3007/com.example.dell.crash I/InstantRun: Instant Run Runtime started. Android package is com.example.dell.crash, real application class is null.
11-12 13:56:02.906 1891-2316/com.google.android.googlequicksearchbox E/Surface: getSlotFromBufferLocked: unknown buffer: 0xe9e5e990
11-12 13:56:03.510 3007-3007/com.example.dell.crash W/System: ClassLoader referenced unknown path: /data/app/com.example.dell.crash-1/lib/x86_64
11-12 13:56:03.707 3007-3007/com.example.dell.crash D/AndroidRuntime: Shutting down VM
--------- beginning of crash
11-12 13:56:03.707 3007-3007/com.example.dell.crash E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dell.crash, PID: 3007
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.dell.crash/com.example.dell.crash.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:116)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50)
at android.support.v7.app.AppCompatDelegateImplV23.<init>(AppCompatDelegateImplV23.java:29)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:199)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)
at android.support.v7.app.AppCompatActivity.findViewById(AppCompatActivity.java:190)
at com.example.dell.crash.MainActivity.<init>(MainActivity.java:10)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-12 13:56:03.708 1585-2055/system_process W/ActivityManager: Force finishing activity com.example.dell.crash/.MainActivity
11-12 13:56:04.016 1585-2055/system_process I/WindowManager: Screenshot max retries 4 of Token{9795bf6 ActivityRecord{989c091 u0 com.example.dell.crash/.MainActivity t51 f}} appWin=Window{a3bf3ce u0 Starting com.example.dell.crash} drawState=4
11-12 13:56:04.116 1585-2485/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
11-12 13:56:04.518 1585-1601/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{989c091 u0 com.example.dell.crash/.MainActivity t51 f}
11-12 13:56:04.550 2328-2336/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/networkstatistics.sqlite' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
11-12 13:56:04.550 2328-2336/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/metrics.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
11-12 13:56:04.551 2328-2336/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/help_responses.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
11-12 13:56:04.572 2328-2336/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/auto_complete_suggestions.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
11-12 13:56:04.860 1585-1602/system_process I/Choreographer: Skipped 35 frames! The application may be doing too much work on its main thread.
11-12 13:56:04.925 2147-3076/com.google.android.googlequicksearchbox:search I/HotwordRecognitionRnr: Starting hotword detection.
11-12 13:56:04.943 2147-3078/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_starting com.google.android.apps.gsa.speech.audio.u#76753fd
11-12 13:56:04.955 1585-1599/system_process I/ActivityManager: Killing 2527:com.android.settings/1000 (adj 15): empty #17
11-12 13:56:04.965 1202-2042/? E/audio_hw_generic: Error opening input stream format 1, channel_mask 0010, sample_rate 16000
11-12 13:56:04.969 1202-3080/? I/AudioFlinger: AudioFlinger's thread 0xf3b80000 ready to run
11-12 13:56:04.988 2147-3078/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_started com.google.android.apps.gsa.speech.audio.u#76753fd
11-12 13:56:04.991 2147-2341/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_close com.google.android.apps.gsa.speech.audio.u#76753fd
11-12 13:56:04.992 2147-3078/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error -4 during AudioRecord native read
11-12 13:56:05.009 2147-2347/com.google.android.googlequicksearchbox:search I/HotwordRecognitionRnr: Stopping hotword detection.
11-12 13:56:05.010 2147-3076/com.google.android.googlequicksearchbox:search I/HotwordRecognitionRnr: Hotword detection finished
11-12 13:56:05.140 1585-1599/system_process I/ActivityManager: Killing 2649:com.android.dialer/u0a4 (adj 15): empty #17
11-12 13:56:05.395 1891-2316/com.google.android.googlequicksearchbox W/OpenGLRenderer: Incorrectly called buildLayer on View: em, destroying layer...
11-12 13:56:05.447 1585-1608/system_process D/gralloc_ranchu: gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread)
11-12 13:56:05.466 2328-2472/com.google.android.gms I/Icing: Usage reports 0 indexed 0 rejected 0 imm upload true
11-12 13:56:05.486 2328-2504/com.google.android.gms I/Icing: Usage reports 0 indexed 0 rejected 0 imm upload true
11-12 13:56:05.499 1585-1920/system_process I/ActivityManager: Killing 2670:com.android.managedprovisioning/u0a8 (adj 15): empty #17
11-12 13:56:15.034 1585-1601/system_process W/ActivityManager: Activity destroy timeout for ActivityRecord{989c091 u0 com.example.dell.crash/.MainActivity t51 f}
11-12 13:56:15.075 2147-3230/com.google.android.googlequicksearchbox:search W/CronetSyncConnectionRcs: Upload content type not set.
11-12 13:56:17.062 3007-3007/com.example.dell.crash I/Process: Sending signal. PID: 3007 SIG: 9
11-12 13:56:17.093 1585-2485/system_process E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f849297e160
11-12 13:56:17.101 1585-2485/system_process D/OpenGLRenderer: endAllStagingAnimators on 0x7f84835bfc00 (RippleDrawable) with handle 0x7f847ee9ee60
11-12 13:56:17.131 1585-1920/system_process W/InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#9d97b24 attribute=null, token = android.os.BinderProxy#32922a9
11-12 13:56:17.165 1585-1920/system_process I/ActivityManager: Process com.example.dell.crash (pid 3007) has died
11-12 13:56:17.367 1585-1608/system_process W/AppOps: Finishing op nesting under-run: uid 1000 pkg android code 24 time=0 duration=0 nesting=0
11-12 13:56:17.409 2147-3268/com.google.android.googlequicksearchbox:search I/HotwordRecognitionRnr: Starting hotword detection.
11-12 13:56:17.413 2147-3269/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_starting com.google.android.apps.gsa.speech.audio.u#898b349
11-12 13:56:17.423 1202-1546/? E/audio_hw_generic: Error opening input stream format 1, channel_mask 0010, sample_rate 16000
11-12 13:56:17.444 1202-3273/? I/AudioFlinger: AudioFlinger's thread 0xf3b80000 ready to run
11-12 13:56:17.449 2147-2157/com.google.android.googlequicksearchbox:search I/art: Background sticky concurrent mark sweep GC freed 1466(93KB) AllocSpace objects, 0(0B) LOS objects, 9% free, 4MB/4MB, paused 25.294ms total 31.038ms
11-12 13:56:17.456 2147-3269/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_started com.google.android.apps.gsa.speech.audio.u#898b349
11-12 13:56:17.493 2147-2147/com.google.android.googlequicksearchbox:search I/HotwordWorker: onReady
11-12 13:56:17.504 2328-3272/com.google.android.gms W/IcingInternalCorpora: getNumBytesRead when not calculated.
11-12 13:56:17.564 2328-2472/com.google.android.gms I/Icing: Usage reports 0 indexed 0 rejected 0 imm upload true
11-12 13:56:17.571 2328-2472/com.google.android.gms I/Icing: Usage reports 0 indexed 0 rejected 0 imm upload true
11-12 13:56:18.155 1202-1544/? W/AudioFlinger: write blocked for 408 msecs, 4 delayed writes, thread 0xf4500000
The .java file has the following block:
public class MainActivity extends AppCompatActivity {
Button btn1 = (Button) findViewById(R.id.button);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, Main2Activity.class));
}
});
}
}
The XML file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.dell.crash.MainActivity">
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="102dp"
android:id="#+id/button" />
</RelativeLayout>
I am using Android Studio 2.2.2
After
setContentView(R.layout.activity_main);
Add call like this
Button button = (Button) findViewById(R.id.button);
issue was you didn't created reference for button.
put Button btn1 = (Button) findViewById(R.id.button); in oncreate method.
The reason is you try add an event to your button but didn't show the reference id inside oncreate from where every app start its activity.
You should always instantiate button inside onCreate(). So your code should be like
public class MainActivity extends AppCompatActivity {
Button btn1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1 = (Button) findViewById(R.id.button);
btn1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, Main2Activity.class));
}
});
}
}
If you init your btn1 variable in declarations section, it will run before the setContextView(...) function call. Put btn1 initialization after setContextView(...)!
public class MainActivity extends AppCompatActivity {
private Button btn1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1 = Button.class.cast(findViewById(R.id.button));
btn1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, Main2Activity.class));
}
});
}
}
I am developing an Titanium Module for Android. I add a customised menu xml "context_menu.xml" to it by placing it in folder /platform/android/res/menu/ in the Module Project.
It can successfully packaged but when include the module in another Mobile Project, it always raise an error during build:
[ERROR] Unable to find generated R.java file
Here is the context_menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/acion_highlight"
android:title="#string/highlight"
android:showAsAction="always"/>
<item android:id="#+id/action_addNote"
android:title="#string/addNote"
android:showAsAction="always"/>
</menu>
So what's wrong??
[EDITED: Add logs in logcat]
05-09 04:47:47.476: D/AndroidRuntime(1120): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
05-09 04:47:47.476: D/AndroidRuntime(1120): CheckJNI is OFF
05-09 04:47:47.476: D/dalvikvm(1120): Unable to stat classpath element '/system/framework/filterfw.jar'
05-09 04:47:47.480: D/dalvikvm(1120): Trying to load lib libjavacore.so 0x0
05-09 04:47:47.480: D/dalvikvm(1120): Added shared lib libjavacore.so 0x0
05-09 04:47:47.484: D/dalvikvm(1120): Trying to load lib libnativehelper.so 0x0
05-09 04:47:47.488: D/dalvikvm(1120): Added shared lib libnativehelper.so 0x0
05-09 04:47:47.528: D/AndroidRuntime(1120): Calling main entry com.android.commands.pm.Pm
05-09 04:47:47.528: W/ActivityManager(324): No content provider found for permission revoke: file:///data/local/tmp/MyApp.apk
05-09 04:47:47.680: W/ActivityManager(324): No content provider found for permission revoke: file:///data/local/tmp/MyApp.apk
05-09 04:47:47.724: D/dalvikvm(324): GC_CONCURRENT freed 465K, 18% free 12077K/14663K, paused 11ms+1ms, total 27ms
05-09 04:47:47.724: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 1ms
05-09 04:47:47.740: D/dalvikvm(324): GC_FOR_ALLOC freed 347K, 20% free 11856K/14663K, paused 13ms, total 13ms
05-09 04:47:47.748: D/dalvikvm(324): GC_FOR_ALLOC freed 180K, 19% free 11899K/14663K, paused 11ms, total 11ms
05-09 04:47:47.768: D/dalvikvm(324): GC_FOR_ALLOC freed 62K, 19% free 11963K/14663K, paused 11ms, total 11ms
05-09 04:47:47.768: I/dalvikvm-heap(324): Grow heap (frag case) to 11.822MB for 109405-byte allocation
05-09 04:47:47.772: D/dalvikvm(324): GC_FOR_ALLOC freed 127K, 20% free 11943K/14791K, paused 12ms, total 12ms
05-09 04:47:47.840: D/dalvikvm(324): GC_CONCURRENT freed 407K, 16% free 12462K/14791K, paused 11ms+1ms, total 25ms
05-09 04:47:47.912: D/dalvikvm(324): GC_CONCURRENT freed 912K, 15% free 12688K/14791K, paused 11ms+1ms, total 27ms
05-09 04:47:47.912: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 6ms
05-09 04:47:48.040: D/dalvikvm(324): GC_CONCURRENT freed 1171K, 15% free 12711K/14791K, paused 12ms+1ms, total 38ms
05-09 04:47:48.040: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 14ms
05-09 04:47:48.092: D/dalvikvm(324): GC_CONCURRENT freed 1191K, 15% free 12716K/14791K, paused 11ms+2ms, total 30ms
05-09 04:47:48.092: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 8ms
05-09 04:47:48.156: D/dalvikvm(324): GC_CONCURRENT freed 1072K, 14% free 12723K/14791K, paused 11ms+2ms, total 27ms
05-09 04:47:48.312: D/dalvikvm(324): GC_CONCURRENT freed 1189K, 14% free 12737K/14791K, paused 11ms+1ms, total 25ms
05-09 04:47:48.320: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 3ms
05-09 04:47:48.532: D/dalvikvm(324): GC_CONCURRENT freed 1132K, 14% free 12752K/14791K, paused 11ms+12ms, total 40ms
05-09 04:47:48.796: D/dalvikvm(324): GC_CONCURRENT freed 1154K, 14% free 12753K/14791K, paused 11ms+1ms, total 33ms
05-09 04:47:48.928: D/dalvikvm(324): GC_CONCURRENT freed 1093K, 14% free 12766K/14791K, paused 11ms+1ms, total 29ms
05-09 04:47:49.252: I/PackageManager(324): Removing non-system package:hk.edu.ouhk.MyApp
05-09 04:47:49.252: I/ActivityManager(324): Force stopping package hk.edu.ouhk.MyApp uid=10047
05-09 04:47:49.312: I/PackageManager(324): Package hk.edu.ouhk.MyApp codePath changed from /data/app/hk.edu.ouhk.MyApp-1.apk to /data/app/hk.edu.ouhk.MyApp-2.apk; Retaining data and using new
05-09 04:47:49.332: I/PackageManager(324): Running dexopt on: hk.edu.ouhk.MyApp
05-09 04:47:49.364: D/dalvikvm(1130): Unable to stat classpath element '/system/framework/filterfw.jar'
05-09 04:47:49.408: D/dalvikvm(1130): DexOpt: 'Lorg/apache/commons/codec/binary/Base64;' has an earlier definition; blocking out
05-09 04:47:49.408: D/dalvikvm(1130): DexOpt: 'Lorg/apache/commons/codec/binary/Hex;' has an earlier definition; blocking out
05-09 04:47:49.416: D/dalvikvm(1130): DexOpt: 'Lorg/w3c/dom/UserDataHandler;' has an earlier definition; blocking out
05-09 04:47:49.488: D/dalvikvm(1130): DexOpt: not verifying/optimizing 'Lorg/apache/commons/codec/binary/Base64;': multiple definitions
05-09 04:47:49.492: D/dalvikvm(1130): DexOpt: not verifying/optimizing 'Lorg/apache/commons/codec/binary/Hex;': multiple definitions
05-09 04:47:49.492: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Hex;'
05-09 04:47:49.520: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Base64;'
05-09 04:47:49.520: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Base64;'
05-09 04:47:49.556: D/dalvikvm(1130): DexOpt: not verifying/optimizing 'Lorg/w3c/dom/UserDataHandler;': multiple definitions
05-09 04:47:49.576: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Hex;'
05-09 04:47:49.612: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Base64;'
05-09 04:47:49.616: D/dalvikvm(1130): DexOpt: load 35ms, verify+opt 186ms, 2392724 bytes
05-09 04:47:49.628: I/ActivityManager(324): Force stopping package hk.edu.ouhk.MyApp uid=10047
05-09 04:47:49.628: W/PackageManager(324): Code path for pkg : hk.edu.ouhk.MyApp changing from /data/app/hk.edu.ouhk.MyApp-1.apk to /data/app/hk.edu.ouhk.MyApp-2.apk
05-09 04:47:49.628: W/PackageManager(324): Resource path for pkg : hk.edu.ouhk.MyApp changing from /data/app/hk.edu.ouhk.MyApp-1.apk to /data/app/hk.edu.ouhk.MyApp-2.apk
05-09 04:47:49.644: D/PackageManager(324): New package installed in /data/app/hk.edu.ouhk.MyApp-2.apk
05-09 04:47:49.656: D/dalvikvm(586): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-09 04:47:49.656: I/ActivityManager(324): Force stopping package hk.edu.ouhk.MyApp uid=10047
05-09 04:47:49.664: D/dalvikvm(586): GC_EXPLICIT freed 135K, 5% free 8223K/8583K, paused 1ms+1ms, total 8ms
05-09 04:47:49.668: D/dalvikvm(529): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-09 04:47:49.676: D/dalvikvm(529): GC_EXPLICIT freed 447K, 7% free 10264K/10951K, paused 0ms+1ms, total 9ms
05-09 04:47:49.680: D/PackageManager(324): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged
05-09 04:47:49.680: D/PackageManager(324): generateServicesMap(android.content.SyncAdapter): 4 services unchanged
05-09 04:47:49.680: D/BackupManagerService(324): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:hk.edu.ouhk.MyApp flg=0x8000010 (has extras) }
05-09 04:47:49.688: I/InputReader(324): Reconfiguring input devices. changes=0x00000010
05-09 04:47:49.688: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-09 04:47:49.716: D/dalvikvm(324): GC_EXPLICIT freed 692K, 14% free 12743K/14791K, paused 11ms+4ms, total 30ms
05-09 04:47:49.720: D/PackageManager(324): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged
05-09 04:47:49.720: D/PackageManager(324): generateServicesMap(android.content.SyncAdapter): 4 services unchanged
05-09 04:47:49.720: D/BackupManagerService(324): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:hk.edu.ouhk.MyApp flg=0x8000010 (has extras) }
05-09 04:47:49.720: V/BackupManagerService(324): removePackageParticipantsLocked: uid=10047 #1
05-09 04:47:49.732: I/InputReader(324): Reconfiguring input devices. changes=0x00000010
05-09 04:47:49.740: V/BackupManagerService(324): addPackageParticipantsLocked: #1
05-09 04:47:49.756: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-09 04:47:49.776: W/ResourceType(324): Failure getting entry for 0x7f060000 (t=5 e=0) in package 0 (error -75)
05-09 04:47:49.776: W/ResourceType(324): Failure getting entry for 0x7f060000 (t=5 e=0) in package 0 (error -75)
05-09 04:47:49.776: W/InputMethodManagerService(324): Found no subtypes in a system IME: com.android.inputmethod.pinyin
05-09 04:47:49.776: W/RecognitionManagerService(324): no available voice recognition services found
05-09 04:47:49.804: D/dalvikvm(324): GC_EXPLICIT freed 1821K, 23% free 11414K/14791K, paused 1ms+2ms, total 50ms
05-09 04:47:49.808: D/AndroidRuntime(1120): Shutting down VM
05-09 04:47:49.808: D/dalvikvm(1120): GC_CONCURRENT freed 99K, 78% free 450K/2048K, paused 0ms+0ms, total 1ms
05-09 04:47:49.808: D/jdwp(1120): Got wake-up signal, bailing out of select
05-09 04:47:49.808: D/dalvikvm(1120): Debugger has detached; object registry had 1 entries
05-09 04:47:49.808: I/AndroidRuntime(1120): NOTE: attach of thread 'Binder_3' failed
05-09 04:47:49.812: D/OpenGLRenderer(529): TextureCache::callback: name, removed size, mSize = 137, 32256, 1218792
05-09 04:47:49.812: D/OpenGLRenderer(529): TextureCache::get: create texture(0xb818d7a8): name, size, mSize = 143, 32256, 1251048
Problem solved.
Root cause is required xml is not properly defined. The "context_menu.xml" is referring to the string definition "action_highlight" and "action_addNote" which I haven't included in res/values/strings.xml
Hope it help someone new to Android development too.
I am trying to basically load a map using Google maps api v2 so i can start working on a more complex application.
My problem is that i followed all the instructions in:
https://developers.google.com/maps/documentation/android/
to setup the new settings for the google map api v2 that uses Google play lib.
Everything is set up fine but when i run the application it crashes(myapp stoped working)
I am using intellij so the applications was signed through "build|Generate signed apk" and to get my SHA1 code i used the file that is generated when the Generate signed apk is selected. I created a new project in Google console named MapTest to get the api key and placed that in the manifest as specified.
Now i know that the emulators usually are missing some staff such as the openGL ES so i installed the app on my phone (Galaxy s2) and the application is still crashing.
ps the google play lib was added
Emulator is google api 15 and everything is updated to latest versions.
Any help or input is deeply appreciated.
Bellow i am including my xml files so you can see if there is anything wrong.
main xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<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"/>
</LinearLayout>
AndroidManifest xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.MapTest"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:targetSdkVersion="15" android:minSdkVersion="8"/>
<application android:label="#string/app_name" android:icon="#drawable/ic_launcher">
<uses-library android:name="com.google.android.maps"/>
<activity android:name="MyActivity"
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 api key goes here"/>
</application>
<permission
android:name="com.example.MapTest.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.MapTest.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
</manifest>
MyActivity class
nothing really change tho included just in case
package com.example.MapTest;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.MapFragment;
public class MyActivity extends Activity {
/**
* Called when the activity is first created.
*/
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
the log of the emulator
01-09 22:16:54.269: DEBUG/AndroidRuntime(1779): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
01-09 22:16:54.269: DEBUG/AndroidRuntime(1779): CheckJNI is ON
01-09 22:16:55.766: DEBUG/AndroidRuntime(1779): Calling main entry com.android.commands.pm.Pm
01-09 22:16:56.059: DEBUG/dalvikvm(1031): GC_EXPLICIT freed 416K, 15% free 11721K/13703K, paused 9ms+19ms
01-09 22:16:56.099: WARN/ActivityManager(1031): No content provider found for permission revoke: file:///data/local/tmp/com.example.MapTest
01-09 22:16:56.139: WARN/ActivityManager(1031): No content provider found for permission revoke: file:///data/local/tmp/com.example.MapTest
01-09 22:16:56.379: INFO/PackageManager(1031): Removing non-system package:com.example.MapTest
01-09 22:16:56.379: INFO/ActivityManager(1031): Force stopping package com.example.MapTest uid=10044
01-09 22:16:56.529: INFO/PackageManager(1031): Package com.example.MapTest codePath changed from /data/app/com.example.MapTest-2.apk to /data/app/com.example.MapTest-1.apk; Retaining data and using new
01-09 22:16:56.529: INFO/PackageManager(1031): Running dexopt on: com.example.MapTest
01-09 22:16:57.781: DEBUG/dalvikvm(1790): DexOpt: load 230ms, verify+opt 493ms
01-09 22:16:57.809: WARN/PackageManager(1031): Code path for pkg : com.example.MapTest changing from /data/app/com.example.MapTest-2.apk to /data/app/com.example.MapTest-1.apk
01-09 22:16:57.809: WARN/PackageManager(1031): Resource path for pkg : com.example.MapTest changing from /data/app/com.example.MapTest-2.apk to /data/app/com.example.MapTest-1.apk
01-09 22:16:57.829: INFO/ActivityManager(1031): Force stopping package com.example.MapTest uid=10044
01-09 22:16:57.939: DEBUG/PackageManager(1031): New package installed in /data/app/com.example.MapTest-1.apk
01-09 22:16:57.949: WARN/PackageManager(1031): Unknown permission android.permission.ADD_SYSTEM_SERVICE in package com.android.phone
01-09 22:16:57.949: WARN/PackageManager(1031): Unknown permission com.android.smspush.WAPPUSH_MANAGER_BIND in package com.android.phone
01-09 22:16:57.959: WARN/PackageManager(1031): Unknown permission com.android.vending.billing.BILLING_ACCOUNT_SERVICE in package com.google.android.gsf.login
01-09 22:16:57.959: WARN/PackageManager(1031): Unknown permission com.android.vending.billing.ADD_CREDIT_CARD in package com.google.android.gsf.login
01-09 22:16:57.959: WARN/PackageManager(1031): Unknown permission com.android.vending.billing.IBillingAccountService.BIND2 in package com.google.android.gsf.login
01-09 22:16:57.959: WARN/PackageManager(1031): Not granting permission android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS to package com.android.browser (protectionLevel=2 flags=0x9be45)
01-09 22:16:57.959: WARN/PackageManager(1031): Not granting permission android.permission.BIND_APPWIDGET to package com.android.widgetpreview (protectionLevel=3 flags=0x28be44)
01-09 22:16:57.989: WARN/PackageManager(1031): Unknown permission com.android.providers.im.permission.READ_ONLY in package com.google.android.apps.maps
01-09 22:16:57.989: WARN/PackageManager(1031): Not granting permission android.permission.DEVICE_POWER to package com.android.deskclock (protectionLevel=2 flags=0x8be45)
01-09 22:16:58.299: DEBUG/dalvikvm(1031): GC_CONCURRENT freed 544K, 15% free 11758K/13703K, paused 9ms+12ms
01-09 22:16:58.489: INFO/ActivityManager(1031): Force stopping package com.example.MapTest uid=10044
01-09 22:16:58.639: DEBUG/dalvikvm(1126): GC_EXPLICIT freed 250K, 7% free 11414K/12231K, paused 5ms+7ms
01-09 22:16:58.869: DEBUG/dalvikvm(1166): GC_EXPLICIT freed 172K, 4% free 9398K/9735K, paused 10ms+9ms
01-09 22:16:59.159: DEBUG/dalvikvm(1031): GC_EXPLICIT freed 191K, 15% free 11704K/13703K, paused 7ms+14ms
01-09 22:16:59.259: DEBUG/PackageManager(1031): generateServicesMap(android.accounts.AccountAuthenticator): 3 services unchanged
01-09 22:16:59.409: DEBUG/PackageManager(1031): generateServicesMap(android.content.SyncAdapter): 5 services unchanged
01-09 22:16:59.431: DEBUG/BackupManagerService(1031): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.MapTest flg=0x10000010 (has extras) }
01-09 22:16:59.459: DEBUG/PackageManager(1031): generateServicesMap(android.accounts.AccountAuthenticator): 3 services unchanged
01-09 22:16:59.479: DEBUG/PackageManager(1031): generateServicesMap(android.content.SyncAdapter): 5 services unchanged
01-09 22:16:59.599: DEBUG/BackupManagerService(1031): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.MapTest flg=0x10000010 (has extras) }
01-09 22:16:59.629: VERBOSE/BackupManagerService(1031): updatePackageParticipantsLocked: #1
01-09 22:17:00.642: WARN/RecognitionManagerService(1031): no available voice recognition services found
01-09 22:17:00.889: DEBUG/BackupManagerService(1031): Received broadcast Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.example.MapTest flg=0x10000010 (has extras) }
01-09 22:17:00.889: VERBOSE/BackupManagerService(1031): updatePackageParticipantsLocked: #1
01-09 22:17:01.519: DEBUG/dalvikvm(1031): GC_EXPLICIT freed 528K, 14% free 11847K/13703K, paused 7ms+17ms
01-09 22:17:02.069: DEBUG/AndroidRuntime(1779): Shutting down VM
01-09 22:17:02.089: INFO/AndroidRuntime(1779): NOTE: attach of thread 'Binder Thread #3' failed
01-09 22:17:02.089: DEBUG/dalvikvm(1779): GC_CONCURRENT freed 101K, 78% free 456K/2048K, paused 2ms+4ms
01-09 22:17:02.099: DEBUG/jdwp(1779): Got wake-up signal, bailing out of select
01-09 22:17:02.099: DEBUG/dalvikvm(1779): Debugger has detached; object registry had 1 entries
01-09 22:17:02.789: DEBUG/AndroidRuntime(1795): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
01-09 22:17:02.789: DEBUG/AndroidRuntime(1795): CheckJNI is ON
01-09 22:17:03.949: DEBUG/AndroidRuntime(1795): Calling main entry com.android.commands.am.Am
01-09 22:17:03.989: INFO/ActivityManager(1031): START {flg=0x10000000 cmp=com.example.MapTest/.MyActivity} from pid 1795
01-09 22:17:04.029: WARN/WindowManager(1031): Failure taking screenshot for (180x300) to layer 21005
01-09 22:17:04.111: DEBUG/AndroidRuntime(1795): Shutting down VM
01-09 22:17:04.139: DEBUG/dalvikvm(1806): Not late-enabling CheckJNI (already on)
01-09 22:17:04.139: INFO/AndroidRuntime(1795): NOTE: attach of thread 'Binder Thread #3' failed
01-09 22:17:04.159: DEBUG/dalvikvm(1795): GC_CONCURRENT freed 101K, 77% free 486K/2048K, paused 1ms+5ms
01-09 22:17:04.159: DEBUG/jdwp(1795): Got wake-up signal, bailing out of select
01-09 22:17:04.159: DEBUG/dalvikvm(1795): Debugger has detached; object registry had 1 entries
01-09 22:17:04.209: INFO/ActivityManager(1031): Start proc com.example.MapTest for activity com.example.MapTest/.MyActivity: pid=1806 uid=10044 gids={3003, 1015}
01-09 22:17:04.649: WARN/NetworkManagementSocketTagger(1031): setKernelCountSet(10044, 1) failed with errno -2
01-09 22:17:05.269: INFO/Process(1031): Sending signal. PID: 1806 SIG: 3
01-09 22:17:05.309: INFO/dalvikvm(1806): threadid=3: reacting to signal 3
01-09 22:17:05.429: INFO/dalvikvm(1806): Wrote stack traces to '/data/anr/traces.txt'
01-09 22:17:05.599: WARN/dalvikvm(1806): VFY: unable to resolve static field 40 (MapAttrs) in Lcom/google/android/gms/R$styleable;
01-09 22:17:05.599: DEBUG/dalvikvm(1806): VFY: replacing opcode 0x62 at 0x000e
01-09 22:17:05.609: DEBUG/AndroidRuntime(1806): Shutting down VM
01-09 22:17:05.609: WARN/dalvikvm(1806): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-09 22:17:05.629: ERROR/AndroidRuntime(1806): FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
at android.app.Activity.onCreateView(Activity.java:4242)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
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 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
at android.app.Activity.setContentView(Activity.java:1835)
at com.example.MapTest.MyActivity.onCreate(MyActivity.java:13)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
01-09 22:17:05.649: WARN/ActivityManager(1031): Force finishing activity com.example.MapTest/.MyActivity
01-09 22:17:05.659: WARN/WindowManager(1031): Failure taking screenshot for (180x300) to layer 21010
01-09 22:17:05.680: INFO/Process(1031): Sending signal. PID: 1806 SIG: 3
01-09 22:17:05.680: INFO/dalvikvm(1806): threadid=3: reacting to signal 3
01-09 22:17:05.699: INFO/dalvikvm(1806): Wrote stack traces to '/data/anr/traces.txt'
01-09 22:17:06.169: WARN/ActivityManager(1031): Activity pause timeout for ActivityRecord{4146dc60 com.example.MapTest/.MyActivity}
01-09 22:17:06.209: INFO/Process(1031): Sending signal. PID: 1806 SIG: 3
01-09 22:17:06.209: INFO/dalvikvm(1806): threadid=3: reacting to signal 3
01-09 22:17:06.229: INFO/dalvikvm(1806): Wrote stack traces to '/data/anr/traces.txt'
01-09 22:17:06.589: WARN/NetworkManagementSocketTagger(1031): setKernelCountSet(10044, 0) failed with errno -2
01-09 22:17:07.899: INFO/Process(1806): Sending signal. PID: 1806 SIG: 9
01-09 22:17:07.919: INFO/ActivityManager(1031): Process com.example.MapTest (pid 1806) has died.
01-09 22:17:08.109: WARN/InputManagerService(1031): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#414b9608
At the moment it is not possible to run Google Android Maps v2 on emulator (see response from Android devs here). You should use real device instead.
However, you can look for updates in this thread - looks like someone managed to create emulator which supports Google Android Maps v2
EDIT:
I can see some problem in your code:
You should extend android.support.v4.app.FragmentActivity, but not regular Activity class.
Also make sure you have added GooglePlayServices project (actually imported entire project) but not just a jar file. If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
I finally fixed the problem. Google has a very bad tutorial. First of all thank you Pavel Dudka for the big help.
i imported google play lib as module and then google play lib as jar then i also added onother jar file android.suport.v4.jar were is can be found as the name is exmaple android\suppor\v4
After those modifications and with the recomentations the map did not work so i added the modified fragment bellow instead of using the one google provited and the map worked like a charm.
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="match_parent" />