0

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

  1. com.domakecreatedesign.getfit
  2. com.domakecreatedesign.runtracker

Does this need to be declared somehow in the manifest?

Any help would be very much appreciated.

Many thanks

RMcGuigan
  • 1,147
  • 2
  • 7
  • 11
  • ... assuming you've cleaned your project & tried to rebuild...? – Richard Le Mesurier Apr 13 '14 at 15:19
  • 1
    I'm unconvinced that the Intent is incorrect; I'd expect the package part of the intent to be the package of the apk, while the component within would be that of the Java file defining the activity. Does this target Activity have any dependencies which might be unsatisfied at link time? Can you post the start of its code? Also consider copying that Activity to a test project of its own package name and seeing if it works there standalone. – Chris Stratton Apr 13 '14 at 15:34
  • @user3076493 if you're using proguard you need to add exception for classes that extend Activity and other Android components. – Yaroslav Mytkalyk Apr 13 '14 at 15:59
  • I'm not using proguard, thanks – RMcGuigan Apr 13 '14 at 16:11

2 Answers2

1

Try this..

Intent i = new Intent();
i.setComponent(new ComponentName("com.domakecreatedesign.getfit", "com.domakecreatedesign.runtracker.RunActivity"));
startActivity(i);
Hariharan
  • 24,741
  • 6
  • 50
  • 54
  • Thanks...just tried it... returned error: 04-13 17:09:59.869: E/AndroidRuntime(9729): Process: com.domakecreatedesign.getfit, PID: 9729 04-13 17:09:59.869: E/AndroidRuntime(9729): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity}: java.lang.NullPointerException – RMcGuigan Apr 13 '14 at 16:10
  • @user3076493 K that NPE Post that full error and also relevant code. – Hariharan Apr 13 '14 at 16:12
  • I really do think that the problem is the fact that the root package declared in the manifest is : and the requested activity is in a different package... is there a special way to declare multiple packages in the manifest file? – RMcGuigan Apr 13 '14 at 16:13
  • @user3076493 No need to change that. After you tried that my code you are getting different error. – Hariharan Apr 13 '14 at 16:16
  • Yes, now logcat returns NullPointerException...cant work out why....thanks – RMcGuigan Apr 13 '14 at 16:19
  • @user3076493 then something `null` in `RunActivity.java` – Hariharan Apr 13 '14 at 16:20
  • @user3076493 Post that code and post that error. – Hariharan Apr 13 '14 at 16:21
0

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);
Gurupriyan
  • 51
  • 9
  • I tried this: `Intent i = new Intent(RunActivity.this, com.domakecreatedesign.runtracker.RunActivity.class); ` but receive an error: No enclosing instance of the type RunActivity is accessible in scope... Am I writing it correctly? Thanks – RMcGuigan Apr 13 '14 at 15:22
  • I think if i can work out why the requesting path is incorrect, that will solve the issue – RMcGuigan Apr 13 '14 at 15:31
  • There's no problem using two packages in one application, I have a similar application, that works just fine, double check your package names and import statements. Show us a little bit more of your error details and code, if you have no problem with that. – Gurupriyan Apr 13 '14 at 16:49
  • This is a Fragment, not an Activity. Otherwise `getActivity()` wouldn't compile. – Ryan M May 26 '23 at 20:05