原文地址:
https://github.com/liquiddandruff/FBReaderJ/blob/android_studio/README.md
Building FBReader using Android Studio and Gradle
Tested on a fresh installation of Windows 8.1 x64 using Android Studio v1.02 build 1653844, jdk-7u71-windows-x64, and android-ndk-r10d.
-
Clone the project into your %userprofile%\AndroidStudioProjects\
-
Import the project into Android Studio
-
Perform a project level gradle sync (CTR+SHIFT+A and search for "project sync", double click the first result).
Android Studio may complain about not finding a git.exe in your path, but this will not prevent you from building the project -
Install Android SDK Platform API 14 when prompted
-
Install Android SDK Platform API 5 when prompted
-
Install Android SDK Platform API 11 when prompted
-
FBReader has now been successfully built using Android Studio, but is missing the necessary binaries (*.so)
Compiling the binaries
-
To compile the binaries from the source, navigate to where you extracted the NDK
-
Execute the following command in your shell:
ndk-build -C %userprofile%\AndroidStudioProjects\FBReaderJ\fBReaderJ\src\main\jni
The binaries should be automatically placed into the appropriate directories (%userprofile%\AndroidStudioProjects\FBReaderJ\fBReaderJ\src\main\lib)
-
Finally, rebuild the project. FBReader should now run without issue on the emulator/on your device.
Generating the introductory help epubs
This step is optional. If you would like to see the introductory help epub when FBReader starts, execute the following commands in your shell and rebuild the project:
cd %userprofile%\AndroidStudioProjects\FBReaderJ\help\
generate.py proto html ..\fBReaderJ\src\main\assets\data\intro\
ECLIPSE ANDROID PROJECT IMPORT SUMMARY
Manifest Merging:
Your project uses libraries that provide manifests, and your Eclipse project did not explicitly turn on manifest merging. In Android Gradle projects, manifests are always merged (meaning that contents from your libraries' manifests will be merged into the app manifest. If you had manually copied contents from library manifests into your app manifest you may need to remove these for the app to build correctly.
Replaced Jars with Dependencies:
The importer recognized the following .jar files as third party libraries and replaced them with Gradle dependencies instead. This has the advantage that more explicit version information is known, and the libraries can be updated automatically. However, it is possible that the .jar file in your project was of an older version than the dependency we picked, which could render the project not compileable. You can disable the jar replacement in the import wizard and try again:
android-support-v4.jar => com.android.support:support-v4:18.0.0
Moved Files:
Android Gradle projects use a different directory structure than ADT Eclipse projects. Here's how the projects were restructured:
In AmbilWarna:
- AndroidManifest.xml => ambilWarna\src\main\AndroidManifest.xml
- res\ => ambilWarna\src\main\res\
- src\ => ambilWarna\src\main\java\
In code:
- AndroidManifest.xml => code\src\main\AndroidManifest.xml
- res\ => code\src\main\res\
- src\ => code\src\main\java\
In library:
- AndroidManifest.xml => library\src\main\AndroidManifest.xml
- res\ => library\src\main\res\
- src\ => library\src\main\java\
In FBReaderJ:
- AndroidManifest.xml => fBReaderJ\src\main\AndroidManifest.xml
- assets\ => fBReaderJ\src\main\assets\
- jni\ => fBReaderJ\src\main\jni\
- libs\httpmime-4.2.5.jar => fBReaderJ\libs\httpmime-4.2.5.jar
- libs\json-simple-1.1.1.jar => fBReaderJ\libs\json-simple-1.1.1.jar
- libs\LingvoIntegration_2.5.2.12.jar => fBReaderJ\libs\LingvoIntegration_2.5.2.12.jar
- libs\nanohttpd-2.0.5.jar => fBReaderJ\libs\nanohttpd-2.0.5.jar
- libs\open-dictionary-api-1.2.1.jar => fBReaderJ\libs\open-dictionary-api-1.2.1.jar
- libs\pdfparse.jar => fBReaderJ\libs\pdfparse.jar
- res\ => fBReaderJ\src\main\res\
- src\ => fBReaderJ\src\main\java\
- src\org\geometerplus\android\fbreader\api\ApiInterface.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\api\ApiInterface.aidl
- src\org\geometerplus\android\fbreader\api\ApiObject.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\api\ApiObject.aidl
- src\org\geometerplus\android\fbreader\api\TextPosition.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\api\TextPosition.aidl
- src\org\geometerplus\android\fbreader\config\ConfigInterface.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\config\ConfigInterface.aidl
- src\org\geometerplus\android\fbreader\formatPlugin\CoverReader.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\formatPlugin\CoverReader.aidl
- src\org\geometerplus\android\fbreader\httpd\DataInterface.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\httpd\DataInterface.aidl
- src\org\geometerplus\android\fbreader\libraryService\LibraryInterface.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\libraryService\LibraryInterface.aidl
- src\org\geometerplus\android\fbreader\libraryService\PositionWithTimestamp.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\libraryService\PositionWithTimestamp.aidl
- src\org\geometerplus\android\fbreader\network\BookDownloaderInterface.aidl => fBReaderJ\src\main\aidl\org\geometerplus\android\fbreader\network\BookDownloaderInterface.aidl
Next Steps:
You can now build the project. The Gradle project needs network connectivity to download dependencies.
Bugs:
If for some reason your project does not build, and you determine that it is due to a bug or limitation of the Eclipse to Gradle importer, please file a bug at http://b.android.com with category Component-Tools.
(This import summary is for your information only, and can be deleted after import once you are satisfied with the results.)