Solace
Solace

Reputation: 9020

ActivityNotFoundException in library projecy while the Activity is there and is declared in Manifest

I am trying to use this library. But the library project as well as the demo project on the github page is for Android Studio, but for some reason I use Eclipse. So I added the library and the demo project to Eclipse (see below for how I did that) and uploaded them here:

So what I did was that I created a new library project in Eclipse and copied all the files from the github library project. Following screenshot shows my project structure:

I added this library project to my demo project just like we add the app_compat v7 project.

enter image description here

Then I went on the create a demo project in Eclipse and copied all the files and resources from the demo project in their github repository.

But when I run it, it gives me android.content.ActivityNotFoundException: Unable to find explicit activity class {br.com.edsilfer/br.com.customsearchable.SearchActivity}; have you declared this activity in your AndroidManifest.xml?

Following are the Logcat of the demo project, and the manifest of the library project:

FROM LOGCAT OF DEMO PROJECT:

08-22 02:53:26.110: E/AndroidRuntime(2405): FATAL EXCEPTION: main
08-22 02:53:26.110: E/AndroidRuntime(2405): Process: br.com.edsilfer, PID: 2405
08-22 02:53:26.110: E/AndroidRuntime(2405): android.content.ActivityNotFoundException: Unable to find explicit activity class {br.com.edsilfer/br.com.customsearchable.SearchActivity}; have you declared this activity in your AndroidManifest.xml?
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1777)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.app.Activity.startActivityForResult(Activity.java:3745)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.app.Activity.startActivityForResult(Activity.java:3706)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:820)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.app.Activity.startActivity(Activity.java:4016)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.app.Activity.startActivity(Activity.java:3984)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at br.com.edsilfer.Main.onOptionsItemSelected(Main.java:82)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.app.Activity.onMenuItemSelected(Activity.java:2885)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:353)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:144)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.internal.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:99)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.app.AppCompatDelegateImplV7.onMenuItemSelected(AppCompatDelegateImplV7.java:541)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:811)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:153)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:958)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:948)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:598)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.support.v7.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:139)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.view.View.performClick(View.java:4780)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.view.View$PerformClick.run(View.java:19866)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.os.Handler.handleCallback(Handler.java:739)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.os.Handler.dispatchMessage(Handler.java:95)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.os.Looper.loop(Looper.java:135)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at android.app.ActivityThread.main(ActivityThread.java:5254)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at java.lang.reflect.Method.invoke(Native Method)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at java.lang.reflect.Method.invoke(Method.java:372)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-22 02:53:26.110: E/AndroidRuntime(2405):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

MANIFEST OF LIB PROJECT:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="br.com.customsearchable">

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity android:name="br.com.customsearchable.SearchActivity"
                  android:launchMode="singleTop"
                  android:windowSoftInputMode="adjustResize|stateVisible"
                  android:theme="@style/Theme.AppCompat.Translucent" >
        </activity>
    </application>
</manifest>

EDIT # 1

After being pointed to this question by @MFaisalHyder I added the following element to the <application> element of the demo project:

<activity android:name="br.com.customsearchable.SearchActivity"
                  android:launchMode="singleTop"
                  android:windowSoftInputMode="adjustResize|stateVisible"
                  android:theme="@style/Theme.AppCompat.Translucent" >
        </activity>

Now, after touching the Search action from the toolbar, I get:

08-22 04:44:31.332: E/AndroidRuntime(2104): FATAL EXCEPTION: main
08-22 04:44:31.332: E/AndroidRuntime(2104): Process: br.com.edsilfer, PID: 2104
08-22 04:44:31.332: E/AndroidRuntime(2104): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.edsilfer/br.com.customsearchable.SearchActivity}: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.app.ActivityThread.access$800(ActivityThread.java:151)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.os.Handler.dispatchMessage(Handler.java:102)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.os.Looper.loop(Looper.java:135)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.app.ActivityThread.main(ActivityThread.java:5254)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at java.lang.reflect.Method.invoke(Native Method)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at java.lang.reflect.Method.invoke(Method.java:372)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
08-22 04:44:31.332: E/AndroidRuntime(2104): Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at br.com.customsearchable.SearchActivity.onCreate(SearchActivity.java:66)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.app.Activity.performCreate(Activity.java:5990)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
08-22 04:44:31.332: E/AndroidRuntime(2104):     ... 10 more
08-22 04:44:31.332: E/AndroidRuntime(2104): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.TextInputLayout" on path: DexPathList[[zip file "/data/app/br.com.edsilfer-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
08-22 04:44:31.332: E/AndroidRuntime(2104):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.createView(LayoutInflater.java:571)
08-22 04:44:31.332: E/AndroidRuntime(2104):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
08-22 04:44:31.332: E/AndroidRuntime(2104):     ... 22 more
08-22 04:44:31.332: E/AndroidRuntime(2104):     Suppressed: java.lang.ClassNotFoundException: android.support.design.widget.TextInputLayout
08-22 04:44:31.332: E/AndroidRuntime(2104):         at java.lang.Class.classForName(Native Method)
08-22 04:44:31.332: E/AndroidRuntime(2104):         at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
08-22 04:44:31.332: E/AndroidRuntime(2104):         at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
08-22 04:44:31.332: E/AndroidRuntime(2104):         at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
08-22 04:44:31.332: E/AndroidRuntime(2104):         ... 25 more
08-22 04:44:31.332: E/AndroidRuntime(2104):     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

EDIT # 2

The above error was resolved by adding the <activity> element for the SearchActivity in my project's Manifest. Now I am getting android.view.InflateException: Error Inflating class android.support.design.widget.TextInputLayout. I have added the design library. Below you can see the logcat for the exception and the project properties for the design library project

Logcat

08-22 05:44:34.827: E/AndroidRuntime(2582): FATAL EXCEPTION: main
08-22 05:44:34.827: E/AndroidRuntime(2582): Process: br.com.edsilfer, PID: 2582
08-22 05:44:34.827: E/AndroidRuntime(2582): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.edsilfer/br.com.customsearchable.SearchActivity}: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.app.ActivityThread.access$800(ActivityThread.java:151)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.os.Handler.dispatchMessage(Handler.java:102)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.os.Looper.loop(Looper.java:135)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.app.ActivityThread.main(ActivityThread.java:5254)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at java.lang.reflect.Method.invoke(Native Method)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at java.lang.reflect.Method.invoke(Method.java:372)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
08-22 05:44:34.827: E/AndroidRuntime(2582): Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.view.LayoutInflater.createView(LayoutInflater.java:633)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
08-22 05:44:34.827: E/AndroidRuntime(2582):     at br.com.customsearchable.SearchActivity.onCreate(SearchActivity.java:66)
...
08-22 05:44:34.827: E/AndroidRuntime(2582): Caused by: java.lang.reflect.InvocationTargetException
...
08-22 05:44:34.827: E/AndroidRuntime(2582): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;
...
...
java.lang.ClassNotFoundException: android.support.design.R$styleable
...
08-22 05:44:34.827: E/AndroidRuntime(2582):     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

enter image description here


EDIT 4:

After deleting (from the emulator) and reinstalling the app, it works somehow, i.e. there is no exception in the appearance of the activity, but the voice search and search suggestions still don't work. =/

Upvotes: 0

Views: 942

Answers (3)

Sourabh Bans
Sourabh Bans

Reputation: 3134

Actually the error you are facing,because of missing design support library. you can follow the steps to import. go to the properties of your design library>>select android>>check android version 5.0 or above>> check is library>>add library appcompat_v7>> click apply and ok

Upvotes: 1

mfaisalhyder
mfaisalhyder

Reputation: 2284

check these two links for help : One and this one.

Before using any activity of Library Project its every activity and other parts must be declared in the Manifest file.

For your Intent part try like this:

Intent i = new Intent();
i.setClassName("base.package.name.of.your.app","br.com.customsearchable.SearchActivity");
startActivity(i);

//*****Another way******\\
Intent i = new Intent(getApplicationContext(),br.com.customsearchable.SearchActivity.class);
startActivity(i);

One more thing: some people also found that it is the problem of Eclipse (Like this one) so do try to update Eclipse.

Hope i helped you.!

Upvotes: 1

Ferencz Andras
Ferencz Andras

Reputation: 41

Maybe, the launcher intent filter is missing...

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity android:name="br.com.customsearchable.SearchActivity"
                  android:launchMode="singleTop"
                  android:windowSoftInputMode="adjustResize|stateVisible"
                  android:theme="@style/Theme.AppCompat.Translucent" >
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        </activity>
    </application>

Try with this, and let me know if it works.

Upvotes: 1

Related Questions