0

I have already gone through How do I add a library project to Android Studio? but it provides explanation only for external libraries. I want to edit SpeechRecognizer class of Android's SDK.

As libraries are already compiled and their object files are linked to application's object file before its execution, I want to exclude 'android.speech' from my project, copy it's contents into a 'libs' folder, make my changes, and treat it like an external library. However, source code of this library contains neither build.gradle nor a manifest file, both of which are necessary for including an external library. How can I install this as an external dependency?

Edit:

Just after adding the library as a dependency, I get this error :

A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugApk'. Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :libs:speech.

This is because there is no build.gradle in the library's directory.

After I add this as build.gradle -

apply plugin: 'com.android.library'

dependencies {
    compile 'com.android.support:support-v4:25.3.1'
}

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 25
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

I again get an error, that it cannot read the package name from AndroidManifest.xml. This is because library does not contain a manifest file either.

Both these problems were mentioned in original question. Kindly guide how can I proceed further. What should I keep in the manifest file that I should now create?

kshubham07
  • 341
  • 1
  • 3
  • 15

1 Answers1

0

Go to File > Project Structure. Then in left side, click app(under Modules) and top side go to Dependencies, click + and select your dependency type.

Cagri Yalcin
  • 402
  • 4
  • 13
  • Effectively you are telling me to compile the new library. Please see edit, I have done that, and that is not the problem. – kshubham07 Oct 16 '17 at 11:04