Download the dependencies source code used at android studio - gradle

Now,google use android studio,i can add dependencies at build.gradle as follows:
dependencies {
compile 'mobi.parchment:parchment:1.6.9#aar'
}
but sometime i want to see the source code "mobi.parchment:parchment#aar",maybe i want to modify it or use to eclipse but not use the gradle plugin

If AndroidStudio didn't download the source code, you can force the download of source (and javadoc) of your AAR dependency by adding these lines in the build.gradle file :
dependencies {
compile 'mobi.parchment:parchment:1.6.9#aar'
compile 'mobi.parchment:parchment:1.6.9:sources#jar'
compile 'mobi.parchment:parchment:1.6.9:javadoc#jar'
}
Then on AndroidStudio in the Projet tab, expand the external Librarie and right clic on your lib (parchment1.6.9), click "Library Properties ..." and the "+" button. the source's jar file is in the gradle cache under ${user_Home}/.gradle/modules-2/files-2.1 directory; you can select it.
(Once is done you don't need anymore to declare the source dependencies; so your build.gradle can contain only :
dependencies {
compile 'mobi.parchment:parchment:1.6.9'
}
I know it's an ugly process, but it's the only workaround I found until now.

Related

compile and build gluon mobile app for desktop

we have
desktopRuntime 'org.xerial:sqlite-jdbc:3.15.1'
in gradle file.
i build project but my zip file dont have this file in lib folder.
how can i build project for desktop?
my ide is netbeans.
Thankful.
The problem with the distZip or jar gradle tasks is they miss to include desktop dependencies.
When deploying to desktop you can change temporary desktopRuntime to runtime, so they will be included, as Ladislav Török suggests, but then you should undo the change so that dependency isn't included in the mobile deployment.
If you want to have a working zip, we have to modify the distZip task, to include the desktop dependencies in the lib folder, and also to include them in the class path (so they are also added to the scripts in the bin folder). Include this in your build.gradle script:
startScripts {
classpath += configurations.desktopRuntime
}
distZip {
into("$project.name/lib") {
from configurations.desktopRuntime
}
}
You can also solve the issue by using the shadowJar, providing you include the desktop dependencies, to create an executable fat jar, like in this solution.
Try next steps:
1.
dependencies {
compile 'org.xerial:sqlite-jdbc:3.15.1'
runtime 'org.xerial:sqlite-jdbc:3.15.1'
}
Go to "Files" tab in NetBeans IDE -> your_project -> build -> libs and here add your lib some as sqlite-jdbc.jar

Cannot resolve symbol TexturePacker

Using libgdx 1.7.0/Android Studio, TexturePacker is supposed to be included out of the box if checking the tools option when creating the project (and so I did).
In fact, if I check my build.gradle file, in the project(":desktop") section I have the compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion" added.
But even with that, the build is not able to find the tools package (even though I can successfully use the Controllers extension, which should be the same I think)
I'll leave here the desktop part of the build.gradle, just in case:
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
And a image with the libraries in the project, where you can see the tools...
This is an issue caused by importing tools in Core Dependency. Remove the dependency in the project(":desktop") of the Core Dependency and add it to desktop dependency.
You can also solve it by downloading the gdx tools and importing the jar file. Just create a library folders and paste the jar file. Then go to File > Project Structure > Modules and add the File Dependency which is your jar file.
dependencies {
compile files('libs/runnable-texturepacker.jar')
}
This should work fine.
I was trying to use the TexturePacker class within a class in the core module. However I discovered it to only be available in the desktop module.
This seems logical as the dependency of the tools extension is placed within the desktop project in the root build.gradle file when using the setup utility or following the official instructions to add the extension manually (see Add tools dependency).
Technically, you could move the dependency in the module you want to use TexturePacker in (say core), but according to the provided link this is discouraged. So I recommend you just write your class using TexturePacker within the desktop module.
PS: Note that due to the deprecation of "compile" a replacement by "implementation" in build.gradle might become necessary, but Android Studio will inform you in that case (use ctrl + r for efficient replacements).

Can't install Kontakt Android SDK using Gradle on Android Studio

I'm trying to install the Android SDK from Kontakt into a project in Android studio. I'm following the (seemingly basic) instructions on the Kontakt site here:
http://docs.kontakt.io/android-sdk/quickstart/#installing-the-sdk---android-studio
In brief, these steps say add maven { url 'http://repo.kontakt.io/repository/internal/' } in the repositories in your top-level build file, and add to add compile 'com.kontakt.sdk.android:library:1.0.5' in the dependencies in the main module build file.
However, when I try to sync my project with the updated files, it fails with an error message:
Error:Failed to find: com.kontakt.sdk.android:library:1.0.5
I tried with a totally fresh project and the same issue.
I'm guess this all has something to do with the fact that the instructions are written for Android's 0.12 version of the Gradle tools, but I'm using v1.1.0. I'm not across the detail of Gradle, so so any help would be appreciated.
My guess is that path to Kontakt.io public repository should be added to allprojects section instead of buildscript.
allprojects {
repositories {
jcenter()
maven { url 'http://repo.kontakt.io/repository/internal/' }
}
}
I am not 100% sure so don't shoot me:P
I think adding this line:
-->compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.kontakt.sdk.android:library:1.0.6'
Directly above the gradle project I wanted to compile fixed it.
Go to the Kontakt.io Android Proximity SDK https://github.com/kontaktio/kontakt-android-sdk on GitHub.
Click the Download ZIP button
Un-zip the file to a temporary location.
Add the jar file in your Android Studio Project.
File -> New Module -> Import .JAR/ .AAR Package -> Click Next -> Browse the SDK path (2.1.1) -> Finish (Take time to add in the project)
Then, Add module in dependencies
Right Click on Project Name -> Open Module Settings -> Under the list (Modules) -> Click on Dependencies -> Click on '+' -> Module Dependency -> Add Kontakt.io-android-sdk
Now Build your project It worked for me to kontakt io SDK. If anybody find the way to do this as Gradle build, please let me know.

how to add a local android lib to gradle build?

I have an android library (source) that I have been using in eclipse and i need to port to android studio. I have the library building as its own project. but now i want to use it in another project (somewhere else on the filesystem).
How can i declare this library project to my other project. I don't want to copy the files over but rather use it in place. so it cant be under the other project dir hierarchy.
Hope it make sense. If you need more info let just ask. possibly i have to add stuff to publish it as an artifact? when i was using maven i would declare it as a module with a file path ....
tried
repositories {
flatDir {
dirs 'path'
}
}
but to no avail ...
may get diff results with diff gradle versions but i've done this on 1.10...
gradle.settings
include '..:youLib'
AndroidManifest for your lib...
make sure its minimal and it does not contain "ActivityName" or "launcher" props
build.gradle
dependencies {
compile project(':..:youLib')
You need to declare libraries in dependencies section:
E.g.
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}

Android Studio adding external JAR to the project

I'm trying all I can to add an external JAR file to my project but I just can't do it. Here's what I'm doing atm:
Copying JAR to libs folder
Hitting "Add as library" and selecting jar package option
Modifying build.gradle to include the new jar, I'm doing it simply like this:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
Yet I'm still getting some weird error on Pre Dex phase:
Android Pre Dex: [StartAppUnifiedSDK-3.0.2.jar] UNEXPECTED TOP-LEVEL EXCEPTION:
Android Pre Dex: [StartAppUnifiedSDK-3.0.2.jar] java.util.zip.ZipException: error in opening zip file
Any ideas on what might be wrong?
the error message format shows that you are not using Gradle to build. You either loaded the eclipse project file (.classpath/.project) or had some existing iml files.
This means changes to build.gradle will have no effect since Studio uses the IntelliJ internal builders instead.
You need to import your build.gradle file instead to create a new Studio project.

Resources