I am having trouble viewing my jar files. All the jar files in the libs directory in my app module show sources not found and allow me the option to attach sources. What exactly should I attach to view these jars in their entirety without the annoying comment "compiled code"?
This is the build.gradle
file from the app and not the overarching one for the project:
apply plugin: 'com.android.application'
apply plugin: 'com.parse'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.parse.com/repo' }
}
dependencies {
classpath 'com.parse.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
dependencies {
compile fileTree (dir:'libs', include:['*.jar'])
}
}
Here is one of the classes in one of the jars in my libs folder (notice all of the comments and also it is not able to be edited):
package net.fortuna.ical4j.data;
public abstract class AbstractOutputter {
protected static final java.nio.charset.Charset DEFAULT_CHARSET;
private boolean validating;
protected int foldLength;
public AbstractOutputter() { /* compiled code */ }
public AbstractOutputter(boolean validating) { /* compiled code */ }
public AbstractOutputter(boolean validating, int foldLength) { /* compiled code */ }
public final boolean isValidating() { /* compiled code */ }
public final void setValidating(boolean validating) { /* compiled code */ }
}
Here is my XML in the libraries folder of my project for one of my jar files if this helps:
<component name="libraryTable">
<library name="ical4j-1.0.6">
<CLASSES>
<root url="jar://$PROJECT_DIR$/app/libs/ical4j-1.0.6.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.ideaLibSources/ical4j-1.0.6-sources.jar!/" />
</SOURCES>
</library>
</component>
Notice where the sources are.
If anyone was wondering, I figured it out. All I had to do was download( in my case) the source files from github as a zip file. I extracted it with7-zip and then at the top right of the IDE where it says "attach sources" I clicked on the extracted folder. Now I can view all of the code.
Add this at the end of your gradle.build file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
This will make your build take under consideration your .jar files
You need to add it to your gradle MODULE file. You probably added it to your PROJECT gradle file. See an example of mine of a gradle MODULE file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "bruno.stackrest"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.