Unable to instantiate activity ComponentInfo java.lang.ClassNotFoundException: util.kalyan.HelloGoogleMapsActivity - android

I have included all the necessary fields correctly.
But still, I am not able to launch the Google map on my emulator.
Checked the internet permissions also.
Getting error like:
E/AndroidRuntime(2064): java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{util.kalyan/util.kalyan.HelloGoogleMapsActivity}:
java.lang.ClassNotFoundException: util.kalyan.HelloGoogleMapsActivity
Please find below my code.
HelloGoogleMapsActivity.java
package util.kalyan;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import util.kalyan.R;
public class HelloGoogleMapsActivity extends MapActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
#Override
protected boolean isRouteDisplayed()
{
return false;
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="util.kalyan"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<uses-library android:name="com.google.android.maps"></uses-library>
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name" >
<activity android:name=".HelloGoogleMapsActivity" android:label="#string/app_name" android:theme="#android:style/Theme.NoTitleBar">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses- permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Any one please help me in this at the earliest.
Thanks in advance.

Change the android:name in activity definition
from
<activity android:name=".HelloGoogleMapsActivity" ../>
to
<activity android:name="util.kalyan.HelloGoogleMapsActivity" ../>

You emulator target should be one that includes Google APIs (Google Inc.).

Right click on your HelloGoogleMapsActivity class > BuildPath > Exclude Then Right click on your HelloGoogleMapsActivity class > BuildPath > Include your class again

Related

Fatal Exception applicationId is null Parse

This is my second question in SO, I have a problem about Fatal Main error. Before I ask it, I found some other problem in SO, but what I found is about Facebook app
This is my error
java.lang.RuntimeException: applicationId is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
But, I have a class that declared it
package com.example.michael.eksperimen6chatting;
import android.app.Application;
import com.parse.Parse;
/**
* Created by Michael on 03/12/2015.
*/
public class ChattApp extends Application
{
#Override
public void onCreate()
{
super.onCreate();
Parse.initialize(this, "urkcFwvUmgSYvuOFTInJmkA3iWv0ArV3XT128TNb", "WvBC0cnGXHkVhTBbkFwLyxGDRgqR6qC8ft7DIleT");
}
}
and this is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.michael.eksperimen6chatting" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".MainActivity" >
</activity>
<activity android:name=".UserList"></activity>
<activity android:name=".Login">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Chat">
</activity>
</application>
</manifest>
Did I miss something here, can anyone help me? Gratia
Specifying ChattApp Application class name in your AndroidManifest.xml's <application> tag.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:name="com.example.michael.eksperimen6chatting.ChattApp">
....
</application>
import com.parse.Parse;
import android.app.Application;
public class ChattApp extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(this);
Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
}
}
AndroidManifest.xml
<application
android:name="com.example.michael.eksperimen6chatting.ChattApp"
.
.
.
</application>

can't display Openstreetmap

I want to display a part of a OSM but i don't know what's the problem with my code, when I run it, the map didn't display:
No error appear but the map didn't only display! I work with eclipse and the emulator Google API 8!
here is my MainActivity code:
package com.formation.dsmap1;
import org.mapsforge.android.maps.MapActivity;
import org.mapsforge.android.maps.MapView;
import android.annotation.SuppressLint;
//import android.annotation.SuppressLint;
//import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
//import android.os.Environment;
public class MainActivity extends MapActivity {
// #SuppressLint("SdCardPath")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
mapView.setEnabled(true);
// mapView.setMapFile("/sdcard/essai.jpg");
// setContentView(mapView);
mapView.setMapFile(Environment.getExternalStorageDirectory().getAbsolutePath()
+ "essai.osm");
setContentView(mapView);
}
}
and my AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.formation.dsmap1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.formation.dsmap1.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>
Can you help me please?
add this permission to your manifest and will be fine :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Adding Shared Library Project Android

I'm struggling with adding a library to my project. I've been following a few other SOs as well as the tictactoemain/lib sample Android provides, but I'm still getting a "unable to find explicit activity class" error. The library package I included showing up under Android Dependencies is com.example.surveymetest. I suspect the issue is how I'm calling/defining the activity in the manifest but I can't seem to get it right. Any ideas where I'm going wrong?
Here's my manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="8"
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.example.surveymedemo.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>
<activity
android:name="com.example.surveymetest.SurveyActivity"
android:label="#string/app_name" >
</activity>
<activity android:name="com.example.surveymetest.TakeSurveyActivity" >
</activity>
<provider
android:name="com.example.surveymetest.SurveyMeContentProvider"
android:authorities="io.surveyme.ContentProviders.SurveyMeContentProvider"
android:exported="true" >
</provider>
</application>
</manifest>
Calling the Activity:
package com.example.surveymedemo;
import com.example.surveymetest.StartSurveyActivity;
import com.example.surveymetest.SurveyMe;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = new Intent(this, StartSurveyActivity.class);
startActivity(i);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Add:
<activity
android:name="com.example.surveymetest.StartSurveyActivity"
android:label="#string/app_name" >
</activity>
to your manifest and you should be good.
(you only defined com.example.surveymetest.SurveyActivity)

MapActivity could'nt get connection factory client

I've been looking for much on google about the problem, but I have not resolved. The map is displayed, but I located at the point where I want and still giving me the same failure:
06-09 12:10:57.231: I/MapActivity(1532): Handling network change
notification:CONNECTED 06-09 12:10:57.231:
W/IdleConnectionHandler(1532): Removing a connection that never
existed! 06-09 12:11:04.829: W/KeyCharacterMap(1532): Can't open
keycharmap file 06-09 12:11:04.829: W/KeyCharacterMap(1532): Error
loading keycharmap file 06-09 12:11:04.829: W/KeyCharacterMap(1532):
Using default keymap 06-09 12:11:57.080: I/MapActivity(1785): Handling
network change notification:CONNECTED 06-09 12:11:57.080:
E/MapActivity(1785): Couldn't get connection factory client
And I do not understand because I've followed all the steps to generate the api key, my Activity extends from MapActivity, and and I added my android manifiest permits and libraries.
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.XXX.XXX"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activities.Gmaps"/>
</application>
</manifest>
Gmaps Activity
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class Gmaps extends MapActivity{
private MapView mapa = null;
private MapController control = null;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gmaps);
mapa = (MapView)findViewById(R.id.mapa);
mapa.setBuiltInZoomControls(true);
Double latitud = 40.4166909;
Double longitud = -3.7003454;
GeoPoint loc = new GeoPoint(latitud.intValue(), longitud.intValue());
control = mapa.getController();
control.setCenter(loc);
control.setZoom(7);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
gmaps.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="#+id/mapa"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0htJ1gM0WymyYYokI3eUunfuJ2-XXXXXXXXX"
android:clickable="true"/>
</RelativeLayout>
Sorry for my english !! jeje :)
Sign your application with a keystore and generate an apk for your application using this keystore.Then install this on your device. This would solve your problem.The map api key you are using must be generated with this keystore only.

SecurityException at starting intent of a new empty Activity

I have developed a little project using just one Activity, and now, I'm trying to add a new one, but, I recieve this error when I'm trying to launch the project on my device:
Running com.android.gl2jni/.TestActivity... 1> Starting: Intent {
cmp=com.android.gl2jni/.TestActivity } 1> 1>
java.lang.SecurityException: Permission Denial: starting Intent {
flg=0x10000000 cmp=com.android.gl2jni/.TestActivity } from null
(pid=2935, uid=2000) requires null
I'm not trying to call the new Activity, and I have developed an empty Activity to check why I can't launch the app.
This is my Manisfest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.gl2jni">
<uses-feature android:glEsVersion="0x00020000"/>
<uses-sdk android:minSdkVersion="9"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:label="#string/gl2jni_activity">
<!--main activity-->
<activity android:name=".GL2JNIActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:configChanges="keyboardHidden"
android:screenOrientation="landscape"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--BT device list activity-->
<activity android:name=".TestActivity"
>
<intent-filter>
</intent-filter>
</activity>
<!--
<activity android:name=".BluetoothDeviceListActivity"
android:label="#string/select_device"
android:theme="#android:style/Theme.Dialog"
android:configChanges="keyboardHidden"
android:screenOrientation="landscape"
/>
-->
</application>
</manifest>
And this is the empty activity class:
package com.android.gl2jni;
import android.app.Activity;
import android.util.Log;
import android.os.Bundle;
public class TestActivity extends Activity {
#Override protected void onCreate(Bundle icicle) {
LogConsole.print( "HI, I AM TestActivity" );
}
}
I suppose that I have to modify something else more, but I don't know what...
Thanks in advance for the help.
You've specified an empty intent filter for TestActivity. An empty intent filter matches NO intents. Remove these lines from the block for TestActivity:
<intent-filter>
</intent-filter>
Also, in onCreate() of TestActivity you must call super.onCreate(), otherwise Android will crash it.

Categories

Resources