RT, this should be the biggest problem that many friends have had when they first go from Eclipse to Android studio, we need to re-recognize the directory structure in as, which is also mentioned in my previous post (Android Project in Studio is the equivalent of workspace in Eclipse, andmodule is the equivalent of project in Eclipse.
So when we manually import project, we are actually importing the module in as. There are several main steps to follow:
1. Copy the build.gradle into the project you want to import
2. Copy the items you need to import into the As Project root folder (that is, the folder that exists Gradlew, Gradlew.bat,. Gradle)
3. Modify Settings.gradle in as project, add include, tell as our project needs to include this module (for example, include ': Slidingmenulibrary ')
4.Rebuild Project automatically generates an. iml file (IML file is a configuration file for the as recognition project, similar to the. project file in Eclipse)
The following post Build.gradle main content:
Apply plugin: ' com.android.application ' dependencies {compile filetree (dir: ' Libs ', include: ' *.jar ')}android {Comp Ilesdkversion buildtoolsversion "20.0.0" sourcesets {main {manifest.srcfile ' androidmanifest. XML ' java.srcdirs = [' src '] resources.srcdirs = [' src '] aidl.srcdirs = [' src '] Renderscript.srcdirs = [' src '] res.srcdirs = [' res '] assets.srcdirs = [' Assets ']}// Move the tests to Tests/java, tests/res, etc ... Instrumenttest.setroot (' tests ')//Move The build types to build-types/<type>//For instance, build-t Ypes/debug/java, Build-types/debug/androidmanifest.xml, ...//This moves them out of them the default location under s rc/<type>/which would//conflict with src/being used by the main source set. Adding New build types or product flavors should be accompanied//by a similar customization. Debug.setroot (' Build-types/debug ') release.setroot (' Build-types/release ')}} In fact, the above file is exported with eclipse, you can rest assured that the use of direct replication. There are also the following points to note:
1. above is the app's Gradle file, if it is a library project, you need to modify the Apply plugin: ' com.android.application ' for apply Plugin : ' Com.android.library ' can
2. Compilesdkversion and buildtoolsversion, need to be modified according to the local SDK version, open the SDK manager to see.
3. Sourcesets main Specifies the directory location of the source code, because as the default code structure is different from Eclipse's
4. Dependencies A dependent library is specified, compile filetree (dir: ' Libs ', include: [' *.jar ']) compiles all the. jar libraries in the Libs directory. If you depend on some library items, you can add: Compile Project (': Cordova ')
Conclusion: In fact, the latest version of as already support the direct import module, but there is a problem, it will be in the import, copy a copy of your project (equivalent to regenerate a copy), and then import the directory structure becomes the directory structure of AS, if you want to maintain the Eclipse directory structure, Or use the method above, hehe.
Importing eclipse Project manually in Android Studio