So this is how I solved my problem:
instead of adding
dependencies { compile files('libs/android-support-v4.jar') compile project(':Module') }
You need to write:
dependencies { compile files('libs/android-support-v4.jar', '../Module') }
2 points say that the module (or directory) can be found in 1 directory above the actual one. therefore, if you want to access a module that contains 2 directories above, you just need to write: '../../ModuleName'
You must add the modules manually in build.gradle, because Android Studio is still under development and has not completed the user interface for editing the project structure.
If this does not solve your problem, try doing this: (I would recommend this method. Here's how I do it)
Examplestructure:
Project
- libraries (regular folder)
- Module1
settings.gradle
include ':Module1', ':libraries:Module2'
build.gradle (Module1)
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android' dependencies { compile project(':libraries:Module2') } android { compileSdkVersion 18 buildToolsVersion "18.0.1" defaultConfig { minSdkVersion 8 targetSdkVersion 11 } }
build.gradle (Module2)
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android-library' dependencies { compile 'com.android.support:support-v4:18.0.0' } android { compileSdkVersion 18 buildToolsVersion "18.0.1" defaultConfig { minSdkVersion 8 targetSdkVersion 11 } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] res.srcDirs = ['res'] } } }
Now it will work well. To make everything work 100%, follow these steps:
- delete
.idea folder - delete all
*.iml files - Restart Android Studio and click
Import Project - Select directory with gradle project
Import project from external model > gradle> next> finish
With these steps, everything should work well. If there is any problem, just tell me :)
maysi
source share