问题
I'm new in Gradle and Android Studio(Intellij Idea based IDE). My problem is to correct import holoeverywhere to project. I read many similar topics but they dign't give my solution on my problem.
Similar topics:
Android Studio not working with HoloEverywhere and ActionBarSherlock
Building Android Studio project with HoloEverywhere fails
How do I add a library project to Android Studio?
Below put screens of my method of operation:
1 First create new project from scratch
2 Create directory for libs
3 Import new module
4 Import holoeverywhere using Maven model
5 Import settings
6 Add dependencies to main application module
7 Move Holoeverywhere dir to libraries
8 Change parent module name
9 Add dependence to gradle files
10 Change imports in Activity
11 Run result
12 Another attempt to set dependent
Please give me same idea how to correct import holoeverywhere
回答1:
I agree with @7wonders , but importing mine project to HoloEverywhere would make bigger problem than importing HoloEverywhere in it.
After cloning HoloEverywhere, inside of project you have folder named "library". Firstly, I copied it to mine folder "libraries" in project's root and renamed it to "HoloEverywhere".
Secondly, I've edited "build.gradle" file in HoloEverywhere folder like this:
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
dependencies {
compile files('libs/support-v4-18.0.4.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
}
Thirdly, added to "settings.gradle" in project`s root folder
include ":libraries:HoloEverywhere"
before line with include of your project.
After all we should add library HoloEveryWhere to our main project dependencies in "build.gradle" file inside YourProjectName folder.
dependencies {
compile project(':libraries:HoloEverywhere')
}
Don't forget to remove from project dependencies support-v4 & support-v7 libraries.
Finally don't forget to clean project. Choose from Android Studio's Menu Build>Clean Project. I recommend to do it via Terminal, because you can't see all errors in Run window. so choose Tools>Open Terminal firstly you should navigate to project root(command "cd ..") and call:
UNIX: ./gradlew clean
Windows: gradlew.bat clean
After successful cleaning build your project.
While build I've got error that there is no "application" tag in AndroidManifest.xml in HoloEverywhere library. So just add it and now everything is OK.
One small, maybe the worst, thing left to do: read basic migration and change all imports, resources(layouts) and override methods with classes from HoloEverywhere library to ignore ClassCastException.
ENJOY :)
回答2:
To get it working on the most basic of levels just follow the advice given here:
https://github.com/Prototik/HoloEverywhere/wiki/Import-in-IDE
Basically close all projects so you get to the welcome screen. Then:
-> Checkout from Version Control - Git -> Type in Repository URL: https://github.com/Prototik/HoloEverywhere.git -> Press 'Clone', wait until repository checkout -> click 'Yes' on the proposal to open a project.
This should give you a HoloEverywhere project thats ready to work with.
Open up File > Project structure and check for any errors with missing libraries (for example I had to download manually the v4 r18 file).
Click apply > ok to make sure changes are saved and return to the project. Click on demo and then click Run > Edit configurations. Click + then Android Application. Call it demo or whatever. Select demo as module, launch default activity checked, deploy checked, USB device checked.
Hitting the little debug dude should now get you running the demo. From here its simply a case of refactoring the demo to your own project or creating a new Android Application module within the HoloEverywhere project.
In other words, instead of trying to add HoloEverywhere to your project, add your project to HoloEverywhere :)
来源:https://stackoverflow.com/questions/17189052/add-holoeverywhere-to-project-in-android-studio