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?