Missing dependencies tab in android studio - android-studio

Screenshot http://i.imgur.com/2i41Vih.png
My project is named Pudge. When I open Module settings, I select my project and all the tabs (dependencies, etc.) are missing.
This is probably something stupid, but I don't know what.
Edit: adding more info:
The project has a folder named libraries, and in it there is the folder of the library (facebook in my case)
build.gradle of the main project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest {
srcFile 'AndroidManifest.xml'
}
java {
srcDir 'src'
}
res {
srcDir 'res'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'tests/src'
}
}
}
defaultConfig {
minSdkVersion 17
targetSdkVersion 17
}
}
dependencies {
compile project(':libraries:facebook')
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'com.google.android.gms:play-services:3.2.25'
}
task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}
build.gradle of the facebook library
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 17
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java {
srcDir 'src'
}
res {
srcDir 'res'
}
}
}
}
settings.gradle
include ':Pudge'
include ':libraries:facebook'
As I said in the comments - after I added the library through the gradle files - its working. But the tabs are still missing.

Looking at your main build file, it has the comment in it about being the top-level build file, so it looks like your main module is located at the project root instead of inside a folder. This is probably what's confusing the Project Structure dialog, because when it examines settings.gradle, it expects to see modules in the Pudge and libraries/facebook directories.
If my assumption about your main module being at the project root is correct, if you change your settings.gradle file to this it should work:
include ':'
include ':libraries:facebook'

Related

How to apply JaCoCo to build.gradle?

I wanted to add JaCoCo to an existing Android Studio Project. In my settings.gradle I edited:
pluginManagement {
gradle.ext.kotlin_version = "1.6.0"
repositories {
google()
mavenCentral()
}
def versionsProp = new Properties()
versionsProp["myapp.version.level"] = "7.1.0-beta05"
def versionsPropFile = file("local.properties")
if (versionsPropFile.canRead()) {
versionsProp.load(new FileInputStream(versionsPropFile))
}
def levelVersion = versionsProp["myapp.version.level"]
plugins {
id("com.android.application") version "$levelVersion"
id("com.android.library") version "$levelVersion"
id("org.jetbrains.dokka") version "1.4.30"
id("org.jetbrains.kotlin.android") version "$gradle.ext.kotlin_version"
id("org.jacoco.core") version "0.8.7"
} }
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
mavenLocal()
} }
rootProject.name = "TestApp"
include ":app"
include ":mylib_1"
include ":mylib_2"
include ":docs"
Especially I added JaCoCo in plugins section. According to this medium article :
Now inside each module’s build.gradle file apply the newly created
jacoco.gradle as such: apply from: "$project.rootDir/jacoco.gradle"
But in my app modules build gradle (I've shortened away stuff commented there) I have follwing structure:
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
compileSdkVersion = 31
buildToolsVersion = "31.0.0"
defaultConfig {
applicationId = "org.example.myapp"
// minSdkVersion(21), targetSdkVersion(31) ..
}
// buildTypes, flavorOptions, compose options
// compile options, kotlinOptions, buildFeatures, packagingOptions, lintOptions
}
dependencies {
implementation(fileTree(include: ["*.jar"], dir: "libs"))
implementation("androidx.activity:activity-compose:$compose_activity_version")
implementation("androidx.appcompat:appcompat:$appcompat_version")
testImplementation("junit:junit:4.13.2")
implementation(project(":org_mylib_1"))
implementation(project(":org_mylib_2"))
}
So where or how am I supposed to add the apply from: "$project.rootDir/jacoco.gradle"?

Android Studio 2.0 Preview 5, linking ndk app fails to locate module .so and .a

I have an ndk project with two modules:
abwrenderer - native library module
app - native and java hybrid, glues java to the abwrenderer
I just updated to AS 2.0 Preview 5 this morning, and encountered some gradle related issues.
I upgraded to gradle-2.10 and switched to gradle-experimental:0.6.0-alpha5. When attempting to debug, an ndk build is triggered and I run into the following problem:
Error:error: C:\android\projects\foo\abwrenderer\build\intermediates\binaries\debug\obj\armeabi-v7a\libabwrenderer.so: No such file or directory
Now when I was on gradle-2.9 & gradle-experimental:0.6.0-alpha3, the libraries were built in this directory. After this morning's upgrades, the libraries are now located in:
C:\android\projects\foo\abwrenderer\build\libs\abwrenderer\shared\armeabi-v7a\debug
Is there a way to update the search location for project dependencies that build libraries?
For reference, I define the dependency on abwrenderer project as follows (build.gradle (app)):
android.sources {
main {
jni {
source {
srcDirs 'src/main/jni'
}
dependencies {
project ":abwrenderer" buildType "debug" linkage "shared"
}
}
jniLibs {
source {
srcDirs 'src/main/libs'
}
}
}
}
And build.gradle for abwrenderer project is as follows:
apply plugin: "com.android.model.native"
model {
android {
compileSdkVersion = 23
}
android.ndk {
moduleName = "abwrenderer"
cppFlags.addAll(["--std=c++11",
"-fexceptions",
"-frtti"])
ldLibs.addAll(["android", "EGL", "GLESv3", "log", "dl"])
stl = "c++_static"
debuggable = true
}
android.sources {
main {
jni {
exportedHeaders {
srcDir "src/main/jni"
}
}
}
}
}
I have invalidated caches and restarted, done a clean build, etc. Any help would be greatly appreciated!
Your defaultConfig and ndk blocks were missing some info. They should look similar to this:
defaultConfig {
applicationId = 'com.myapp.abwrenderer'
minSdkVersion.apiLevel = 13
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = '1.0'
}
ndk {
platformVersion = 21
moduleName = 'abwrenderer'
toolchain = 'clang'
stl = 'gnustl_static'
cppFlags.addAll(['-std=c++11'])
ldLibs.addAll(['android', 'EGL', 'GLESv3', 'log', 'dl'])
}
You should take a look at the following NDK sample from Google to see how they did it: hello-libs

working of tesseract,(tess-two,eyes-two) and its gradle errors with default config in android studio

Iam trying to use tessearct for an image based compiler App.
I have created a library under the main project which contains both tess-two and eyes-two files.
Iam having problems in building their build.gradle files
THE PROJECT'S Root build.gradle file
enter // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
The project's module:app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.example.pavithra.ocrreader"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile project (':libraries:eyes-two')
compile project (':libraries:tess-two')
}
now the project's setting.gradle
include ':app'
include ':libraries:eyes-two'
include ':libraries:tess-two'
tess-two's build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:1.2.3"
}
}
apply plugin: "android-library"
android {
compileSdkVersion 22
buildToolsVersion '23.0.0 rc3'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
}
sourceSets.main {
manifest.srcFile "AndroidManifest.xml"
java.srcDirs = ["src"]
resources.srcDirs = ["src"]
res.srcDirs = ["res"]
jniLibs.srcDirs = ["libs"]
}
eyes-two build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:1.2.3"
}
}
apply plugin: "android-library"
android {
compileSdkVersion 22
buildToolsVersion '23.0.0 rc3'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
}
sourceSets.main {
manifest.srcFile "AndroidManifest.xml"
java.srcDirs = ["src"]
resources.srcDirs = ["src"]
res.srcDirs = ["res"]
jniLibs.srcDirs = ["libs"]
}
Now when i build this, Android studio throws an error saying:
Error:A problem occurred configuring project ':app'.
> Cannot evaluate module eyes-two : Configuration with name 'default' not found.
This is really taking me no where Can anyone PLEASE HELP me with it as i have my submission in a day ! please.
Also with the build.gradle files with respect to eyes-to and tess-two
Thank you in advance.
Add the following lines to your settings.gradle file
project(':tess-two').projectDir = new File('libraries/tess-two')
project(':eyes-two').projectDir = new File('libraries/eyes-two')

Build and link multiple NDK libraries using gradle

I have an Android project that links together a bunch of sources into a single monolithic JNI library. I would like to split this single library out into multiple smaller libraries with some dependencies between them. How can I achieve this with the new gradle build system?
You can achieve this with the standalone android native plugin from the experimental gradle plugin family. The new plugins are based on the gradle component approach towards modeling builds. There are many advantages to using the new system.
For example:
root
+ lib -> 'com.android.model.native'
+ lub -> 'com.android.model.native'
+ aar -> 'com.android.model.library'
+ app -> 'com.android.model.application'
build.gradle
configure([project(':lib'), project(':lub'), project(':aar'), project(':app')]) {
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha5'
}
}
}
lib/build.gradle
apply plugin: "com.android.model.native"
model {
android {
compileSdkVersion 23
ndk {
moduleName "foo"
}
sources {
main {
jni {
exportedHeaders {
srcDir "src/main/headers"
}
}
}
}
}
lub/build.gradle
apply plugin: "com.android.model.native"
model {
android {
compileSdkVersion 23
ndk {
moduleName "bar"
}
sources {
main {
jni {
exportedHeaders {
srcDir "include"
}
}
}
}
}
aar/build.gradle
apply plugin: "com.android.model.library"
model {
android {
buildToolsVersion '23.0.2'
compileSdkVersion 23
ndk {
moduleName "aggregate-jni"
stl "stlport_shared" // using cpp?
}
sources {
main {
jni {
dependencies {
project ":lib"
project ":lub"
}
}
}
}
}
app/build.gradle
apply plugin: 'com.android.model.application'
model {
android {
buildToolsVersion '23.0.2'
compileSdkVersion 23
defaultConfig {
applicationId "com.example.app"
minSdkVersion.apiLevel 21
targetSdkVersion.apiLevel 23
versionCode 1
versionName "1.0"
}
}
}
dependencies {
compile project(':aar')
}
If linkage is dynamic (default for ndk), the aar will contain:
libfoo.so libbar.so libaggregate-jni.so libstlport.so
and your mirror java classes. You can simply
System.load("aggregate-jni");
in your java classes and referenced libraries will load too. If linkage is static, you'll end up with a single libaggregate-jni.so anyway. Note that it's bad to link a bunch of things statically against the stl as you will end up with multiple copies of the stl in your binary. This can really mess things up.
Note that the default gcc toolchain is now deprecated. It's probably best to use:
model {
android {
ndk {
toolchain 'clang'
stl 'c++_shared'
}
}
}
Finally, you absolutely don't need an aar, I simply included it for completeness. The app project can depend directly on standalone native lib projects as the application plugin fully support the ndk, too.

Android Studio removes modules falsely identified as not backed by Gradle

I have a problem with Android Studio 0.3.0 and my project folder containing a plain old java library project, two Android library projects, and three Android apps. It's all built with Gradle.
The problem is that the initial import into Android Studio works fine (using Android Studio's Import Project..., then choosing my settings.gradle file), but when I press the refresh button in the Gradle sidebar, I get the message "The modules below are not backed by Gradle anymore. Check those to be removed from the ide project too:", and then it lists ALL my modules for removal. Everything builds fine from the terminal.
Output of gradle projects is (with edited names):
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'root'
+--- Project ':android-lib1'
+--- Project ':android-app1'
+--- Project ':android-app2'
+--- Project ':android-app3'
+--- Project ':android-lib2'
\--- Project ':java-lib'
In the root folder, I have settings.gradle:
include ':java-lib'
include ':android-lib1'
include ':android-lib2'
include ':android-app1'
include ':android-app2'
include ':android-app3'
My build.gradle in the root folder:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
allprojects {
repositories {
mavenCentral()
ivy {
name 'repo'
artifactPattern 'http://repo.example.com:8081/artifactory/libs-release-local/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]'
credentials {
username 'example'
password 'example'
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}
build.gradle for java-lib:
apply plugin: 'java'
apply plugin: 'eclipse'
compileJava.options.encoding = 'UTF-8'
group 'example'
version '0.1.0'
status 'release'
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
dependencies {
compile 'com.google.protobuf:protobuf-java:2.5.0'
compile 'com.google.guava:guava:15.0'
compile 'org.slf4j:slf4j-api:1.7.5'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
uploadArchives {
repositories {
add project.repositories.repo
}
}
build.gradle for the two Android libs (they are the same apart from dependencies and version numbers:
apply plugin: 'android-library'
dependencies {
compile project(':java-lib')
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
versionCode 1
versionName '0.1.0'
minSdkVersion 9
targetSdkVersion 18
}
}
And finally, build.gradle for the Android apps (again, almost identical):
apply plugin: 'android'
dependencies {
compile project(':android-lib1')
compile project(':android-lib2')
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
versionCode 1
versionName '0.1.0'
}
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
if (project.hasProperty('storeFile')) {
android.signingConfigs.release.storeFile = file(storeFile)
}
if (project.hasProperty('storePassword')) {
android.signingConfigs.release.storePassword = storePassword
}
if (project.hasProperty('keyAlias')) {
android.signingConfigs.release.keyAlias = keyAlias
}
if (project.hasProperty('keyPassword')) {
android.signingConfigs.release.keyPassword = keyPassword
}
Perhaps it's a bug in Android Studio 0.3.0? I didn't experience it in earlier versions, but I want to make sure it's not just something in my build files.
Thanks a bunch for reading!
This was a bug which has now been fixed (working for me since Android Studio 0.3.5): https://code.google.com/p/android/issues/detail?id=61453
Also got this or very similar error (don't know if I did refresh) I see you posted bug at code.google.com and agree it must be their bug. My work around fix was just to cancel out of "not backed by Gradle" message and then I ran gradle build from command line. Then everything worked.

Resources