0

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. =/

Community
  • 1
  • 1
Solace
  • 8,612
  • 22
  • 95
  • 183
  • 1
    try activity name with the parent package name as well then let me know – mfaisalhyder Aug 22 '15 at 08:15
  • @MFaisalHyder "try activity name with the parent package name as well" - Assuming that you are talking about the Manifest of the library project which is posted in the question, The name of the Activity is `SearchActivity`. I already appended the parent package name to it, thus making it `android:name="br.com.customsearchable.SearchActivity"`. – Solace Aug 22 '15 at 08:20
  • @MFaisalHyder or are you asking me to add that to the manifest of the dmeo project? The package `br.com.edsilfer` is in the demo project, while the package `br.com.customsearchable` is in the library project. I am not sure of what you asked. Can you clarify, then I'll do it and report back. – Solace Aug 22 '15 at 08:23
  • 1
    http://stackoverflow.com/questions/6157616/using-an-android-library-project-activity-within-another-project check this thread – mfaisalhyder Aug 22 '15 at 08:37
  • @MFaisalHyder From that answer, "Declarations should reference the library components by their fully-qualified package names" - so I believe the fully qualified name of the Activity is `br.com.customsearchable.SearchActivity`. Am I right? – Solace Aug 22 '15 at 08:42
  • 1
    I am posting my answer, i will try to detail it as much as possible, meanwhile try check this all activities in Library Projects are declared in manifest or at least the one which your calling in your APP? – mfaisalhyder Aug 22 '15 at 08:47
  • @MFaisalHyder Cool. Please also see the edit in my question. Thank you so very much indeed for your time. – Solace Aug 22 '15 at 08:49
  • 1
    you need to add design support library for this error. – SRB Bans Aug 22 '15 at 08:56
  • @sourabhbans Is this library in the SDK? – Solace Aug 22 '15 at 09:00
  • yes you can find it like : D:\00_DEVELOPEMENT\00_DEVELOPEMENT\sdk_android\extras\android\support – SRB Bans Aug 22 '15 at 09:03
  • and import it into eclipse and make sure to check the copy into work space.. – SRB Bans Aug 22 '15 at 09:04
  • @sourabhbans Right after I imported the design support library into my workspace, I got a ton of errors in console. You can find them [in a text file here](http://www.mediafire.com/view/9jv4j7nl9y6cnn1/1.txt), adding to the question was increasing my question text limit – Solace Aug 22 '15 at 09:15
  • how you are using Intent? post intent part as well – mfaisalhyder Aug 22 '15 at 09:17
  • 1
    go to the properties of your design library>>select android>>check android version 5.0 or above>> check is library>>add library app compat_v7>> click apply and ok – SRB Bans Aug 22 '15 at 09:23
  • @sourabhbans Did all that. See the screenshot in the last edit in the question – Solace Aug 22 '15 at 10:03
  • @sourabhbans See my last edit at the bottom of the question. If you can post all things you said as an answer, I'll be glad to accept it. It will help any future visitors. – Solace Aug 22 '15 at 10:35

3 Answers3

1

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.

1

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.!

Community
  • 1
  • 1
mfaisalhyder
  • 2,250
  • 3
  • 28
  • 38
  • Hi, this problem was resolved after adding the Activity declaration to my project's manifest. But then I got `exception`, because I had not added the support design library. I added it, but still getting this exception. Adding an edit in the question. – Solace Aug 22 '15 at 09:49
1

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

SRB Bans
  • 3,096
  • 1
  • 10
  • 21