getting error while integrating map in android application - java

I want to integrate map in my android application. I have generated key through sh1 and using package name. but when I use map activity then it will give error. I have also installed google play service. but it cannot resolve on map callback activity.
It does not support even android:name in xml file
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney, Australia, and move the camera.
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
And My Manifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAz-m0JHQmk0qqairiEkkKFaiccgzTxb10"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Your Manifest file has should be like this.
Source click here!
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="com.example.user.myapplication.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<permission
android:name="com.example.user.myapplication.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.
WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.
ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.googlemaps.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDKymeBXNeiFWY5jRUejv6zItpmr2MVyQ0" />
</application>
</manifest>

There is a problem in your manifest file. <uses-permssion> tag comes out side of the <application> tag.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.myapplication" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAz-m0JHQmk0qqairiEkkKFaiccgzTxb10"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.myapplication" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your key"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Related

ant build error: package r does not exist

I got this error message when running from command line:
[javac]E:\...\MainActivity.java:19: Error: Package R does not exist
[javac] setContentView(R.layout.activity_main);
I have added import com.***.R; to file MainActivity.java.
Here is the xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.***">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:persistent="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".JmfService"
android:enabled="true"/>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DELETE_PACKAGES"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.intent.action.MEDIA_SCANNER_SCAN_DIR" />
</manifest>
I've tried ant clean, rebuild project and so on.
When clicking on the menu button to build the project, i got BUILD SUCCESSFUL.

ActivityNotFoundException: but activity has been declared in manifest

hoping for some help. I am receiving an error:
04-13 15:01:45.336: E/AndroidRuntime(11065):
android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity};
have you declared this activity in your AndroidManifest.xml?
...
However I have declared said class RunActivity in the manifest. However, I notice that the path is not correct, it should be calling com.domakecreatedesign.runtracker.RunActivity, however as you can see from above, it is making a call for: com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity...
I have no idea why this is.
Here is my my manifest xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domakecreatedesign.getfit"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<permission
android:name="com.domakecreatedesign.getfit.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.domakecreatedesign.getfit.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<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-permission
android:name="android.permission.GET_ACCOUNTS"
android:maxSdkVersion="19" />
<uses-permission
android:name="android.permission.USE_CREDENTIALS"
android:maxSdkVersion="19" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="true" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/getfit_icon"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- Splash screen -->
<activity
android:name="com.domakecreatedesign.getfit.SplashScreen"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main Activity -->
<activity
android:name="com.domakecreatedesign.getfit.MainActivity"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.getfit.ChooseLogin"
android:label="#string/title_activity_fblogin" />
<activity
android:name="com.domakecreatedesign.getfit.gplus_Login"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.getfit.Main_Menu"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunListActivity"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunMapActivity"
android:label="#string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunActivity"
android:label="#string/app_name" />
<receiver
android:name=".TrackingLocationReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.domakecreatedesign.runtracker.ACTION_LOCATION" />
</intent-filter>
</receiver>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyATK_V5Ae2g7uJQM1EBhEcPZAL19B8jBuc" />
</application>
</manifest>
And the calling method is:
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
// the id argument will be the Run ID; CursorAdapter gives us this for free
Intent i = new Intent(getActivity(), com.domakecreatedesign.runtracker.RunActivity.class);
i.putExtra(com.domakecreatedesign.runtracker.RunActivity.EXTRA_RUN_ID, id);
startActivity(i);
}
Also worth noting, the application is contained within two packages
com.domakecreatedesign.getfit
com.domakecreatedesign.runtracker
Does this need to be declared somehow in the manifest?
Any help would be very much appreciated.
Many thanks
try ActivityName.this instead of getActivity()
Intent i = new Intent(getActivity(), com.domakecreatedesign.runtracker.RunActivity.class);
something like this,
Intent i = new Intent(AcitivityName.this, com.domakecreatedesign.runtracker.RunActivity.class);
Try this..
Intent i = new Intent();
i.setComponent(new ComponentName("com.domakecreatedesign.getfit", "com.domakecreatedesign.runtracker.RunActivity"));
startActivity(i);

Google play services rev. 16 error

I am new to android. I want add a map to my application. I have the latest revision 16 of play services installed. When I run my application, I get an error a missing meta tag which i have added as below. I testing on android 2.3.6. See Manifets file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mylocation"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mylocation.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="A***************************IE" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>

Android error: "APK NOT INSTALLED" in Android 2.3.x

My app seems to working in Android 4.0 also in emulator. but when I tried in other device(2.3) it showing "APK NOT INSTALLED" :(
Here is my manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ex.live"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
android:name="com.ex.live.Main"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED how to fix?

Today, I was working on an app. Testing testing testing.. and out of the blue, the app says Manifest Malformed. What is did first was undo what I changed, but that didn't help. I then copied a copy from this morning, but that was no good either.. Hope you guys can help, my manifest is below!
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lahmob.swagdaddymcnugget"
android:versionCode="2"
android:versionName="1.1" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.lahmob.swagdaddymcnugget.MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.lahmob.swagdaddymcnugget.SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="com.lahmob.swagdaddymcnugget.Webview"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.lahmob.swagdaddymcnugget.MusicPlayer"
android:label="#string/title_activity_music_player" >
</activity>
</application>
</manifest>
Because requested, the LogCat
In the meantime, I fixed the problem myself. Turned out I just had to remove a corrupt lib file.
-Laurens

Categories

Resources