VorteXavier VorteXavier - 26 days ago 11
Android Question

Android app using google maps not working on phone

I'm developing an application which uses a map. I use my galaxy nexus to test the app but after I included the code related to the map it stopped working on my phone but it still works on the emulator. The problem is that the emulator doesnt show the map because it doesnt have Google Play Services.

When I try to launch the app I get no error but my phone does nothing, and if I try to run it manually from the app drawer the app is there but it says "isn't installed".

Here is the java code MainActivity.java

package myPackage.android;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import com.actionbarsherlock.view.*;

public class MainActivity extends SherlockFragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//private GoogleMap map;

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getSupportMenuInflater().inflate(R.menu.main, menu);
return true;
}

public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;

case R.id.action_search:
final int RESULT=1;
startActivityForResult(new Intent(MainActivity.this, SearchForm.class), RESULT);
return true;
}
return super.onOptionsItemSelected(item);
}

}


Here's the xml layout activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.SupportMapFragment" />


and the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=myPackage.android"
android:versionCode="1"
android:versionName="1.0" >

<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<permission
android:name="myPackage.android.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="myPackage.android.permission.MAPS_RECEIVE"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar" >

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my ap map key"/>


<activity
android:name="myPackage.android.SplashScreen"
android:label="@string/app_name"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:permission="android.permission.INTERNET" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name="myPackage.android.MainActivity"
android:label=""
android:logo="@drawable/logo"
android:screenOrientation="portrait"
android:permission="android.permission.INTERNET" >
</activity>

<activity
android:name="myPackage.android.SearchForm"
android:label="@string/title_activity_search_form"
android:parentActivityName="ar.com.package.android.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="myPackage.android.MainActivity" />
</activity>

</application>

</manifest>


logCat

05-09 21:17:04.744: D/AndroidRuntime(15507): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
05-09 21:17:04.744: D/AndroidRuntime(15507): CheckJNI is OFF
05-09 21:17:04.752: D/dalvikvm(15507): Trying to load lib libjavacore.so 0x0
05-09 21:17:04.760: D/dalvikvm(15507): Added shared lib libjavacore.so 0x0
05-09 21:17:04.768: D/dalvikvm(15507): Trying to load lib libnativehelper.so 0x0
05-09 21:17:04.768: D/dalvikvm(15507): Added shared lib libnativehelper.so 0x0
05-09 21:17:04.908: D/AndroidRuntime(15507): Calling main entry com.android.commands.pm.Pm
05-09 21:17:04.916: D/AndroidRuntime(15507): Shutting down VM
05-09 21:17:04.916: D/dalvikvm(15507): GC_CONCURRENT freed 97K, 18% free 482K/584K, paused 1ms+0ms, total 4ms
05-09 21:17:04.924: D/jdwp(15507): Got wake-up signal, bailing out of select
05-09 21:17:04.924: D/dalvikvm(15507): Debugger has detached; object registry had 1 entries
05-09 21:17:05.314: D/AndroidRuntime(15519): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
05-09 21:17:05.314: D/AndroidRuntime(15519): CheckJNI is OFF
05-09 21:17:05.330: D/dalvikvm(15519): Trying to load lib libjavacore.so 0x0
05-09 21:17:05.330: D/dalvikvm(15519): Added shared lib libjavacore.so 0x0
05-09 21:17:05.338: D/dalvikvm(15519): Trying to load lib libnativehelper.so 0x0
05-09 21:17:05.338: D/dalvikvm(15519): Added shared lib libnativehelper.so 0x0
05-09 21:17:05.486: D/AndroidRuntime(15519): Calling main entry com.android.commands.am.Am
05-09 21:17:05.494: D/dalvikvm(15519): Note: class Landroid/app/ActivityManagerNative; has 157 unimplemented (abstract) methods
05-09 21:17:05.502: I/ActivityManager(407): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=myPackage.android/.SplashScreen} from pid 15519
05-09 21:17:05.502: I/AndroidRuntime(15519): VM exiting with result code 1.
05-09 21:17:05.502: W/ActivityManager(407): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=myPackage.android/.SplashScreen } from null (pid=15519, uid=2000) requires android.permission.INTERNET

Answer

Well, I figured it out; i didnt have to use the android:permission atribute under the activities in the manifest. After deleting that the app works just fine.